@kaitranntt/ccs 7.56.0-dev.1 → 7.56.0-dev.3
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/README.md +22 -11
- package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
- package/dist/api/services/profile-lifecycle-service.js +10 -10
- package/dist/api/services/profile-lifecycle-service.js.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +33 -36
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +46 -48
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/bin/droid-runtime.d.ts +1 -0
- package/dist/bin/droid-runtime.d.ts.map +1 -0
- package/dist/bin/droid-runtime.js +5 -0
- package/dist/bin/droid-runtime.js.map +1 -0
- package/dist/cliproxy/account-manager.d.ts +1 -1
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +4 -1
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/accounts/index.d.ts +1 -1
- package/dist/cliproxy/accounts/index.d.ts.map +1 -1
- package/dist/cliproxy/accounts/index.js +4 -1
- package/dist/cliproxy/accounts/index.js.map +1 -1
- package/dist/cliproxy/accounts/query.d.ts.map +1 -1
- package/dist/cliproxy/accounts/query.js +4 -6
- package/dist/cliproxy/accounts/query.js.map +1 -1
- package/dist/cliproxy/accounts/registry.d.ts +2 -2
- package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
- package/dist/cliproxy/accounts/registry.js +292 -320
- package/dist/cliproxy/accounts/registry.js.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts +16 -1
- package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -1
- package/dist/cliproxy/accounts/token-file-ops.js +55 -3
- package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
- package/dist/cliproxy/ai-providers/config-store.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/config-store.js +37 -4
- package/dist/cliproxy/ai-providers/config-store.js.map +1 -1
- package/dist/cliproxy/ai-providers/service.d.ts +2 -2
- package/dist/cliproxy/ai-providers/service.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/service.js +39 -10
- package/dist/cliproxy/ai-providers/service.js.map +1 -1
- package/dist/cliproxy/ai-providers/types.d.ts +2 -0
- package/dist/cliproxy/ai-providers/types.d.ts.map +1 -1
- package/dist/cliproxy/ai-providers/types.js.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +31 -69
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/auth/oauth-process.d.ts +1 -0
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-process.js +5 -5
- package/dist/cliproxy/auth/oauth-process.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +53 -20
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/cliproxy/auth-token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth-token-manager.js +47 -50
- package/dist/cliproxy/auth-token-manager.js.map +1 -1
- package/dist/cliproxy/executor/index.js +1 -1
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.js +43 -39
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
- package/dist/commands/api-command/create-command.d.ts.map +1 -1
- package/dist/commands/api-command/create-command.js +8 -4
- package/dist/commands/api-command/create-command.js.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +0 -5
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +6 -16
- package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts +6 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts.map +1 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js +15 -0
- package/dist/commands/cliproxy/resolve-lifecycle-port.js.map +1 -0
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +12 -6
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/config-auth/disable-command.d.ts.map +1 -1
- package/dist/commands/config-auth/disable-command.js +8 -8
- package/dist/commands/config-auth/disable-command.js.map +1 -1
- package/dist/commands/config-auth/setup-command.d.ts.map +1 -1
- package/dist/commands/config-auth/setup-command.js +9 -11
- package/dist/commands/config-auth/setup-command.js.map +1 -1
- package/dist/commands/copilot-command.js +11 -11
- package/dist/commands/copilot-command.js.map +1 -1
- package/dist/commands/cursor-command.d.ts.map +1 -1
- package/dist/commands/cursor-command.js +11 -11
- package/dist/commands/cursor-command.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +10 -8
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/setup-command.d.ts.map +1 -1
- package/dist/commands/setup-command.js +4 -3
- package/dist/commands/setup-command.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +39 -32
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/targets/target-resolver.d.ts +2 -2
- package/dist/targets/target-resolver.d.ts.map +1 -1
- package/dist/targets/target-resolver.js +68 -18
- package/dist/targets/target-resolver.js.map +1 -1
- package/dist/ui/assets/{accounts-CccaoV-N.js → accounts-_HKzUYeW.js} +1 -1
- package/dist/ui/assets/{alert-dialog-D838sIju.js → alert-dialog-7NHGF_Xe.js} +1 -1
- package/dist/ui/assets/api-DOfVbQ1z.js +4 -0
- package/dist/ui/assets/{auth-section-BGCaHAcN.js → auth-section-DqMIwU7c.js} +1 -1
- package/dist/ui/assets/{backups-section-CqZN-2Qq.js → backups-section-D4um8aUY.js} +1 -1
- package/dist/ui/assets/{checkbox-BgLi38k2.js → checkbox-BOeXuNDh.js} +1 -1
- package/dist/ui/assets/{claude-extension-ClHnH_4i.js → claude-extension-CelZ8ku0.js} +1 -1
- package/dist/ui/assets/cliproxy-CzJfXgOZ.js +3 -0
- package/dist/ui/assets/{cliproxy-ai-providers-EhHqrkRr.js → cliproxy-ai-providers-BYWaYXvO.js} +3 -3
- package/dist/ui/assets/{cliproxy-control-panel-lRQBQhPS.js → cliproxy-control-panel-77ZZmJI4.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-t6i94F2B.js → confirm-dialog-Bz3IbucG.js} +1 -1
- package/dist/ui/assets/{copilot-DlSkTZ2q.js → copilot-DzskqpA-.js} +1 -1
- package/dist/ui/assets/{cursor-DJvTEVHh.js → cursor-C8f14wrT.js} +1 -1
- package/dist/ui/assets/{droid-wevxXBVG.js → droid-DR0b5dXu.js} +2 -2
- package/dist/ui/assets/{globalenv-section-De072K_j.js → globalenv-section-O2tusa4k.js} +1 -1
- package/dist/ui/assets/{health-Wv80MRCF.js → health-BPuHhvGU.js} +1 -1
- package/dist/ui/assets/{icons-DMeZET56.js → icons-DR-ORtNe.js} +1 -1
- package/dist/ui/assets/{index-BmB4ckDm.js → index-3azdVT3y.js} +1 -1
- package/dist/ui/assets/{index-BqdBnk5l.js → index-BxTb3XSE.js} +1 -1
- package/dist/ui/assets/{index-C9TiCNLM.js → index-D0r4vaLi.js} +1 -1
- package/dist/ui/assets/index-ZlUC3TcJ.js +47 -0
- package/dist/ui/assets/{index-CxPqnEpn.js → index-eQOk8v6I.js} +1 -1
- package/dist/ui/assets/index-kGiBvBM-.css +1 -0
- package/dist/ui/assets/{proxy-status-widget-DMe8konR.js → proxy-status-widget-CU9RtUUZ.js} +1 -1
- package/dist/ui/assets/{searchable-select-C-dUgzQ_.js → searchable-select-DltMdKve.js} +1 -1
- package/dist/ui/assets/{separator-TnQMGoEt.js → separator-DvmULQuv.js} +1 -1
- package/dist/ui/assets/{shared-Cbcz8ZIu.js → shared-3KjBmAma.js} +1 -1
- package/dist/ui/assets/{switch-Df15Gmz9.js → switch-WfgHsT03.js} +1 -1
- package/dist/ui/assets/{updates-WOEYNHTJ.js → updates-DEb1kb0C.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/web-server/health-service.d.ts.map +1 -1
- package/dist/web-server/health-service.js +2 -3
- package/dist/web-server/health-service.js.map +1 -1
- package/dist/web-server/middleware/auth-middleware.d.ts +2 -0
- package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
- package/dist/web-server/middleware/auth-middleware.js +23 -1
- package/dist/web-server/middleware/auth-middleware.js.map +1 -1
- package/dist/web-server/routes/ai-provider-routes.d.ts.map +1 -1
- package/dist/web-server/routes/ai-provider-routes.js +19 -13
- package/dist/web-server/routes/ai-provider-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts +7 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +119 -32
- package/dist/web-server/routes/cliproxy-auth-routes.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 +6 -0
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-sync-routes.js +6 -11
- package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cursor-settings-routes.js +36 -33
- package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
- package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
- package/dist/web-server/routes/misc-routes.js +26 -19
- package/dist/web-server/routes/misc-routes.js.map +1 -1
- package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
- package/dist/web-server/routes/proxy-routes.js +6 -0
- package/dist/web-server/routes/proxy-routes.js.map +1 -1
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
- package/dist/web-server/routes/settings-routes.js +143 -109
- package/dist/web-server/routes/settings-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 +31 -43
- package/dist/web-server/routes/websearch-routes.js.map +1 -1
- package/dist/web-server/shared-routes.d.ts.map +1 -1
- package/dist/web-server/shared-routes.js +6 -0
- package/dist/web-server/shared-routes.js.map +1 -1
- package/package.json +3 -2
- package/scripts/add-shebang.js +33 -20
- package/dist/ui/assets/api-IXigV-A_.js +0 -4
- package/dist/ui/assets/cliproxy-qX23viWV.js +0 -3
- package/dist/ui/assets/index-DRmZP4OP.css +0 -1
- package/dist/ui/assets/index-N_jd9sKU.js +0 -47
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Resolves which CLI target to use based on:
|
|
6
6
|
* 1. --target flag (highest priority)
|
|
7
|
-
* 2.
|
|
8
|
-
* 3.
|
|
7
|
+
* 2. Runtime alias entrypoint / argv[0] detection
|
|
8
|
+
* 3. Per-profile config
|
|
9
9
|
* 4. Default: 'claude'
|
|
10
10
|
*/
|
|
11
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -35,28 +35,75 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
exports.stripTargetFlag = exports.resolveTargetType = void 0;
|
|
36
36
|
const path = __importStar(require("path"));
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Built-in argv[0] aliases for explicit runtime entrypoints.
|
|
39
|
+
* `ccs-droid` is the transparent alias; `ccsd` remains as a legacy shortcut.
|
|
40
40
|
*/
|
|
41
|
-
const
|
|
41
|
+
const BUILTIN_ARGV0_TARGET_MAP = {
|
|
42
|
+
'ccs-droid': 'droid',
|
|
42
43
|
ccsd: 'droid',
|
|
43
44
|
};
|
|
44
45
|
const ALIAS_NAME_REGEX = /^[a-z0-9._-]+$/;
|
|
46
|
+
const INTERNAL_ENTRY_TARGET_ENV_VAR = 'CCS_INTERNAL_ENTRY_TARGET';
|
|
47
|
+
const GENERIC_TARGET_ALIAS_ENV_VAR = 'CCS_TARGET_ALIASES';
|
|
48
|
+
const LEGACY_TARGET_ALIAS_ENV_VARS = {
|
|
49
|
+
droid: 'CCS_DROID_ALIASES',
|
|
50
|
+
};
|
|
51
|
+
const RESERVED_BIN_NAMES = new Set(['ccs', ...Object.keys(BUILTIN_ARGV0_TARGET_MAP)]);
|
|
52
|
+
function addAliasToMap(map, alias, target) {
|
|
53
|
+
const normalizedAlias = alias.trim().toLowerCase();
|
|
54
|
+
if (!normalizedAlias ||
|
|
55
|
+
!ALIAS_NAME_REGEX.test(normalizedAlias) ||
|
|
56
|
+
RESERVED_BIN_NAMES.has(normalizedAlias)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
map[normalizedAlias] = target;
|
|
60
|
+
}
|
|
61
|
+
function addAliasListToMap(map, target, rawAliases) {
|
|
62
|
+
for (const rawAlias of rawAliases.split(',')) {
|
|
63
|
+
addAliasToMap(map, rawAlias, target);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function parseGenericTargetAliasConfig(map, rawConfig) {
|
|
67
|
+
for (const rawEntry of rawConfig.split(';')) {
|
|
68
|
+
const entry = rawEntry.trim();
|
|
69
|
+
if (!entry) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const separatorIndex = entry.indexOf('=');
|
|
73
|
+
if (separatorIndex <= 0 || separatorIndex === entry.length - 1) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const rawTarget = entry.slice(0, separatorIndex).trim().toLowerCase();
|
|
77
|
+
const rawAliases = entry.slice(separatorIndex + 1).trim();
|
|
78
|
+
if (!rawAliases || !isValidTarget(rawTarget)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
addAliasListToMap(map, rawTarget, rawAliases);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
45
84
|
function buildArgv0TargetMap() {
|
|
46
|
-
const map = { ...
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
|
|
85
|
+
const map = { ...BUILTIN_ARGV0_TARGET_MAP };
|
|
86
|
+
const genericAliasConfig = process.env[GENERIC_TARGET_ALIAS_ENV_VAR];
|
|
87
|
+
if (genericAliasConfig) {
|
|
88
|
+
parseGenericTargetAliasConfig(map, genericAliasConfig);
|
|
50
89
|
}
|
|
51
|
-
for (const
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
90
|
+
for (const [target, envVar] of Object.entries(LEGACY_TARGET_ALIAS_ENV_VARS)) {
|
|
91
|
+
const rawAliases = process.env[envVar];
|
|
92
|
+
if (!rawAliases) {
|
|
54
93
|
continue;
|
|
55
94
|
}
|
|
56
|
-
map
|
|
95
|
+
addAliasListToMap(map, target, rawAliases);
|
|
57
96
|
}
|
|
58
97
|
return map;
|
|
59
98
|
}
|
|
99
|
+
function resolveEntrypointTarget() {
|
|
100
|
+
const rawTarget = process.env[INTERNAL_ENTRY_TARGET_ENV_VAR];
|
|
101
|
+
if (!rawTarget) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const normalizedTarget = rawTarget.trim().toLowerCase();
|
|
105
|
+
return isValidTarget(normalizedTarget) ? normalizedTarget : null;
|
|
106
|
+
}
|
|
60
107
|
/**
|
|
61
108
|
* Valid target types for --target flag validation.
|
|
62
109
|
*/
|
|
@@ -121,12 +168,11 @@ function resolveTargetType(args, profileConfig) {
|
|
|
121
168
|
if (parsed.targetOverride) {
|
|
122
169
|
return parsed.targetOverride;
|
|
123
170
|
}
|
|
124
|
-
// 2. Check
|
|
125
|
-
|
|
126
|
-
|
|
171
|
+
// 2. Check runtime alias entrypoint / argv[0]
|
|
172
|
+
const entrypointTarget = resolveEntrypointTarget();
|
|
173
|
+
if (entrypointTarget) {
|
|
174
|
+
return entrypointTarget;
|
|
127
175
|
}
|
|
128
|
-
// 3. Check argv[0] (busybox pattern)
|
|
129
|
-
// Strip common wrapper extensions for Windows shims/wrappers
|
|
130
176
|
const rawBin = path.basename(process.argv[1] || process.argv0 || '');
|
|
131
177
|
const binName = rawBin.replace(/\.(cmd|bat|ps1|exe)$/i, '').toLowerCase();
|
|
132
178
|
const argv0TargetMap = buildArgv0TargetMap();
|
|
@@ -134,6 +180,10 @@ function resolveTargetType(args, profileConfig) {
|
|
|
134
180
|
if (argv0Target) {
|
|
135
181
|
return argv0Target;
|
|
136
182
|
}
|
|
183
|
+
// 3. Check per-profile config
|
|
184
|
+
if (profileConfig?.target !== undefined) {
|
|
185
|
+
return isValidTarget(profileConfig.target) ? profileConfig.target : 'claude';
|
|
186
|
+
}
|
|
137
187
|
// 4. Default
|
|
138
188
|
return 'claude';
|
|
139
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-resolver.js","sourceRoot":"","sources":["../../src/targets/target-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAG7B;;;GAGG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"target-resolver.js","sourceRoot":"","sources":["../../src/targets/target-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAG7B;;;GAGG;AACH,MAAM,wBAAwB,GAA+B;IAC3D,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,OAAO;CACd,CAAC;AACF,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAC1C,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAClE,MAAM,4BAA4B,GAAG,oBAAoB,CAAC;AAC1D,MAAM,4BAA4B,GAAwC;IACxE,KAAK,EAAE,mBAAmB;CAC3B,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAE9F,SAAS,aAAa,CAAC,GAA+B,EAAE,KAAa,EAAE,MAAkB;IACvF,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnD,IACE,CAAC,eAAe;QAChB,CAAC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC;QACvC,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,EACvC,CAAC;QACD,OAAO;IACT,CAAC;IAED,GAAG,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC;AAChC,CAAC;AAED,SAAS,iBAAiB,CACxB,GAA+B,EAC/B,MAAkB,EAClB,UAAkB;IAElB,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,SAAS,6BAA6B,CAAC,GAA+B,EAAE,SAAiB;IACvF,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,SAAS;QACX,CAAC;QAED,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,cAAc,IAAI,CAAC,IAAI,cAAc,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/D,SAAS;QACX,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,UAAU,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,SAAS;QACX,CAAC;QAED,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,GAAG,GAA+B,EAAE,GAAG,wBAAwB,EAAE,CAAC;IACxE,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IACrE,IAAI,kBAAkB,EAAE,CAAC;QACvB,6BAA6B,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAEzE,EAAE,CAAC;QACF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,SAAS;QACX,CAAC;QAED,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC7D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxD,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AAED;;GAEG;AACH,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAOpF,SAAS,aAAa,CAAC,MAAe;IACpC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,CAAC,MAAoB,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAwB,CAAC;IAClC,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,iBAAiB,SAAS,EAAE,CAAC,CAAC;AACxE,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,IAAc;IACtC,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,cAAsC,CAAC;IAE3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpB,gEAAgE;QAChE,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM;QACR,CAAC;QAED,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,cAAc,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa;YACrB,SAAS;QACX,CAAC;QAED,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YACnD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,cAAc,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC7C,SAAS;QACX,CAAC;QAED,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,IAAc,EACd,aAAuC;IAEvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAEtC,4CAA4C;IAC5C,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,8CAA8C;IAC9C,MAAM,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IACnD,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1E,MAAM,cAAc,GAAG,mBAAmB,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,8BAA8B;IAC9B,IAAI,aAAa,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/E,CAAC;IAED,aAAa;IACb,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhCD,8CAgCC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAc;IAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;AAC5C,CAAC;AAFD,0CAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as f,h as je}from"./react-vendor-CNOkPC89.js";import{u as ye,a as L,b as z,d as be,f as B,g as Ne}from"./tanstack-B8i0evp-.js";import{c as y,Y as T,a as O,ad as oe,ae as re,af as le,ag as ie,ah as de,L as P,r as Q,s as I,t as Z,v as V,w as G,I as $,at as Ce,d as u,C as S,j as D,k,_ as M,B as F,b as w,M as ue,N as xe,O as me,n as ve,x as X}from"./index-N_jd9sKU.js";import{A as Pe,a as Ae,b as Se,c as De,d as ke,e as we,f as Te,g as _e}from"./alert-dialog-D838sIju.js";import{t as b}from"./notifications-B2HqRBj7.js";import{aM as Me,aN as Le,l as q,ai as ze,I as Oe,Q as Ge,n as W,aO as Fe,an as R,aP as Re,aQ as He,r as he,aR as $e,aS as qe,U as Ee,a3 as Y,Z as J,T as Ke}from"./icons-DMeZET56.js";import{C as ee}from"./checkbox-BgLi38k2.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ue({className:s,...a}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:y("w-full caption-bottom text-sm",s),...a})})}function Be({className:s,...a}){return e.jsx("thead",{"data-slot":"table-header",className:y("[&_tr]:border-b",s),...a})}function Qe({className:s,...a}){return e.jsx("tbody",{"data-slot":"table-body",className:y("[&_tr:last-child]:border-0",s),...a})}function te({className:s,...a}){return e.jsx("tr",{"data-slot":"table-row",className:y("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...a})}function Ie({className:s,...a}){return e.jsx("th",{"data-slot":"table-head",className:y("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}function Ze({className:s,...a}){return e.jsx("td",{"data-slot":"table-cell",className:y("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}function Ve(){return ye({queryKey:["accounts"],queryFn:()=>T.accounts.list(),select:s=>{const a=s.accounts.filter(l=>l.type!=="cliproxy"),t=s.accounts.length-a.length,c=a.filter(l=>l.context_mode==="shared").length,o=a.filter(l=>l.context_mode==="shared"&&l.continuity_mode==="deeper").length,x=Math.max(c-o,0),i=a.length-c,m=a.filter(l=>l.context_inferred).length,g=a.filter(l=>l.context_mode==="shared"&&l.continuity_mode!=="deeper"&&l.continuity_inferred).length,p=a.some(l=>l.name===s.default)?s.default:null;return{accounts:a,default:p,cliproxyCount:t,legacyContextCount:m,legacyContinuityCount:g,sharedCount:c,sharedStandardCount:x,deeperSharedCount:o,isolatedCount:i}}})}function Xe(){const s=L();return z({mutationFn:a=>T.accounts.setDefault(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),b.success(`Default account set to "${t}"`)},onError:a=>{b.error(a.message)}})}function We(){const s=L();return z({mutationFn:()=>T.accounts.resetDefault(),onSuccess:()=>{s.invalidateQueries({queryKey:["accounts"]}),b.success("Default account reset to CCS")},onError:a=>{b.error(a.message)}})}function Ye(){const s=L();return z({mutationFn:a=>T.accounts.delete(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),b.success(`Account "${t}" deleted`)},onError:a=>{b.error(a.message)}})}function ge(){const s=L();return z({mutationFn:({name:a,context_mode:t,context_group:c,continuity_mode:o})=>T.accounts.updateContext(a,{context_mode:t,context_group:c,continuity_mode:o}),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]});const c=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";b.success(`Updated "${t.name}" context to ${c}`)},onError:a=>{b.error(a.message)}})}function Je(){const s=L();return z({mutationFn:async a=>{const t=a.filter(c=>c.context_inferred||c.continuity_inferred);for(const c of t){const o=c.context_mode==="shared";await T.accounts.updateContext(c.name,{context_mode:o?"shared":"isolated",context_group:o?c.context_group||"default":void 0,continuity_mode:o?c.continuity_mode==="deeper"?"deeper":"standard":void 0})}return{updatedCount:t.length}},onSuccess:({updatedCount:a})=>{if(s.invalidateQueries({queryKey:["accounts"]}),a>0){b.success(`Confirmed explicit sync mode for ${a} legacy account${a>1?"s":""}`);return}b.info("No legacy accounts need confirmation")},onError:a=>{b.error(a.message)}})}const se=64,et=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function tt({account:s,onClose:a}){const{t}=O(),c=ge(),[o,x]=f.useState(s.context_mode==="shared"?"shared":"isolated"),[i,m]=f.useState(s.context_group||"default"),[g,p]=f.useState(s.continuity_mode==="deeper"?"deeper":"standard"),l=f.useMemo(()=>i.trim().toLowerCase().replace(/\s+/g,"-"),[i]),N=l.length>0&&l.length<=se&&et.test(l),j=o==="isolated"||N,n=()=>{j&&c.mutate({name:s.name,context_mode:o,context_group:o==="shared"?l:void 0,continuity_mode:o==="shared"?g:void 0},{onSuccess:()=>{a()}})},r=d=>{d||a()};return e.jsx(oe,{open:!0,onOpenChange:r,children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(ie,{children:t("editAccountContext.title")}),e.jsx(de,{children:t("editAccountContext.description",{name:s.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"context-mode",children:t("editAccountContext.syncMode")}),e.jsxs(Q,{value:o,onValueChange:d=>x(d),children:[e.jsx(I,{id:"context-mode",children:e.jsx(Z,{placeholder:t("editAccountContext.selectContextMode")})}),e.jsxs(V,{children:[e.jsx(G,{value:"isolated",children:t("editAccountContext.isolatedOption")}),e.jsx(G,{value:"shared",children:t("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(o==="shared"?"editAccountContext.sharedModeHint":"editAccountContext.isolatedModeHint")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"context-group",children:t("editAccountContext.historySyncGroup")}),e.jsx($,{id:"context-group",value:i,onChange:d=>m(d.target.value),placeholder:t("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.groupHint",{max:se})}),!N&&e.jsx("p",{className:"text-xs text-destructive",children:t("editAccountContext.invalidGroup")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"continuity-mode",children:t("editAccountContext.continuityDepth")}),e.jsxs(Q,{value:g,onValueChange:d=>p(d),children:[e.jsx(I,{id:"continuity-mode",children:e.jsx(Z,{placeholder:t("editAccountContext.selectContinuityDepth")})}),e.jsxs(V,{children:[e.jsx(G,{value:"standard",children:t("editAccountContext.standardOption")}),e.jsx(G,{value:"deeper",children:t("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(g==="deeper"?"editAccountContext.deeperHint":"editAccountContext.standardHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.credentialsIsolated")})]}),e.jsxs(Ce,{children:[e.jsx(u,{variant:"outline",onClick:a,disabled:c.isPending,children:t("editAccountContext.cancel")}),e.jsx(u,{onClick:n,disabled:!j||c.isPending,children:c.isPending?t("editAccountContext.saving"):t("editAccountContext.save")})]})]})})}function ae({data:s,defaultAccount:a}){const{t}=O(),c=Xe(),o=Ye(),x=We(),i=ge(),[m,g]=f.useState(null),[p,l]=f.useState(null),N=[{accessorKey:"name",header:t("accountsTable.name"),size:200,cell:({row:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n.original.name}),n.original.name===a&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:t("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:t("accountsTable.type"),size:100,cell:({row:n})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:n.original.type||"oauth"})},{accessorKey:"created",header:t("accountsTable.created"),size:150,cell:({row:n})=>{const r=new Date(n.original.created);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{accessorKey:"last_used",header:t("accountsTable.lastUsed"),size:150,cell:({row:n})=>{if(!n.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const r=new Date(n.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{id:"context",header:t("accountsTable.historySync"),size:170,cell:({row:n})=>{if(n.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((n.original.context_mode||"isolated")==="shared"){const d=n.original.context_group||"default";return n.original.continuity_mode==="deeper"?e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupDeeper",{group:d})}):n.original.continuity_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.sharedGroupLegacy",{group:d})}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupStandard",{group:d})})}return n.original.context_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.isolatedLegacy")}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.isolated")})}},{id:"actions",header:t("accountsTable.actions"),size:220,cell:({row:n})=>{const r=n.original.name===a,d=c.isPending||o.isPending||i.isPending,C=n.original.type==="cliproxy",A=n.original.context_inferred||n.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!C&&e.jsxs(u,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:d,onClick:()=>l(n.original),title:t("accountsTable.syncTitle"),children:[e.jsx(Me,{className:"w-3.5 h-3.5 mr-1"}),t("accountsTable.sync")]}),!C&&A&&e.jsxs(u,{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:d,onClick:()=>i.mutate({name:n.original.name,context_mode:n.original.context_mode==="shared"?"shared":"isolated",context_group:n.original.context_mode==="shared"?n.original.context_group||"default":void 0,continuity_mode:n.original.context_mode==="shared"?n.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:t("accountsTable.confirmLegacyTitle"),children:[e.jsx(Le,{className:"w-3 h-3 mr-1"}),t("accountsTable.confirm")]}),e.jsxs(u,{variant:r?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:r||d,onClick:()=>c.mutate(n.original.name),children:[e.jsx(q,{className:`w-3 h-3 mr-1 ${r?"opacity-50":""}`}),t(r?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:r||d,onClick:()=>g(n.original.name),title:t(r?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(ze,{className:"w-4 h-4"})})]})}}],j=be({data:s,columns:N,getCoreRowModel:Ne()});return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t("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(Ue,{children:[e.jsx(Be,{children:j.getHeaderGroups().map(n=>e.jsx(te,{children:n.headers.map(r=>{const d={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[r.id]||"w-auto";return e.jsx(Ie,{className:d,children:r.isPlaceholder?null:B(r.column.columnDef.header,r.getContext())},r.id)})},n.id))}),e.jsx(Qe,{children:j.getRowModel().rows.map(n=>e.jsx(te,{children:n.getVisibleCells().map(r=>e.jsx(Ze,{children:B(r.column.columnDef.cell,r.getContext())},r.id))},n.id))})]})}),a&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),t("accountsTable.resetToDefault")]})})]}),p&&e.jsx(tt,{account:p,onClose:()=>l(null)}),e.jsx(Pe,{open:!!m,onOpenChange:n=>!n&&g(null),children:e.jsxs(Ae,{children:[e.jsxs(Se,{children:[e.jsx(De,{children:t("accountsTable.deleteDialogTitle")}),e.jsx(ke,{children:t("accountsTable.deleteDialogDesc",{name:m??""})})]}),e.jsxs(we,{children:[e.jsx(Te,{children:t("accountsTable.cancel")}),e.jsx(_e,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m&&(o.mutate(m),g(null))},children:t("accountsTable.delete")})]})]})})]})}const ne=64;function st({open:s,onClose:a}){const{t}=O(),[c,o]=f.useState(""),[x,i]=f.useState(!1),[m,g]=f.useState(""),[p,l]=f.useState(!1),[N,j]=f.useState(!1),n=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(c),r=m.trim().toLowerCase().replace(/\s+/g,"-"),d=r.length===0||r.length<=ne&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(r),C=c&&n?[`ccs auth create ${c}`,x?r.length>0?`--context-group ${r}`:"--share-context":"",x&&p?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),A=async()=>{!n||x&&!d||(await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3))},_=()=>{o(""),i(!1),g(""),l(!1),j(!1),a()};return e.jsx(oe,{open:s,onOpenChange:h=>!h&&_(),children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(ie,{children:t("createAuthProfileDialog.title")}),e.jsx(de,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx($,{id:"profile-name",value:c,onChange:h=>o(h.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),c&&!n&&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(ee,{id:"share-context",checked:x,onCheckedChange:h=>i(h===!0)}),e.jsx(P,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),x&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(P,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx($,{id:"context-group",value:m,onChange:h=>g(h.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(ee,{id:"deeper-continuity",checked:p,onCheckedChange:h=>l(h===!0)}),e.jsx(P,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),m.trim().length>0&&!d&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:ne})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{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(Ge,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:C}),e.jsx(u,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:A,disabled:!n||x&&!d,children:N?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(W,{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(u,{variant:"ghost",onClick:_,children:t("createAuthProfileDialog.close")}),e.jsx(u,{onClick:A,disabled:!n||x&&!d,children:N?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function H({title:s,count:a,icon:t,tone:c}){const o={isolated:{border:"border-blue-300/60 bg-blue-50/40 dark:border-blue-900/40 dark:bg-blue-900/10",icon:"text-blue-700 dark:text-blue-400",count:"text-blue-700 dark:text-blue-400"},shared:{border:"border-emerald-300/60 bg-emerald-50/40 dark:border-emerald-900/40 dark:bg-emerald-900/10",icon:"text-emerald-700 dark:text-emerald-400",count:"text-emerald-700 dark:text-emerald-400"},deeper:{border:"border-indigo-300/60 bg-indigo-50/40 dark:border-indigo-900/40 dark:bg-indigo-900/10",icon:"text-indigo-700 dark:text-indigo-400",count:"text-indigo-700 dark:text-indigo-400"}};return e.jsxs("div",{className:y("rounded-md border p-2.5",o[c].border),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:s}),e.jsx(t,{className:y("h-3.5 w-3.5",o[c].icon)})]}),e.jsx("p",{className:y("mt-1 text-lg font-mono font-semibold",o[c].count),children:a})]})}function ce({isolatedCount:s,sharedStandardCount:a,deeperSharedCount:t,sharedGroups:c,legacyTargetCount:o,cliproxyCount:x}){const{t:i}=O(),[m,g]=f.useState(!1),p=c.length>0?c:["default"];return e.jsxs(S,{className:"border-dashed",children:[e.jsx(D,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-base",children:i("historySyncLearningMap.title")}),e.jsx(M,{className:"mt-1",children:i("historySyncLearningMap.description")})]}),e.jsx(F,{variant:"outline",children:i("historySyncLearningMap.learningMap")})]})}),e.jsxs(w,{className:"space-y-3",children:[x>0&&e.jsx("div",{className:"rounded-md border border-blue-300/60 bg-blue-50/40 px-3 py-2 text-xs text-blue-800 dark:border-blue-900/40 dark:bg-blue-900/10 dark:text-blue-300",children:i("historySyncLearningMap.cliproxyManaged",{count:x})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto_1fr_auto_1fr] sm:items-center",children:[e.jsx(H,{title:i("historySyncLearningMap.isolated"),count:s,icon:Fe,tone:"isolated"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(H,{title:i("historySyncLearningMap.shared"),count:a,icon:Re,tone:"shared"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(H,{title:i("historySyncLearningMap.deeper"),count:t,icon:He,tone:"deeper"})]}),e.jsxs(ue,{open:m,onOpenChange:g,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-8 w-full justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",children:[e.jsx("span",{children:i("historySyncLearningMap.showDetails")}),e.jsx(he,{className:y("h-4 w-4 transition-transform",m&&"rotate-180")})]})}),e.jsxs(me,{className:"pt-2",children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:i("historySyncLearningMap.modeSwitch")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:i("historySyncLearningMap.modeSwitchDesc")})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:i("historySyncLearningMap.historySyncGroup")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:i("historySyncLearningMap.historySyncGroupDesc")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:p.map(l=>e.jsx(F,{variant:"outline",className:"font-mono text-[10px]",children:l},l))})]})]}),o>0&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-300",children:i("historySyncLearningMap.legacyConfirmation",{count:o})})]})]})]})]})}function ht(){const{t:s}=O(),a=je(),{data:t,isLoading:c}=Ve(),o=Je(),[x,i]=f.useState(!1),[m,g]=f.useState(!1),p=t?.accounts||[],l=t?.cliproxyCount||0,N=t?.legacyContextCount||0,j=t?.legacyContinuityCount||0,n=t?.sharedCount||0,r=t?.sharedStandardCount||0,d=t?.deeperSharedCount||0,C=t?.isolatedCount||0,A=Array.from(new Set(p.filter(v=>v.context_mode==="shared").map(v=>v.context_group||"default"))).sort((v,fe)=>v.localeCompare(fe)),_=p.filter(v=>v.context_inferred||v.continuity_inferred),h=_.length,pe=h>0,E=()=>a("/cliproxy?provider=claude"),K=()=>a("/cliproxy?provider=claude&action=auth"),U=()=>o.mutate(_);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] hidden 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(Ee,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.manageSuffix")]})]}),e.jsx(ve,{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:s("accountsPage.primaryActions")}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:()=>i(!0),children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:K,children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.authClaudeInPool")]}),e.jsxs(u,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:E,children:[s("accountsPage.openClaudePoolSettings"),e.jsx(R,{className:"w-4 h-4 ml-auto"})]})]}),pe?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("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(Ke,{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:[N>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContextPending",{count:N})}),j>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContinuityPending",{count:j})})]})]}),e.jsx(u,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:U,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:s("accountsPage.noLegacyFollowup")}),e.jsx(ue,{open:m,onOpenChange:g,children:e.jsxs(S,{children:[e.jsx(D,{className:"pb-2",children:e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-auto w-full justify-between px-0 py-0",children:[e.jsxs("div",{className:"text-left",children:[e.jsx(k,{className:"text-sm",children:s("accountsPage.continuityGuide")}),e.jsx(M,{className:"mt-1",children:s("accountsPage.expandWhenNeeded")})]}),e.jsx(he,{className:y("h-4 w-4 transition-transform",m&&"rotate-180")})]})})}),e.jsx(me,{children:e.jsxs(w,{className:"space-y-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedStandard")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.sharedStandardDesc")})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedDeeper")}),e.jsxs("p",{className:"mt-1",children:[s("accountsPage.sharedDeeperPrefix")," ",e.jsx("code",{children:"session-env"}),","," ",e.jsx("code",{children:"file-history"}),", ",e.jsx("code",{children:"shell-snapshots"}),","," ",e.jsx("code",{children:"todos"}),"."]})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.isolated")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.isolatedDesc")})]})]})})]})}),e.jsxs(S,{children:[e.jsxs(D,{className:"pb-2",children:[e.jsx(k,{className:"text-sm",children:s("accountsPage.quickCommands")}),e.jsx(M,{children:s("accountsPage.quickCommandsDesc")})]}),e.jsxs(w,{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(X,{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(X,{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(F,{variant:"outline",children:s("accountsPage.workspaceBadge")}),e.jsx(F,{variant:"secondary",children:s("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:s("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[s("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:s("accountsTable.sync")}),s("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(ce,{isolatedCount:C,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:A,legacyTargetCount:h,cliproxyCount:l}),e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(D,{className:"pb-3",children:[e.jsx(k,{className:"text-lg",children:s("accountsPage.accountMatrix")}),e.jsx(M,{children:s("accountsPage.sharedTotalDesc",{count:n})})]}),e.jsx(w,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(S,{children:[e.jsxs(D,{children:[e.jsx(k,{className:"text-lg",children:s("accountsPage.title")}),e.jsxs(M,{children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.mobileManageSuffix")]})]}),e.jsxs(w,{className:"space-y-2",children:[e.jsxs(u,{className:"w-full",onClick:()=>i(!0),children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:E,children:[s("accountsPage.openCliProxyClaudePool"),e.jsx(R,{className:"w-4 h-4 ml-2"})]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:K,children:[s("accountsPage.authClaudeInPool"),e.jsx(J,{className:"w-4 h-4 ml-2"})]}),e.jsx(u,{variant:"outline",className:"w-full",onClick:U,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}),e.jsx(ce,{isolatedCount:C,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:A,legacyTargetCount:h,cliproxyCount:l}),e.jsxs(S,{children:[e.jsx(D,{className:"pb-3",children:e.jsx(k,{className:"text-base",children:s("accountsPage.accountMatrix")})}),e.jsx(w,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]}),e.jsx(st,{open:x,onClose:()=>i(!1)})]})}export{ht as AccountsPage};
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as f,h as je}from"./react-vendor-CNOkPC89.js";import{u as ye,a as L,b as z,d as be,f as B,g as Ne}from"./tanstack-B8i0evp-.js";import{c as y,Y as T,a as O,ad as oe,ae as re,af as le,ag as ie,ah as de,L as P,r as Q,s as I,t as Z,v as V,w as G,I as $,as as Ce,d as u,C as S,j as D,k,_ as M,B as F,b as w,M as ue,N as xe,O as me,n as ve,x as X}from"./index-ZlUC3TcJ.js";import{A as Pe,a as Ae,b as Se,c as De,d as ke,e as we,f as Te,g as _e}from"./alert-dialog-7NHGF_Xe.js";import{t as b}from"./notifications-B2HqRBj7.js";import{aM as Me,aN as Le,l as q,ai as ze,I as Oe,Q as Ge,n as W,aO as Fe,ap as R,aP as Re,aQ as He,r as he,aR as $e,aS as qe,U as Ee,a3 as Y,Z as J,T as Ke}from"./icons-DR-ORtNe.js";import{C as ee}from"./checkbox-BOeXuNDh.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Ue({className:s,...a}){return e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:y("w-full caption-bottom text-sm",s),...a})})}function Be({className:s,...a}){return e.jsx("thead",{"data-slot":"table-header",className:y("[&_tr]:border-b",s),...a})}function Qe({className:s,...a}){return e.jsx("tbody",{"data-slot":"table-body",className:y("[&_tr:last-child]:border-0",s),...a})}function te({className:s,...a}){return e.jsx("tr",{"data-slot":"table-row",className:y("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",s),...a})}function Ie({className:s,...a}){return e.jsx("th",{"data-slot":"table-head",className:y("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}function Ze({className:s,...a}){return e.jsx("td",{"data-slot":"table-cell",className:y("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a})}function Ve(){return ye({queryKey:["accounts"],queryFn:()=>T.accounts.list(),select:s=>{const a=s.accounts.filter(l=>l.type!=="cliproxy"),t=s.accounts.length-a.length,c=a.filter(l=>l.context_mode==="shared").length,o=a.filter(l=>l.context_mode==="shared"&&l.continuity_mode==="deeper").length,x=Math.max(c-o,0),i=a.length-c,m=a.filter(l=>l.context_inferred).length,g=a.filter(l=>l.context_mode==="shared"&&l.continuity_mode!=="deeper"&&l.continuity_inferred).length,p=a.some(l=>l.name===s.default)?s.default:null;return{accounts:a,default:p,cliproxyCount:t,legacyContextCount:m,legacyContinuityCount:g,sharedCount:c,sharedStandardCount:x,deeperSharedCount:o,isolatedCount:i}}})}function Xe(){const s=L();return z({mutationFn:a=>T.accounts.setDefault(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),b.success(`Default account set to "${t}"`)},onError:a=>{b.error(a.message)}})}function We(){const s=L();return z({mutationFn:()=>T.accounts.resetDefault(),onSuccess:()=>{s.invalidateQueries({queryKey:["accounts"]}),b.success("Default account reset to CCS")},onError:a=>{b.error(a.message)}})}function Ye(){const s=L();return z({mutationFn:a=>T.accounts.delete(a),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]}),b.success(`Account "${t}" deleted`)},onError:a=>{b.error(a.message)}})}function ge(){const s=L();return z({mutationFn:({name:a,context_mode:t,context_group:c,continuity_mode:o})=>T.accounts.updateContext(a,{context_mode:t,context_group:c,continuity_mode:o}),onSuccess:(a,t)=>{s.invalidateQueries({queryKey:["accounts"]});const c=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";b.success(`Updated "${t.name}" context to ${c}`)},onError:a=>{b.error(a.message)}})}function Je(){const s=L();return z({mutationFn:async a=>{const t=a.filter(c=>c.context_inferred||c.continuity_inferred);for(const c of t){const o=c.context_mode==="shared";await T.accounts.updateContext(c.name,{context_mode:o?"shared":"isolated",context_group:o?c.context_group||"default":void 0,continuity_mode:o?c.continuity_mode==="deeper"?"deeper":"standard":void 0})}return{updatedCount:t.length}},onSuccess:({updatedCount:a})=>{if(s.invalidateQueries({queryKey:["accounts"]}),a>0){b.success(`Confirmed explicit sync mode for ${a} legacy account${a>1?"s":""}`);return}b.info("No legacy accounts need confirmation")},onError:a=>{b.error(a.message)}})}const se=64,et=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function tt({account:s,onClose:a}){const{t}=O(),c=ge(),[o,x]=f.useState(s.context_mode==="shared"?"shared":"isolated"),[i,m]=f.useState(s.context_group||"default"),[g,p]=f.useState(s.continuity_mode==="deeper"?"deeper":"standard"),l=f.useMemo(()=>i.trim().toLowerCase().replace(/\s+/g,"-"),[i]),N=l.length>0&&l.length<=se&&et.test(l),j=o==="isolated"||N,n=()=>{j&&c.mutate({name:s.name,context_mode:o,context_group:o==="shared"?l:void 0,continuity_mode:o==="shared"?g:void 0},{onSuccess:()=>{a()}})},r=d=>{d||a()};return e.jsx(oe,{open:!0,onOpenChange:r,children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(ie,{children:t("editAccountContext.title")}),e.jsx(de,{children:t("editAccountContext.description",{name:s.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"context-mode",children:t("editAccountContext.syncMode")}),e.jsxs(Q,{value:o,onValueChange:d=>x(d),children:[e.jsx(I,{id:"context-mode",children:e.jsx(Z,{placeholder:t("editAccountContext.selectContextMode")})}),e.jsxs(V,{children:[e.jsx(G,{value:"isolated",children:t("editAccountContext.isolatedOption")}),e.jsx(G,{value:"shared",children:t("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(o==="shared"?"editAccountContext.sharedModeHint":"editAccountContext.isolatedModeHint")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"context-group",children:t("editAccountContext.historySyncGroup")}),e.jsx($,{id:"context-group",value:i,onChange:d=>m(d.target.value),placeholder:t("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.groupHint",{max:se})}),!N&&e.jsx("p",{className:"text-xs text-destructive",children:t("editAccountContext.invalidGroup")})]}),o==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"continuity-mode",children:t("editAccountContext.continuityDepth")}),e.jsxs(Q,{value:g,onValueChange:d=>p(d),children:[e.jsx(I,{id:"continuity-mode",children:e.jsx(Z,{placeholder:t("editAccountContext.selectContinuityDepth")})}),e.jsxs(V,{children:[e.jsx(G,{value:"standard",children:t("editAccountContext.standardOption")}),e.jsx(G,{value:"deeper",children:t("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t(g==="deeper"?"editAccountContext.deeperHint":"editAccountContext.standardHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("editAccountContext.credentialsIsolated")})]}),e.jsxs(Ce,{children:[e.jsx(u,{variant:"outline",onClick:a,disabled:c.isPending,children:t("editAccountContext.cancel")}),e.jsx(u,{onClick:n,disabled:!j||c.isPending,children:c.isPending?t("editAccountContext.saving"):t("editAccountContext.save")})]})]})})}function ae({data:s,defaultAccount:a}){const{t}=O(),c=Xe(),o=Ye(),x=We(),i=ge(),[m,g]=f.useState(null),[p,l]=f.useState(null),N=[{accessorKey:"name",header:t("accountsTable.name"),size:200,cell:({row:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n.original.name}),n.original.name===a&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:t("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:t("accountsTable.type"),size:100,cell:({row:n})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:n.original.type||"oauth"})},{accessorKey:"created",header:t("accountsTable.created"),size:150,cell:({row:n})=>{const r=new Date(n.original.created);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{accessorKey:"last_used",header:t("accountsTable.lastUsed"),size:150,cell:({row:n})=>{if(!n.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const r=new Date(n.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:r.toLocaleDateString()})}},{id:"context",header:t("accountsTable.historySync"),size:170,cell:({row:n})=>{if(n.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((n.original.context_mode||"isolated")==="shared"){const d=n.original.context_group||"default";return n.original.continuity_mode==="deeper"?e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupDeeper",{group:d})}):n.original.continuity_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.sharedGroupLegacy",{group:d})}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.sharedGroupStandard",{group:d})})}return n.original.context_inferred?e.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:t("accountsTable.isolatedLegacy")}):e.jsx("span",{className:"text-muted-foreground",children:t("accountsTable.isolated")})}},{id:"actions",header:t("accountsTable.actions"),size:220,cell:({row:n})=>{const r=n.original.name===a,d=c.isPending||o.isPending||i.isPending,C=n.original.type==="cliproxy",A=n.original.context_inferred||n.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!C&&e.jsxs(u,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:d,onClick:()=>l(n.original),title:t("accountsTable.syncTitle"),children:[e.jsx(Me,{className:"w-3.5 h-3.5 mr-1"}),t("accountsTable.sync")]}),!C&&A&&e.jsxs(u,{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:d,onClick:()=>i.mutate({name:n.original.name,context_mode:n.original.context_mode==="shared"?"shared":"isolated",context_group:n.original.context_mode==="shared"?n.original.context_group||"default":void 0,continuity_mode:n.original.context_mode==="shared"?n.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:t("accountsTable.confirmLegacyTitle"),children:[e.jsx(Le,{className:"w-3 h-3 mr-1"}),t("accountsTable.confirm")]}),e.jsxs(u,{variant:r?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:r||d,onClick:()=>c.mutate(n.original.name),children:[e.jsx(q,{className:`w-3 h-3 mr-1 ${r?"opacity-50":""}`}),t(r?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:r||d,onClick:()=>g(n.original.name),title:t(r?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(ze,{className:"w-4 h-4"})})]})}}],j=be({data:s,columns:N,getCoreRowModel:Ne()});return s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:t("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(Ue,{children:[e.jsx(Be,{children:j.getHeaderGroups().map(n=>e.jsx(te,{children:n.headers.map(r=>{const d={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[r.id]||"w-auto";return e.jsx(Ie,{className:d,children:r.isPlaceholder?null:B(r.column.columnDef.header,r.getContext())},r.id)})},n.id))}),e.jsx(Qe,{children:j.getRowModel().rows.map(n=>e.jsx(te,{children:n.getVisibleCells().map(r=>e.jsx(Ze,{children:B(r.column.columnDef.cell,r.getContext())},r.id))},n.id))})]})}),a&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),t("accountsTable.resetToDefault")]})})]}),p&&e.jsx(tt,{account:p,onClose:()=>l(null)}),e.jsx(Pe,{open:!!m,onOpenChange:n=>!n&&g(null),children:e.jsxs(Ae,{children:[e.jsxs(Se,{children:[e.jsx(De,{children:t("accountsTable.deleteDialogTitle")}),e.jsx(ke,{children:t("accountsTable.deleteDialogDesc",{name:m??""})})]}),e.jsxs(we,{children:[e.jsx(Te,{children:t("accountsTable.cancel")}),e.jsx(_e,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{m&&(o.mutate(m),g(null))},children:t("accountsTable.delete")})]})]})})]})}const ne=64;function st({open:s,onClose:a}){const{t}=O(),[c,o]=f.useState(""),[x,i]=f.useState(!1),[m,g]=f.useState(""),[p,l]=f.useState(!1),[N,j]=f.useState(!1),n=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(c),r=m.trim().toLowerCase().replace(/\s+/g,"-"),d=r.length===0||r.length<=ne&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(r),C=c&&n?[`ccs auth create ${c}`,x?r.length>0?`--context-group ${r}`:"--share-context":"",x&&p?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),A=async()=>{!n||x&&!d||(await navigator.clipboard.writeText(C),j(!0),setTimeout(()=>j(!1),2e3))},_=()=>{o(""),i(!1),g(""),l(!1),j(!1),a()};return e.jsx(oe,{open:s,onOpenChange:h=>!h&&_(),children:e.jsxs(re,{className:"sm:max-w-md",children:[e.jsxs(le,{children:[e.jsx(ie,{children:t("createAuthProfileDialog.title")}),e.jsx(de,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx($,{id:"profile-name",value:c,onChange:h=>o(h.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),c&&!n&&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(ee,{id:"share-context",checked:x,onCheckedChange:h=>i(h===!0)}),e.jsx(P,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),x&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(P,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx($,{id:"context-group",value:m,onChange:h=>g(h.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(ee,{id:"deeper-continuity",checked:p,onCheckedChange:h=>l(h===!0)}),e.jsx(P,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),m.trim().length>0&&!d&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:ne})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{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(Ge,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:C}),e.jsx(u,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:A,disabled:!n||x&&!d,children:N?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(W,{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(u,{variant:"ghost",onClick:_,children:t("createAuthProfileDialog.close")}),e.jsx(u,{onClick:A,disabled:!n||x&&!d,children:N?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function H({title:s,count:a,icon:t,tone:c}){const o={isolated:{border:"border-blue-300/60 bg-blue-50/40 dark:border-blue-900/40 dark:bg-blue-900/10",icon:"text-blue-700 dark:text-blue-400",count:"text-blue-700 dark:text-blue-400"},shared:{border:"border-emerald-300/60 bg-emerald-50/40 dark:border-emerald-900/40 dark:bg-emerald-900/10",icon:"text-emerald-700 dark:text-emerald-400",count:"text-emerald-700 dark:text-emerald-400"},deeper:{border:"border-indigo-300/60 bg-indigo-50/40 dark:border-indigo-900/40 dark:bg-indigo-900/10",icon:"text-indigo-700 dark:text-indigo-400",count:"text-indigo-700 dark:text-indigo-400"}};return e.jsxs("div",{className:y("rounded-md border p-2.5",o[c].border),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-semibold",children:s}),e.jsx(t,{className:y("h-3.5 w-3.5",o[c].icon)})]}),e.jsx("p",{className:y("mt-1 text-lg font-mono font-semibold",o[c].count),children:a})]})}function ce({isolatedCount:s,sharedStandardCount:a,deeperSharedCount:t,sharedGroups:c,legacyTargetCount:o,cliproxyCount:x}){const{t:i}=O(),[m,g]=f.useState(!1),p=c.length>0?c:["default"];return e.jsxs(S,{className:"border-dashed",children:[e.jsx(D,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-base",children:i("historySyncLearningMap.title")}),e.jsx(M,{className:"mt-1",children:i("historySyncLearningMap.description")})]}),e.jsx(F,{variant:"outline",children:i("historySyncLearningMap.learningMap")})]})}),e.jsxs(w,{className:"space-y-3",children:[x>0&&e.jsx("div",{className:"rounded-md border border-blue-300/60 bg-blue-50/40 px-3 py-2 text-xs text-blue-800 dark:border-blue-900/40 dark:bg-blue-900/10 dark:text-blue-300",children:i("historySyncLearningMap.cliproxyManaged",{count:x})}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto_1fr_auto_1fr] sm:items-center",children:[e.jsx(H,{title:i("historySyncLearningMap.isolated"),count:s,icon:Fe,tone:"isolated"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(H,{title:i("historySyncLearningMap.shared"),count:a,icon:Re,tone:"shared"}),e.jsx("div",{className:"hidden sm:flex justify-center text-muted-foreground",children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(H,{title:i("historySyncLearningMap.deeper"),count:t,icon:He,tone:"deeper"})]}),e.jsxs(ue,{open:m,onOpenChange:g,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-8 w-full justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",children:[e.jsx("span",{children:i("historySyncLearningMap.showDetails")}),e.jsx(he,{className:y("h-4 w-4 transition-transform",m&&"rotate-180")})]})}),e.jsxs(me,{className:"pt-2",children:[e.jsxs("div",{className:"grid gap-2 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:i("historySyncLearningMap.modeSwitch")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:i("historySyncLearningMap.modeSwitchDesc")})]}),e.jsxs("div",{className:"rounded-md border bg-muted/20 p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:i("historySyncLearningMap.historySyncGroup")})]}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:i("historySyncLearningMap.historySyncGroupDesc")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:p.map(l=>e.jsx(F,{variant:"outline",className:"font-mono text-[10px]",children:l},l))})]})]}),o>0&&e.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-300",children:i("historySyncLearningMap.legacyConfirmation",{count:o})})]})]})]})]})}function ht(){const{t:s}=O(),a=je(),{data:t,isLoading:c}=Ve(),o=Je(),[x,i]=f.useState(!1),[m,g]=f.useState(!1),p=t?.accounts||[],l=t?.cliproxyCount||0,N=t?.legacyContextCount||0,j=t?.legacyContinuityCount||0,n=t?.sharedCount||0,r=t?.sharedStandardCount||0,d=t?.deeperSharedCount||0,C=t?.isolatedCount||0,A=Array.from(new Set(p.filter(v=>v.context_mode==="shared").map(v=>v.context_group||"default"))).sort((v,fe)=>v.localeCompare(fe)),_=p.filter(v=>v.context_inferred||v.continuity_inferred),h=_.length,pe=h>0,E=()=>a("/cliproxy?provider=claude"),K=()=>a("/cliproxy?provider=claude&action=auth"),U=()=>o.mutate(_);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[calc(100vh-100px)] hidden 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(Ee,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.manageSuffix")]})]}),e.jsx(ve,{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:s("accountsPage.primaryActions")}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:()=>i(!0),children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{size:"sm",className:"w-full justify-start",onClick:K,children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),s("accountsPage.authClaudeInPool")]}),e.jsxs(u,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:E,children:[s("accountsPage.openClaudePoolSettings"),e.jsx(R,{className:"w-4 h-4 ml-auto"})]})]}),pe?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("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(Ke,{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:[N>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContextPending",{count:N})}),j>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:s("accountsPage.legacyContinuityPending",{count:j})})]})]}),e.jsx(u,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:U,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:s("accountsPage.noLegacyFollowup")}),e.jsx(ue,{open:m,onOpenChange:g,children:e.jsxs(S,{children:[e.jsx(D,{className:"pb-2",children:e.jsx(xe,{asChild:!0,children:e.jsxs(u,{variant:"ghost",className:"h-auto w-full justify-between px-0 py-0",children:[e.jsxs("div",{className:"text-left",children:[e.jsx(k,{className:"text-sm",children:s("accountsPage.continuityGuide")}),e.jsx(M,{className:"mt-1",children:s("accountsPage.expandWhenNeeded")})]}),e.jsx(he,{className:y("h-4 w-4 transition-transform",m&&"rotate-180")})]})})}),e.jsx(me,{children:e.jsxs(w,{className:"space-y-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedStandard")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.sharedStandardDesc")})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.sharedDeeper")}),e.jsxs("p",{className:"mt-1",children:[s("accountsPage.sharedDeeperPrefix")," ",e.jsx("code",{children:"session-env"}),","," ",e.jsx("code",{children:"file-history"}),", ",e.jsx("code",{children:"shell-snapshots"}),","," ",e.jsx("code",{children:"todos"}),"."]})]}),e.jsxs("div",{className:"rounded-md border p-2.5",children:[e.jsx("p",{className:"font-semibold text-foreground",children:s("accountsPage.isolated")}),e.jsx("p",{className:"mt-1",children:s("accountsPage.isolatedDesc")})]})]})})]})}),e.jsxs(S,{children:[e.jsxs(D,{className:"pb-2",children:[e.jsx(k,{className:"text-sm",children:s("accountsPage.quickCommands")}),e.jsx(M,{children:s("accountsPage.quickCommandsDesc")})]}),e.jsxs(w,{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(X,{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(X,{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(F,{variant:"outline",children:s("accountsPage.workspaceBadge")}),e.jsx(F,{variant:"secondary",children:s("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:s("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[s("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:s("accountsTable.sync")}),s("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(ce,{isolatedCount:C,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:A,legacyTargetCount:h,cliproxyCount:l}),e.jsxs(S,{className:"flex flex-col",children:[e.jsxs(D,{className:"pb-3",children:[e.jsx(k,{className:"text-lg",children:s("accountsPage.accountMatrix")}),e.jsx(M,{children:s("accountsPage.sharedTotalDesc",{count:n})})]}),e.jsx(w,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(S,{children:[e.jsxs(D,{children:[e.jsx(k,{className:"text-lg",children:s("accountsPage.title")}),e.jsxs(M,{children:[s("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),s("accountsPage.mobileManageSuffix")]})]}),e.jsxs(w,{className:"space-y-2",children:[e.jsxs(u,{className:"w-full",onClick:()=>i(!0),children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),s("accountsPage.createAccount")]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:E,children:[s("accountsPage.openCliProxyClaudePool"),e.jsx(R,{className:"w-4 h-4 ml-2"})]}),e.jsxs(u,{variant:"outline",className:"w-full",onClick:K,children:[s("accountsPage.authClaudeInPool"),e.jsx(J,{className:"w-4 h-4 ml-2"})]}),e.jsx(u,{variant:"outline",className:"w-full",onClick:U,disabled:o.isPending||h===0,children:o.isPending?s("accountsPage.confirmingLegacy"):s("accountsPage.confirmLegacy",{count:h})})]})]}),e.jsx(ce,{isolatedCount:C,sharedStandardCount:r,deeperSharedCount:d,sharedGroups:A,legacyTargetCount:h,cliproxyCount:l}),e.jsxs(S,{children:[e.jsx(D,{className:"pb-3",children:e.jsx(k,{className:"text-base",children:s("accountsPage.accountMatrix")})}),e.jsx(w,{children:c?e.jsx("div",{className:"text-muted-foreground",children:s("accountsPage.loadingAccounts")}):e.jsx(ae,{data:p,defaultAccount:t?.default??null})})]})]}),e.jsx(st,{open:x,onClose:()=>i(!1)})]})}export{ht 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-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as o,
|
|
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-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as o,bA as l}from"./index-ZlUC3TcJ.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};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as x,h as He}from"./react-vendor-CNOkPC89.js";import{B as R,c as _,T as Qe,p as $e,q as ze,r as Ke,s as Je,t as Be,v as qe,w as xe,d as j,I as M,a as q,n as ne,L as T,x as B,y as we,z as Ye,A as Ve,D as We,E as Ge,S as ue,F as se,G as le,H as Ce,J as Xe,K as Ze,M as ye,N as ke,O as Pe,Q as es,R as ss,U as he,V as pe,W as te,X as ts,Y as as,Z as de,C as Oe,b as Se,j as rs,k as ns,_ as is,$ as ls,a0 as os,a1 as cs,a2 as ds,a3 as ms,a4 as xs,a5 as us,a6 as hs,a7 as ps}from"./index-ZlUC3TcJ.js";import{a as fs,u as gs,b as fe}from"./tanstack-B8i0evp-.js";import{C as oe}from"./confirm-dialog-Bz3IbucG.js";import{t as P}from"./notifications-B2HqRBj7.js";import{L as ae,R as X,ai as Te,aj as js,E as Ns,f as vs,a3 as re,O as bs,ak as Ee,a4 as me,C as Ae,al as ws,a2 as Cs,am as ys,o as ce,X as ks,Z as _e,an as ge,m as je,ao as Re,ap as Ps,a6 as Os,aq as Ss,x as Me,ar as Ts,v as De,n as Es,as as As}from"./icons-DR-ORtNe.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-7NHGF_Xe.js";function _s({className:s,showTooltip:t=!0}){const n=e.jsxs(R,{variant:"outline",className:_("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 t?e.jsxs(Qe,{children:[e.jsx($e,{asChild:!0,children:n}),e.jsx(ze,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Ne(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function Le(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Rs(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 Ms(s,t){const n={...s};return t.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=t.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,t.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=t.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,t.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=t.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ds({profileName:s,target:t,data:n,settings:d,isLoading:l,isSaving:f,isTargetSaving:r,hasChanges:g,isRawJsonValid:a,onTargetChange:p,onRefresh:u,onDelete:v,onSave:b}){const k=f||r,N=l||k;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}),n?.path&&e.jsx(R,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),Le(d)&&e.jsx(_s,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.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(Ke,{value:t,onValueChange:O=>{N||p(O)},disabled:N,children:[e.jsx(Je,{className:"h-7 w-[170px] text-xs",disabled:N,children:e.jsx(Be,{})}),e.jsxs(qe,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"})]})]}),r&&e.jsx(ae,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"ghost",size:"sm",onClick:u,disabled:N,children:e.jsx(X,{className:`w-4 h-4 ${l?"animate-spin":""}`})}),v&&e.jsx(j,{variant:"ghost",size:"sm",onClick:v,disabled:k,children:e.jsx(Te,{className:"w-4 h-4 text-destructive"})}),e.jsx(j,{size:"sm",onClick:b,disabled:k||!g||!a,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(js,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Ie({label:s,...t}){const[n,d]=x.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(M,{type:n?"text":"password",className:"pr-10 font-mono",...t}),e.jsx(j,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>d(!n),tabIndex:-1,children:n?e.jsx(Ns,{className:"w-4 h-4"}):e.jsx(vs,{className:"w-4 h-4"})})]})]})}function Ls({currentSettings:s,newEnvKey:t,newEnvValue:n,onNewEnvKeyChange:d,onNewEnvValueChange:l,onEnvValueChange:f,onAddEnvVar:r}){const{t:g}=q();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(([a,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(T,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[a,Ne(a)&&e.jsx(R,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:g("envEditor.sensitive")})]}),Ne(a)?e.jsx(Ie,{value:p,onChange:u=>f(a,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(M,{value:p,onChange:u=>f(a,u.target.value),className:"font-mono text-sm h-8"})]},a))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:g("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:g("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:g("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:g("envEditor.keyPlaceholder"),value:t,onChange:a=>d(a.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(M,{placeholder:g("envEditor.valuePlaceholder"),value:n,onChange:a=>l(a.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:a=>a.key==="Enter"&&t.trim()&&r()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:r,disabled:!t.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]})}function Is({profileName:s,target:t,data:n}){const{t:d}=q(),l=t==="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(bs,{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:n&&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:n.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:n.path}),e.jsx(B,{value:n.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(n.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:t})]})]})})]}),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(T,{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(B,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"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(B,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:d(l?"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 ",l?"claude":"droid",' "prompt"']}),e.jsx(B,{value:`ccs ${s} --target ${l?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(T,{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(B,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Fs({value:s,onChange:t,placeholder:n="Search models...",className:d}){const[l,f]=x.useState(""),[r,g]=x.useState(null),{models:a,isLoading:p,isError:u,isFetching:v}=we(),b=Ye(),k=x.useMemo(()=>Ve(a,l,{category:r??void 0}),[a,l,r]),N=x.useMemo(()=>We(a,2),[a]),O=!l.trim()&&!r,F=x.useMemo(()=>{const c={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(h=>{c[h.category].push(h)});for(const h of Object.keys(c))c[h]=Ge(c[h]);return c},[k]),w=x.useCallback(()=>{b()},[b]),E=a.find(c=>c.id===s);return p&&a.length===0?e.jsxs("div",{className:_("space-y-2",d),children:[e.jsx(ue,{className:"h-10 w-full"}),e.jsx(ue,{className:"h-32 w-full"})]}):e.jsxs("div",{className:_("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(Ee,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(M,{value:l,onChange:c=>f(c.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(j,{variant:"outline",size:"icon",onClick:w,disabled:v,title:"Refresh models",children:v?e.jsx(ae,{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(R,{variant:r===null?"default":"outline",className:"cursor-pointer",onClick:()=>g(null),children:["All (",a.length,")"]}),Object.keys(se).map(c=>{const h=F[c].length;return h===0?null:e.jsxs(R,{variant:r===c?"default":"outline",className:"cursor-pointer",onClick:()=>g(c),children:[se[c]," (",h,")"]},c)})]}),E&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:E.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[le(E.pricing)," |"," ",Ce(E.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:u?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(j,{variant:"link",onClick:w,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',l,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[O&&N.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(me,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:N.map(c=>e.jsx(ve,{model:c,isSelected:c.id===s,onClick:()=>t(c.id),showAge:!0},c.id))})]}),Object.keys(se).map(c=>{const h=F[c];return h.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:se[c]}),e.jsx("div",{className:"space-y-1",children:h.map(i=>e.jsx(ve,{model:i,isSelected:i.id===s,onClick:()=>t(i.id)},i.id))})]},c)})]})})]})}function ve({model:s,isSelected:t,onClick:n,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:n,className:_("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",t&&"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:_("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",t?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[d&&s.created&&e.jsx(R,{variant:"outline",className:_("text-[10px] px-1",t?"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:Xe(s.created)}),s.isFree?e.jsx(R,{variant:"secondary",className:_("text-[10px] px-1",t?"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(R,{variant:"outline",className:_("text-[10px] px-1 border-emerald-500/50 text-emerald-600",t?"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:le(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:le(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Ce(s.context_length)})]})]})}function Us({selectedModel:s,value:t,onChange:n,className:d}){const{t:l}=q(),{models:f}=we(),r=x.useMemo(()=>s?Ze(s,f):{},[s,f]),g=()=>{n(r)},a=(u,v)=>{n({...t,[u]:v||void 0})},p=s&&Object.keys(r).length>0;return e.jsxs(ye,{className:_("group",d),children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ae,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),l("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",l("modelTierMapping.advanced"),")"]})]}),e.jsxs(Pe,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:l("modelTierMapping.description")}),p&&e.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(ws,{className:"mr-1 h-4 w-4"}),l("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(T,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(M,{id:"tier-opus",value:t.opus??"",onChange:u=>a("opus",u.target.value),placeholder:l("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(M,{id:"tier-sonnet",value:t.sonnet??"",onChange:u=>a("sonnet",u.target.value),placeholder:l("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(T,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(M,{id:"tier-haiku",value:t.haiku??"",onChange:u=>a("haiku",u.target.value),placeholder:l("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:l("modelTierMapping.footer")})]})]})}function Hs({profileName:s,target:t,data:n,currentSettings:d,newEnvKey:l,newEnvValue:f,onNewEnvKeyChange:r,onNewEnvValueChange:g,onEnvValueChange:a,onAddEnvVar:p,onEnvBulkChange:u}){const v=Le(d),b=d?.env,k=x.useMemo(()=>Rs(b??{}),[b]),N=b??{},O=i=>{if(u){const U={...N,ANTHROPIC_MODEL:i,ANTHROPIC_DEFAULT_OPUS_MODEL:i,ANTHROPIC_DEFAULT_SONNET_MODEL:i,ANTHROPIC_DEFAULT_HAIKU_MODEL:i};u(U)}else a("ANTHROPIC_MODEL",i),a("ANTHROPIC_DEFAULT_OPUS_MODEL",i),a("ANTHROPIC_DEFAULT_SONNET_MODEL",i),a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i);P.success(te.t("commonToast.appliedModelAllTiers"),{duration:2e3})},F=i=>{if(u){const U=Ms(N,i);u(U)}else i.opus!==void 0&&a("ANTHROPIC_DEFAULT_OPUS_MODEL",i.opus||""),i.sonnet!==void 0&&a("ANTHROPIC_DEFAULT_SONNET_MODEL",i.sonnet||""),i.haiku!==void 0&&a("ANTHROPIC_DEFAULT_HAIKU_MODEL",i.haiku||"")},[w,E]=x.useState(!1),c=new Set(["ANTHROPIC_AUTH_TOKEN"]),h=Object.entries(N).filter(([i])=>!c.has(i));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(es,{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(ss,{className:"w-full",children:[e.jsx(he,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(he,{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(pe,{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(T,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Fs,{value:N.ANTHROPIC_MODEL,onChange:O,placeholder:"Search OpenRouter models..."})]}),e.jsx(Us,{selectedModel:N.ANTHROPIC_MODEL,value:k,onChange:F}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Ie,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:i=>a("ANTHROPIC_AUTH_TOKEN",i.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),h.length>0&&e.jsxs(ye,{open:w,onOpenChange:E,children:[e.jsxs(ke,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ae,{className:_("h-4 w-4 transition-transform",w&&"rotate-90")}),e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",h.length,")"]})]}),e.jsx(Pe,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:h.map(([i,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:i}),e.jsx(M,{value:U,onChange:Q=>a(i,Q.target.value),className:"font-mono text-xs h-8"})]},i))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(T,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(M,{placeholder:"VARIABLE_NAME",value:l,onChange:i=>r(i.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(M,{placeholder:"value",value:f,onChange:i=>g(i.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:i=>i.key==="Enter"&&l.trim()&&p()}),e.jsx(j,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!l.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]}):e.jsx(Ls,{currentSettings:d,newEnvKey:l,newEnvValue:f,onNewEnvKeyChange:r,onNewEnvValueChange:g,onEnvValueChange:a,onAddEnvVar:p})}),e.jsx(pe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Is,{profileName:s,target:t,data:n})})]})]})})}function Qs({profileName:s,profileTarget:t,onDelete:n,onHasChangesUpdate:d}){const[l,f]=x.useState({}),[r,g]=x.useState(!1),[a,p]=x.useState(null),[u,v]=x.useState(""),[b,k]=x.useState(""),N=fs(),{data:O,isLoading:F,isError:w,refetch:E}=gs({queryKey:["settings",s],queryFn:async()=>{const m=await fetch(`/api/settings/${s}/raw`);if(!m.ok)throw new Error(`Failed to load settings: ${m.status}`);return m.json()}}),c=O?.settings,h=x.useMemo(()=>{if(a!==null)try{return JSON.parse(a)}catch{}if(c)return{...c,env:{...c.env,...l}}},[c,l,a]),i=x.useMemo(()=>a!==null?a:c?JSON.stringify(c,null,2):"",[a,c]),U=x.useCallback(m=>{p(m)},[]),Q=(m,y)=>{const D={...h?.env||{},[m]:y};f($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2))},Y=m=>{const y={...h?.env||{},...m};f(D=>({...D,...m})),p(JSON.stringify({...h,env:y},null,2))},J=()=>{if(!u.trim())return;const m=u.trim(),y=b,D={...h?.env||{},[m]:y};f($=>({...$,[m]:y})),p(JSON.stringify({...h,env:D},null,2)),v(""),k("")},V=x.useMemo(()=>{try{return JSON.parse(i),!0}catch{return!1}},[i]),S=x.useMemo(()=>a!==null?a!==JSON.stringify(c,null,2):Object.keys(l).length>0,[a,l,c]),Z=x.useMemo(()=>{const m=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],y=h?.env||{};return m.filter(D=>!y[D]?.trim())},[h]);x.useEffect(()=>{d?.(S)},[S,d]);const C=fe({mutationFn:async()=>{let m;try{m=JSON.parse(i)}catch{m={...O?.settings,env:{...O?.settings?.env,...l}}}const y=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:m,expectedMtime:O?.mtime})});if(y.status===409)throw new Error("CONFLICT");if(!y.ok)throw new Error("Failed to save");return y.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),f({}),p(null),P.success(te.t("commonToast.settingsSaved"))},onError:m=>{m.message==="CONFLICT"?g(!0):P.error(m.message)}}),H=fe({mutationFn:async m=>(await as.profiles.update(s,{target:m}),m),onSuccess:()=>{N.invalidateQueries({queryKey:["profiles"]}),P.success(te.t("commonToast.defaultTargetUpdated"))},onError:(m,y)=>{const D=y==="droid"?"Factory Droid":"Claude Code",$=m.message.trim()?`: ${m.message}`:"";P.error(te.t("commonToast.failedUpdateDefaultTarget",{target:D,suffix:$}))}}),W=t||"claude",G=C.isPending||H.isPending,ee=async m=>{g(!1),m?(await E(),C.mutate()):(f({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ds,{profileName:s,target:W,data:O,settings:h,isLoading:F,isSaving:C.isPending,isTargetSaving:H.isPending,hasChanges:S,isRawJsonValid:V,onTargetChange:m=>{G||m!==W&&H.mutate(m)},onRefresh:()=>{G||E()},onDelete:n,onSave:()=>{G||C.mutate()}}),F?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ae,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):w?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(j,{variant:"outline",size:"sm",onClick:()=>E(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5 min-w-0",children:e.jsx(Hs,{profileName:s,target:W,data:O,currentSettings:h,newEnvKey:u,newEnvValue:b,onNewEnvKeyChange:v,onNewEnvValueChange:k,onEnvValueChange:Q,onEnvBulkChange:Y,onAddEnvVar:J})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(ys,{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(ts,{rawJsonContent:i,isRawJsonValid:V,rawJsonEdits:a,settings:c,onChange:U,missingRequiredFields:Z})]})]}),e.jsx(oe,{open:r,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ee(!0),onCancel:()=>ee(!1)})]},s)}const be="ccs:openrouter-banner-dismissed";function $s({onCreateClick:s}){const[t,n]=x.useState(!0),{modelCount:d,isLoading:l}=de();x.useEffect(()=>{const r=localStorage.getItem(be)==="true";n(r)},[]);const f=()=>{localStorage.setItem(be,"true"),n(!0)};return t?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(me,{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 ",l?"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(j,{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(ce,{className:"w-3 h-3"})]}),e.jsxs(j,{size:"icon",variant:"ghost",onClick:f,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ie({badge:s,badgeClassName:t,className:n,title:d,description:l,visual:f,highlights:r,actionLabel:g,actionClassName:a,onAction:p,footer:u}){return e.jsxs(Oe,{className:_("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(rs,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[f,e.jsx(R,{variant:"secondary",className:t,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ns,{className:"text-base",children:d}),e.jsx(is,{className:"text-sm leading-6",children:l})]})]}),e.jsxs(Se,{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:r.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(j,{onClick:p,className:a,children:[g,e.jsx(Ps,{className:"ml-2 h-4 w-4"})]}),u?e.jsx("div",{className:"text-xs text-muted-foreground",children:u}):null]})]})}function zs({hasProfiles:s,profileCount:t,onOpenRouterClick:n,onAlibabaCodingPlanClick:d,onCliproxyClick:l,onCustomClick:f}){const{t:r}=q(),{modelCount:g,isLoading:a}=de(),p=a?"300+":`${g}+`,u=s?r("openrouterQuickStart.profileCount",{count:t}):r("openrouterQuickStart.recommended"),v=r(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),b=s?r("openrouterQuickStart.summaryDescriptionWithProfiles",{count:t}):r("openrouterQuickStart.summaryDescriptionNoProfiles");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-4",children:[e.jsx(Oe,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Se,{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(R,{variant:"secondary",children:u}),e.jsx(R,{variant:"outline",children:r("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:v}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:b})]})]}),e.jsx(j,{variant:"outline",onClick:f,className:"shrink-0",children:r("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ie,{badge:r("openrouterQuickStart.recommended"),title:r("openrouterQuickStart.title"),description:r("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(_e,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureOneApi")},{icon:e.jsx(me,{className:"h-3.5 w-3.5 text-accent"}),label:r("openrouterQuickStart.featureTierMapping")}],actionLabel:r("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[r("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(ce,{className:"h-3 w-3"})]})]})}),e.jsx(ie,{badge:r("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:r("openrouterQuickStart.runtimeProviderTitle"),description:r("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(ge,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(ge,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-emerald-600"}),label:r("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:r("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:l,footer:e.jsx("span",{children:r("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ie,{badge:r("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:r("alibabaCodingPlanQuickStart.title"),description:r("alibabaCodingPlanQuickStart.description"),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(Re,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(je,{className:"h-3.5 w-3.5 text-orange-600"}),label:r("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:r("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:d,footer:e.jsxs(e.Fragment,{children:[r("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(ce,{className:"h-3 w-3"})]})]})})]})]})})}function Ks({onCreateClick:s}){const{modelCount:t,isLoading:n}=de();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:[n?"300+":`${t}+`," models available"]})]}),e.jsxs(j,{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(_e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Js({onCreateClick:s}){const{t}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:t("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(j,{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(Re,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:t("alibabaCodingPlanPromo.add")})]})]})})}function rt(){const{t:s}=q(),t=He(),{data:n,isLoading:d,isError:l,refetch:f}=ls(),r=os(),g=cs(),a=ds(),p=ms(),u=xs(),v=us(),[b,k]=x.useState(null),[N,O]=x.useState(""),[F,w]=x.useState(!1),[E,c]=x.useState("normal"),[h,i]=x.useState(null),[U,Q]=x.useState(!1),[Y,J]=x.useState(null),V=x.useRef(null);hs();const S=x.useMemo(()=>n?.profiles||[],[n?.profiles]),Z=x.useMemo(()=>S.filter(o=>o.name.toLowerCase().includes(N.toLowerCase())),[S,N]),C=b?S.find(o=>o.name===b):null,H=o=>{U&&b!==o?J(o):k(o)},W=o=>{r.mutate(o,{onSuccess:()=>{b===o&&(k(null),Q(!1),J(null)),i(null)}})},G=o=>{w(!1),H(o)},ee=o=>{H(o)},m=(o,L)=>{const A=JSON.stringify(L,null,2)+`
|
|
2
|
+
`,z=new Blob([A],{type:"application/json"}),I=URL.createObjectURL(z),K=document.createElement("a");K.href=I,K.download=o,document.body.appendChild(K),K.click(),K.remove(),URL.revokeObjectURL(I)},y=async()=>{try{const o=await g.mutateAsync();if(o.orphans.length===0){P.success("No orphan profile settings found");return}const L=o.orphans.filter(K=>K.validation.valid).length;if(!window.confirm(`Found ${o.orphans.length} orphan settings file(s). Register ${L} valid profile(s) now?`))return;const z=await a.mutateAsync({}),I=z.skipped.length>0?`, skipped ${z.skipped.length}`:"";P.success(`Registered ${z.registered.length} profile(s)${I}`)}catch(o){P.error(o.message)}},D=async()=>{if(!C)return;const o=window.prompt(`Copy profile "${C.name}" to new profile name:`,`${C.name}-copy`);if(!o)return;const L=o.trim();if(!L){P.error("Destination profile name cannot be empty");return}try{const A=await p.mutateAsync({name:C.name,data:{destination:L}});H(L),A.warnings&&A.warnings.length>0&&P.info(A.warnings.join(`
|
|
3
|
+
`))}catch(A){P.error(A.message)}},$=async()=>{if(C)try{const o=await u.mutateAsync({name:C.name});m(`${C.name}.ccs-profile.json`,o.bundle),o.redacted?P.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):P.success("Profile export downloaded")}catch(o){P.error(o.message)}},Fe=()=>{V.current?.click()},Ue=async o=>{const L=o.target.files?.[0];if(o.target.value="",!!L)try{const A=await L.text(),z=JSON.parse(A),I=await v.mutateAsync({bundle:z});I.name&&H(I.name),I.warnings&&I.warnings.length>0&&P.info(I.warnings.join(`
|
|
4
|
+
`))}catch(A){P.error(A.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx($s,{onCreateClick:()=>w(!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:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j,{size:"sm",variant:"outline",onClick:()=>void y(),disabled:g.isPending||a.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${g.isPending?"animate-spin":""}`})}),e.jsx(j,{size:"sm",variant:"outline",onClick:Fe,disabled:v.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Ss,{className:"w-4 h-4"})}),e.jsxs(j,{size:"sm",onClick:()=>{w(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ee,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(M,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:N,onChange:o=>O(o.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")}):l?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Me,{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(j,{size:"sm",variant:"outline",onClick:()=>f(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):Z.length===0?e.jsx("div",{className:"p-4 text-center",children:S.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ts,{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(j,{size:"sm",variant:"outline",onClick:()=>{w(!0)},children:[e.jsx(re,{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:N})})}):e.jsx("div",{className:"p-2 space-y-1",children:Z.map(o=>e.jsx(Bs,{profile:o,isSelected:b===o.name,onSelect:()=>ee(o.name),onDelete:()=>i(o.name)},o.name))})}),S.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:S.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(De,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:S.filter(o=>o.configured).length})]})]})}),e.jsx(Ks,{onCreateClick:()=>{c("openrouter"),w(!0)}}),e.jsx(Js,{onCreateClick:()=>{c("alibaba-coding-plan"),w(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:C?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(j,{size:"sm",variant:"outline",onClick:()=>void D(),disabled:p.isPending,children:[e.jsx(Es,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>void $(),disabled:u.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(Qs,{profileName:C.name,profileTarget:C.target,onDelete:()=>i(C.name),onHasChangesUpdate:Q},C.name)]}):e.jsx(zs,{hasProfiles:S.length>0,profileCount:S.length,onCliproxyClick:()=>{t("/cliproxy/ai-providers")},onOpenRouterClick:()=>{c("openrouter"),w(!0)},onAlibabaCodingPlanClick:()=>{c("alibaba-coding-plan"),w(!0)},onCustomClick:()=>{c("normal"),w(!0)}})})]}),e.jsx("input",{ref:V,type:"file",accept:".json,application/json",className:"hidden",onChange:o=>void Ue(o)}),e.jsx(ps,{open:F,onOpenChange:w,onSuccess:G,initialMode:E}),e.jsx(oe,{open:!!h,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:h??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>h&&W(h),onCancel:()=>i(null)}),e.jsx(oe,{open:!!Y,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:b??"",next:Y??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{Q(!1),k(Y),J(null)},onCancel:()=>J(null)})]})}function Bs({profile:s,isSelected:t,onSelect:n,onDelete:d}){return e.jsxs("div",{className:_("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(De,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Me,{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(R,{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(B,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(j,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),d()},children:e.jsx(Te,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{rt as ApiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bj as W,b3 as X,b5 as Y,n as Z,I as C,d as c}from"./index-ZlUC3TcJ.js";import{R as E,x as _,v as ee,m as se,E as K,f as T,l as R,n as z,aE as te,a4 as ae,I as ne,aj as re}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.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),[I,b]=n.useState(!1),[$,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 F=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 Q=await A.json();throw new Error(Q.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 G=d??a.apiKey.value,H=u??a.managementSecret.value,M=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:G,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:I?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:H,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:$?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:F,disabled:!M||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-Dt3edmE5.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,
|
|
1
|
+
import{j as e}from"./radix-ui-Dt3edmE5.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bj as E,n as k,S as n,C as g,b3 as R,b5 as D,B as T,d as C}from"./index-ZlUC3TcJ.js";import{A as O,a as _,b as I,c as F,d as P,e as z,f as L,g as U}from"./alert-dialog-7NHGF_Xe.js";import{x as $,v as H,a7 as v,u as M,I as Y,R as J}from"./icons-DR-ORtNe.js";import"./tanstack-B8i0evp-.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q=3e3,G=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),G);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(I,{children:[e.jsx(F,{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,$ as i,a0 as t}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-
|
|
1
|
+
import{j as r,$ as i,a0 as t}from"./radix-ui-Dt3edmE5.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-ZlUC3TcJ.js";import{l as o}from"./icons-DR-ORtNe.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};
|