@rubytech/create-maxy-code 0.1.506 → 0.1.507
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/package.json +2 -2
- package/payload/platform/config/brand.json +79 -18
- package/payload/platform/lib/account-schema-regions/dist/index.d.ts +17 -5
- package/payload/platform/lib/account-schema-regions/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/account-schema-regions/dist/index.js +20 -6
- package/payload/platform/lib/account-schema-regions/dist/index.js.map +1 -1
- package/payload/platform/lib/account-schema-regions/src/index.ts +20 -6
- package/payload/platform/plugins/admin/PLUGIN.md +36 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +48 -2
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +7 -0
- package/payload/platform/plugins/aeo/PLUGIN.md +3 -0
- package/payload/platform/plugins/browser/PLUGIN.md +18 -0
- package/payload/platform/plugins/connector/PLUGIN.md +4 -0
- package/payload/platform/plugins/contacts/PLUGIN.md +9 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +21 -1
- package/payload/platform/plugins/docs/references/plugins-guide.md +26 -0
- package/payload/platform/plugins/email/PLUGIN.md +17 -0
- package/payload/platform/plugins/filesystem/PLUGIN.md +6 -0
- package/payload/platform/plugins/google/PLUGIN.md +12 -0
- package/payload/platform/plugins/graph/PLUGIN.md +3 -0
- package/payload/platform/plugins/graph-viewer/PLUGIN.md +1 -0
- package/payload/platform/plugins/ledger/PLUGIN.md +7 -0
- package/payload/platform/plugins/memory/PLUGIN.md +41 -0
- package/payload/platform/plugins/outlook/PLUGIN.md +24 -0
- package/payload/platform/plugins/quickbooks/PLUGIN.md +15 -0
- package/payload/platform/plugins/replicate/PLUGIN.md +3 -0
- package/payload/platform/plugins/scheduling/PLUGIN.md +10 -0
- package/payload/platform/plugins/storage-broker/PLUGIN.md +12 -0
- package/payload/platform/plugins/telegram/PLUGIN.md +3 -0
- package/payload/platform/plugins/url-get/PLUGIN.md +1 -0
- package/payload/platform/plugins/voice-mirror/PLUGIN.md +5 -0
- package/payload/platform/plugins/whatsapp/PLUGIN.md +12 -0
- package/payload/platform/plugins/work/PLUGIN.md +15 -0
- package/payload/platform/plugins/workflows/PLUGIN.md +8 -0
- package/payload/platform/scripts/check-risk-class.mjs +145 -0
- package/payload/platform/scripts/lib/__pycache__/account-schema-owned-dirs.cpython-314.pyc +0 -0
- package/payload/platform/scripts/lib/provision-account-dir.sh +4 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +4 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/index.js +8 -0
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/tool-surface.d.ts +13 -0
- package/payload/platform/services/claude-session-manager/dist/tool-surface.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/tool-surface.js +33 -8
- package/payload/platform/services/claude-session-manager/dist/tool-surface.js.map +1 -1
- package/payload/server/{chunk-5ADBNEJA.js → chunk-2WAXM5N2.js} +111 -111
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-D5KOQA8S.js → AdminLoginScreens-YT7jsh_H.js} +1 -1
- package/payload/server/public/assets/{AdminShell-C8wazpnz.js → AdminShell-Ckht9hmU.js} +1 -1
- package/payload/server/public/assets/{activity-CFqkDhTs.js → activity-DH3Wgc3O.js} +1 -1
- package/payload/server/public/assets/admin-DetvulAu.js +1 -0
- package/payload/server/public/assets/{agents-DPulfmrd.js → agents-X_IvDHLZ.js} +1 -1
- package/payload/server/public/assets/{browser-T_5xbnJh.js → browser-Bym8QhfA.js} +1 -1
- package/payload/server/public/assets/{calendar-CKjuiG8c.js → calendar-CFnufJOy.js} +1 -1
- package/payload/server/public/assets/chat-wrckyIpw.js +1 -0
- package/payload/server/public/assets/chevron-left-Dtk3jEK5.js +1 -0
- package/payload/server/public/assets/chevron-right-Dih6IZ8B.js +1 -0
- package/payload/server/public/assets/clock-iJCrrmWM.js +1 -0
- package/payload/server/public/assets/data-D76--TYs.js +1 -0
- package/payload/server/public/assets/{file-text-c6cA4Evd.js → file-text-zch0E1GJ.js} +1 -1
- package/payload/server/public/assets/{graph-DIk-o45J.js → graph-BavHLzpV.js} +1 -1
- package/payload/server/public/assets/{graph-labels-5bjxhC_p.js → graph-labels-CBwh4g-6.js} +1 -1
- package/payload/server/public/assets/{maximize-2-BCQkFb1_.js → maximize-2-bTn_Ozpi.js} +1 -1
- package/payload/server/public/assets/{operator-0UnNo2ms.js → operator-a4IOwf62.js} +1 -1
- package/payload/server/public/assets/page-3T2mE63b.js +1 -0
- package/payload/server/public/assets/{page-HVtUfub2.js → page-D6M1CmPe.js} +4 -4
- package/payload/server/public/assets/{public-CKEYyIPn.js → public-B3y_YU1G.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-dTpO5dhL.js → rotate-ccw-BGvzNB1b.js} +1 -1
- package/payload/server/public/assets/{routines-C6P1-Dto.js → routines-C7Dr16am.js} +1 -1
- package/payload/server/public/assets/{skills-ClrpVqlz.js → skills-DFeb3XO3.js} +1 -1
- package/payload/server/public/assets/{tasks-C8SNhSFC.js → tasks-CSfnCKJe.js} +1 -1
- package/payload/server/public/assets/{time-entry-format-CCO6N6XZ.js → time-entry-format-BgZqOOqG.js} +1 -1
- package/payload/server/public/assets/{triangle-alert-CHjdKpag.js → triangle-alert-DBJ7xz_t.js} +1 -1
- package/payload/server/public/assets/{useCopyFeedback-BTUu3-l8.js → useCopyFeedback-BFOujMl-.js} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-BkQ5tA8A.css +1 -0
- package/payload/server/public/assets/{useVoiceRecorder-BeNqxmm2.js → useVoiceRecorder-BP6CpYQD.js} +1 -1
- package/payload/server/public/assets/{wrench-CeNnc7oO.js → wrench-DdaRhfzS.js} +1 -1
- package/payload/server/public/brand/fonts/inter-400.woff2 +0 -0
- package/payload/server/public/brand/fonts/inter-500.woff2 +0 -0
- package/payload/server/public/brand-defaults.css +47 -4
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +7 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +702 -586
- package/payload/server/public/assets/admin-B-EGUWS4.js +0 -1
- package/payload/server/public/assets/chat-DWLYAA70.js +0 -1
- package/payload/server/public/assets/chevron-left-DBMCTKlT.js +0 -1
- package/payload/server/public/assets/chevron-right-SBAr6zzc.js +0 -1
- package/payload/server/public/assets/clock-kkzt7Scf.js +0 -1
- package/payload/server/public/assets/data-CV8N9qcy.js +0 -1
- package/payload/server/public/assets/page-JJa2xdzf.js +0 -1
- package/payload/server/public/assets/useSubAccountSwitcher-DyrH8DA8.css +0 -1
- /package/payload/server/public/assets/{useSubAccountSwitcher-DSW9vDi2.js → useSubAccountSwitcher-0PfRrN6i.js} +0 -0
|
@@ -3047,6 +3047,101 @@ function getDefaultAccountId() {
|
|
|
3047
3047
|
return resolveAccount()?.accountId ?? null;
|
|
3048
3048
|
}
|
|
3049
3049
|
|
|
3050
|
+
// ../lib/require-port-env/src/index.ts
|
|
3051
|
+
var MissingPortEnvError = class extends Error {
|
|
3052
|
+
envName;
|
|
3053
|
+
tag;
|
|
3054
|
+
failLine;
|
|
3055
|
+
constructor(envName, tag, failLine, message) {
|
|
3056
|
+
super(message);
|
|
3057
|
+
this.name = "MissingPortEnvError";
|
|
3058
|
+
this.envName = envName;
|
|
3059
|
+
this.tag = tag;
|
|
3060
|
+
this.failLine = failLine;
|
|
3061
|
+
}
|
|
3062
|
+
};
|
|
3063
|
+
var VALID_PORT_MIN = 1;
|
|
3064
|
+
var VALID_PORT_MAX = 65535;
|
|
3065
|
+
function requirePortEnv(envName, options = {}) {
|
|
3066
|
+
const tag = options.tag ?? "port-env";
|
|
3067
|
+
const failLine = options.failLine ?? "missing-port-env";
|
|
3068
|
+
const raw2 = process.env[envName];
|
|
3069
|
+
if (raw2 === void 0 || raw2 === "") {
|
|
3070
|
+
const msg = `[${tag}] ${failLine} reason=missing-env env=${envName}`;
|
|
3071
|
+
throw new MissingPortEnvError(envName, tag, failLine, msg);
|
|
3072
|
+
}
|
|
3073
|
+
const parsed = Number.parseInt(raw2, 10);
|
|
3074
|
+
if (!Number.isInteger(parsed) || parsed < VALID_PORT_MIN || parsed > VALID_PORT_MAX || String(parsed) !== raw2.trim()) {
|
|
3075
|
+
const msg = `[${tag}] ${failLine} reason=invalid-port-env env=${envName} value=${JSON.stringify(raw2)}`;
|
|
3076
|
+
throw new MissingPortEnvError(envName, tag, failLine, msg);
|
|
3077
|
+
}
|
|
3078
|
+
return parsed;
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
// app/lib/claude-agent/session-store.ts
|
|
3082
|
+
import { createHash } from "crypto";
|
|
3083
|
+
var SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3084
|
+
var sessionStore = /* @__PURE__ */ new Map();
|
|
3085
|
+
function fingerprintSessionKey(raw2) {
|
|
3086
|
+
if (typeof raw2 !== "string" || !raw2) return raw2;
|
|
3087
|
+
if (/^sk_[a-f0-9]{16}$/.test(raw2)) return raw2;
|
|
3088
|
+
if (!raw2.startsWith("v1.")) return raw2;
|
|
3089
|
+
return `sk_${createHash("sha256").update(raw2).digest("hex").slice(0, 16)}`;
|
|
3090
|
+
}
|
|
3091
|
+
function registerSession(cacheKey2, agentType, accountId, _unused, userId, userName, role) {
|
|
3092
|
+
const existing = sessionStore.get(cacheKey2);
|
|
3093
|
+
if (existing) {
|
|
3094
|
+
existing.agentType = agentType;
|
|
3095
|
+
existing.accountId = accountId;
|
|
3096
|
+
existing.userId = userId ?? existing.userId;
|
|
3097
|
+
existing.userName = userName ?? existing.userName;
|
|
3098
|
+
existing.role = role ?? existing.role;
|
|
3099
|
+
return;
|
|
3100
|
+
}
|
|
3101
|
+
sessionStore.set(cacheKey2, { agentType, createdAt: Date.now(), accountId, userId, userName, role });
|
|
3102
|
+
}
|
|
3103
|
+
function validateSession(cacheKey2, agentType, _signedSessionToken) {
|
|
3104
|
+
const session = sessionStore.get(cacheKey2);
|
|
3105
|
+
if (!session) return { ok: false, reason: "session-not-registered" };
|
|
3106
|
+
if (session.agentType !== agentType) return { ok: false, reason: "agent-type-mismatch" };
|
|
3107
|
+
if (Date.now() - session.createdAt > SESSION_TTL_MS) {
|
|
3108
|
+
sessionStore.delete(cacheKey2);
|
|
3109
|
+
return { ok: false, reason: "session-expired-age" };
|
|
3110
|
+
}
|
|
3111
|
+
return { ok: true };
|
|
3112
|
+
}
|
|
3113
|
+
function getAccountIdForSession(cacheKey2) {
|
|
3114
|
+
return sessionStore.get(cacheKey2)?.accountId;
|
|
3115
|
+
}
|
|
3116
|
+
function getUserIdForSession(cacheKey2) {
|
|
3117
|
+
return sessionStore.get(cacheKey2)?.userId;
|
|
3118
|
+
}
|
|
3119
|
+
function getUserNameForSession(cacheKey2) {
|
|
3120
|
+
return sessionStore.get(cacheKey2)?.userName;
|
|
3121
|
+
}
|
|
3122
|
+
function getRoleForSession(cacheKey2) {
|
|
3123
|
+
return sessionStore.get(cacheKey2)?.role;
|
|
3124
|
+
}
|
|
3125
|
+
function getSessionIdForSession(cacheKey2) {
|
|
3126
|
+
return sessionStore.get(cacheKey2)?.sessionId;
|
|
3127
|
+
}
|
|
3128
|
+
function setSessionIdForSession(cacheKey2, sessionId) {
|
|
3129
|
+
const session = sessionStore.get(cacheKey2);
|
|
3130
|
+
if (!session) return false;
|
|
3131
|
+
session.sessionId = sessionId;
|
|
3132
|
+
return true;
|
|
3133
|
+
}
|
|
3134
|
+
function setWantsPriorConversation(cacheKey2) {
|
|
3135
|
+
const session = sessionStore.get(cacheKey2);
|
|
3136
|
+
if (session) session.wantsPriorConversation = true;
|
|
3137
|
+
}
|
|
3138
|
+
function unregisterSession(cacheKey2) {
|
|
3139
|
+
return sessionStore.delete(cacheKey2);
|
|
3140
|
+
}
|
|
3141
|
+
function getSessionKeyBySessionId(_sessionId) {
|
|
3142
|
+
return void 0;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3050
3145
|
// server/loop-registry.ts
|
|
3051
3146
|
import { readFileSync as readFileSync4 } from "fs";
|
|
3052
3147
|
var TAG = "[loop-registry]";
|
|
@@ -3524,7 +3619,7 @@ async function verifyRemotePassword(password) {
|
|
|
3524
3619
|
const configured = anyAccessPasswordConfigured(USERS_FILE) || legacy !== null;
|
|
3525
3620
|
return { ok: false, why: configured ? "password-mismatch" : "no-password-file", hashBytes: 0 };
|
|
3526
3621
|
}
|
|
3527
|
-
var
|
|
3622
|
+
var SESSION_TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
3528
3623
|
var TOKEN_PREFIX = "v1.";
|
|
3529
3624
|
var SECRET_BYTES = 32;
|
|
3530
3625
|
var NONCE_BYTES = 16;
|
|
@@ -3599,13 +3694,13 @@ function validateRemoteSession(token, now = Date.now()) {
|
|
|
3599
3694
|
if (!token) return false;
|
|
3600
3695
|
const parsed = parseToken(token);
|
|
3601
3696
|
if (!parsed || !parsed.signatureValid) return false;
|
|
3602
|
-
return now - parsed.payload.c <=
|
|
3697
|
+
return now - parsed.payload.c <= SESSION_TTL_MS2;
|
|
3603
3698
|
}
|
|
3604
3699
|
function describeRemoteSession(token, now = Date.now()) {
|
|
3605
3700
|
if (!token) return { present: false, expired: false };
|
|
3606
3701
|
const parsed = parseToken(token);
|
|
3607
3702
|
if (!parsed || !parsed.signatureValid) return { present: false, expired: false };
|
|
3608
|
-
return { present: true, expired: now - parsed.payload.c >
|
|
3703
|
+
return { present: true, expired: now - parsed.payload.c > SESSION_TTL_MS2 };
|
|
3609
3704
|
}
|
|
3610
3705
|
function normalizeIp(ip) {
|
|
3611
3706
|
if (!ip) return void 0;
|
|
@@ -4244,70 +4339,6 @@ function getOperatorDomains() {
|
|
|
4244
4339
|
return operatorDomains;
|
|
4245
4340
|
}
|
|
4246
4341
|
|
|
4247
|
-
// app/lib/claude-agent/session-store.ts
|
|
4248
|
-
import { createHash } from "crypto";
|
|
4249
|
-
var SESSION_TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
4250
|
-
var sessionStore = /* @__PURE__ */ new Map();
|
|
4251
|
-
function fingerprintSessionKey(raw2) {
|
|
4252
|
-
if (typeof raw2 !== "string" || !raw2) return raw2;
|
|
4253
|
-
if (/^sk_[a-f0-9]{16}$/.test(raw2)) return raw2;
|
|
4254
|
-
if (!raw2.startsWith("v1.")) return raw2;
|
|
4255
|
-
return `sk_${createHash("sha256").update(raw2).digest("hex").slice(0, 16)}`;
|
|
4256
|
-
}
|
|
4257
|
-
function registerSession(cacheKey2, agentType, accountId, _unused, userId, userName, role) {
|
|
4258
|
-
const existing = sessionStore.get(cacheKey2);
|
|
4259
|
-
if (existing) {
|
|
4260
|
-
existing.agentType = agentType;
|
|
4261
|
-
existing.accountId = accountId;
|
|
4262
|
-
existing.userId = userId ?? existing.userId;
|
|
4263
|
-
existing.userName = userName ?? existing.userName;
|
|
4264
|
-
existing.role = role ?? existing.role;
|
|
4265
|
-
return;
|
|
4266
|
-
}
|
|
4267
|
-
sessionStore.set(cacheKey2, { agentType, createdAt: Date.now(), accountId, userId, userName, role });
|
|
4268
|
-
}
|
|
4269
|
-
function validateSession(cacheKey2, agentType, _signedSessionToken) {
|
|
4270
|
-
const session = sessionStore.get(cacheKey2);
|
|
4271
|
-
if (!session) return { ok: false, reason: "session-not-registered" };
|
|
4272
|
-
if (session.agentType !== agentType) return { ok: false, reason: "agent-type-mismatch" };
|
|
4273
|
-
if (Date.now() - session.createdAt > SESSION_TTL_MS2) {
|
|
4274
|
-
sessionStore.delete(cacheKey2);
|
|
4275
|
-
return { ok: false, reason: "session-expired-age" };
|
|
4276
|
-
}
|
|
4277
|
-
return { ok: true };
|
|
4278
|
-
}
|
|
4279
|
-
function getAccountIdForSession(cacheKey2) {
|
|
4280
|
-
return sessionStore.get(cacheKey2)?.accountId;
|
|
4281
|
-
}
|
|
4282
|
-
function getUserIdForSession(cacheKey2) {
|
|
4283
|
-
return sessionStore.get(cacheKey2)?.userId;
|
|
4284
|
-
}
|
|
4285
|
-
function getUserNameForSession(cacheKey2) {
|
|
4286
|
-
return sessionStore.get(cacheKey2)?.userName;
|
|
4287
|
-
}
|
|
4288
|
-
function getRoleForSession(cacheKey2) {
|
|
4289
|
-
return sessionStore.get(cacheKey2)?.role;
|
|
4290
|
-
}
|
|
4291
|
-
function getSessionIdForSession(cacheKey2) {
|
|
4292
|
-
return sessionStore.get(cacheKey2)?.sessionId;
|
|
4293
|
-
}
|
|
4294
|
-
function setSessionIdForSession(cacheKey2, sessionId) {
|
|
4295
|
-
const session = sessionStore.get(cacheKey2);
|
|
4296
|
-
if (!session) return false;
|
|
4297
|
-
session.sessionId = sessionId;
|
|
4298
|
-
return true;
|
|
4299
|
-
}
|
|
4300
|
-
function setWantsPriorConversation(cacheKey2) {
|
|
4301
|
-
const session = sessionStore.get(cacheKey2);
|
|
4302
|
-
if (session) session.wantsPriorConversation = true;
|
|
4303
|
-
}
|
|
4304
|
-
function unregisterSession(cacheKey2) {
|
|
4305
|
-
return sessionStore.delete(cacheKey2);
|
|
4306
|
-
}
|
|
4307
|
-
function getSessionKeyBySessionId(_sessionId) {
|
|
4308
|
-
return void 0;
|
|
4309
|
-
}
|
|
4310
|
-
|
|
4311
4342
|
// app/lib/claude-agent/plugin-manifest.ts
|
|
4312
4343
|
import { resolve as resolve5, join as join3 } from "path";
|
|
4313
4344
|
import {
|
|
@@ -4522,37 +4553,6 @@ var emitMissingOnResolve = (..._args) => null;
|
|
|
4522
4553
|
// app/lib/claude-agent/summary-helpers.ts
|
|
4523
4554
|
var stripAttachmentMetaSuffix = (..._args) => null;
|
|
4524
4555
|
|
|
4525
|
-
// ../lib/require-port-env/src/index.ts
|
|
4526
|
-
var MissingPortEnvError = class extends Error {
|
|
4527
|
-
envName;
|
|
4528
|
-
tag;
|
|
4529
|
-
failLine;
|
|
4530
|
-
constructor(envName, tag, failLine, message) {
|
|
4531
|
-
super(message);
|
|
4532
|
-
this.name = "MissingPortEnvError";
|
|
4533
|
-
this.envName = envName;
|
|
4534
|
-
this.tag = tag;
|
|
4535
|
-
this.failLine = failLine;
|
|
4536
|
-
}
|
|
4537
|
-
};
|
|
4538
|
-
var VALID_PORT_MIN = 1;
|
|
4539
|
-
var VALID_PORT_MAX = 65535;
|
|
4540
|
-
function requirePortEnv(envName, options = {}) {
|
|
4541
|
-
const tag = options.tag ?? "port-env";
|
|
4542
|
-
const failLine = options.failLine ?? "missing-port-env";
|
|
4543
|
-
const raw2 = process.env[envName];
|
|
4544
|
-
if (raw2 === void 0 || raw2 === "") {
|
|
4545
|
-
const msg = `[${tag}] ${failLine} reason=missing-env env=${envName}`;
|
|
4546
|
-
throw new MissingPortEnvError(envName, tag, failLine, msg);
|
|
4547
|
-
}
|
|
4548
|
-
const parsed = Number.parseInt(raw2, 10);
|
|
4549
|
-
if (!Number.isInteger(parsed) || parsed < VALID_PORT_MIN || parsed > VALID_PORT_MAX || String(parsed) !== raw2.trim()) {
|
|
4550
|
-
const msg = `[${tag}] ${failLine} reason=invalid-port-env env=${envName} value=${JSON.stringify(raw2)}`;
|
|
4551
|
-
throw new MissingPortEnvError(envName, tag, failLine, msg);
|
|
4552
|
-
}
|
|
4553
|
-
return parsed;
|
|
4554
|
-
}
|
|
4555
|
-
|
|
4556
4556
|
// app/lib/neo4j-store.ts
|
|
4557
4557
|
import neo4j from "neo4j-driver";
|
|
4558
4558
|
import { randomUUID } from "crypto";
|
|
@@ -6236,6 +6236,19 @@ export {
|
|
|
6236
6236
|
resolveAgentConfig,
|
|
6237
6237
|
isActiveAgentSlug,
|
|
6238
6238
|
getDefaultAccountId,
|
|
6239
|
+
requirePortEnv,
|
|
6240
|
+
fingerprintSessionKey,
|
|
6241
|
+
registerSession,
|
|
6242
|
+
validateSession,
|
|
6243
|
+
getAccountIdForSession,
|
|
6244
|
+
getUserIdForSession,
|
|
6245
|
+
getUserNameForSession,
|
|
6246
|
+
getRoleForSession,
|
|
6247
|
+
getSessionIdForSession,
|
|
6248
|
+
setSessionIdForSession,
|
|
6249
|
+
setWantsPriorConversation,
|
|
6250
|
+
unregisterSession,
|
|
6251
|
+
getSessionKeyBySessionId,
|
|
6239
6252
|
sampleCpu,
|
|
6240
6253
|
sampleProcessCpu,
|
|
6241
6254
|
registerLoop,
|
|
@@ -6271,18 +6284,6 @@ export {
|
|
|
6271
6284
|
isOperatorHost,
|
|
6272
6285
|
classifyHost,
|
|
6273
6286
|
getOperatorDomains,
|
|
6274
|
-
fingerprintSessionKey,
|
|
6275
|
-
registerSession,
|
|
6276
|
-
validateSession,
|
|
6277
|
-
getAccountIdForSession,
|
|
6278
|
-
getUserIdForSession,
|
|
6279
|
-
getUserNameForSession,
|
|
6280
|
-
getRoleForSession,
|
|
6281
|
-
getSessionIdForSession,
|
|
6282
|
-
setSessionIdForSession,
|
|
6283
|
-
setWantsPriorConversation,
|
|
6284
|
-
unregisterSession,
|
|
6285
|
-
getSessionKeyBySessionId,
|
|
6286
6287
|
findMissingPlugins,
|
|
6287
6288
|
walkPremiumBundles,
|
|
6288
6289
|
autoDeliverPremiumPlugins,
|
|
@@ -6290,7 +6291,6 @@ export {
|
|
|
6290
6291
|
cleanupLeakedPremiumSubs,
|
|
6291
6292
|
emitMissingOnResolve,
|
|
6292
6293
|
stripAttachmentMetaSuffix,
|
|
6293
|
-
requirePortEnv,
|
|
6294
6294
|
getSession,
|
|
6295
6295
|
runAdminUserSelfHeal,
|
|
6296
6296
|
runUserProfileReconcile,
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Activity — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/activity-
|
|
8
|
+
<script type="module" crossorigin src="/assets/activity-DH3Wgc3O.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CltuBf4Z.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/triangle-alert-
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-0PfRrN6i.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-Ckht9hmU.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/triangle-alert-DBJ7xz_t.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-BkQ5tA8A.css">
|
|
14
14
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Agents — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/agents-
|
|
8
|
+
<script type="module" crossorigin src="/assets/agents-X_IvDHLZ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CltuBf4Z.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-0PfRrN6i.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-Ckht9hmU.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-BkQ5tA8A.css">
|
|
13
13
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/payload/server/public/assets/{AdminLoginScreens-D5KOQA8S.js → AdminLoginScreens-YT7jsh_H.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,H as r,I as i,K as a,R as o}from"./useSubAccountSwitcher-DSW9vDi2.js";import{D as s}from"./useVoiceRecorder-BeNqxmm2.js";import{C as c,T as l,w as u}from"./AdminShell-C8wazpnz.js";var d=`admin-landing-redirected`,f=`/graph`;function p(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var m=e(a(),1);function h(e=`admin`){let[t,n]=(0,m.useState)(`loading`),[i,a]=(0,m.useState)(``),[o,c]=(0,m.useState)(``),[u,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(void 0),[M,N]=(0,m.useState)(null),[P,F]=(0,m.useState)(void 0),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(null),[B,V]=(0,m.useState)(void 0),H=(0,m.useRef)(void 0),[U,W]=(0,m.useState)(!1),[G,K]=(0,m.useState)(!0);(0,m.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,m.useRef)(null),J=(0,m.useRef)(null);(0,m.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=s(r.thinkingView);return H.current=i,V(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,m.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,m.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(d)===`1`}catch{}if(p({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(d,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${f}`),window.location.replace(f)}},[t,e]);let Y=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){r(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,m.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!i.ok){let e=await i.json().catch(()=>({}));if(i.status===401&&e?.code===`remote-auth-required`){r(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let o=await i.json();D(o.session_key),z(o.sessionId??null),j(o.businessName),N(o.role??null),F(o.userName===void 0?null:o.userName),L(o.avatar??null);let c=s(o.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,m.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=o.trim();if(!t){h(`Please enter your name.`);return}if(i.length<4){h(`PIN must be at least 4 characters.`);return}let s=i;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){r(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let i=await fetch(`/api/health`);if((i.ok?await i.json():null)?.claude_authenticated){await X(s);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[i,v,o]),Q=(0,m.useCallback)(async e=>{e.preventDefault(),h(``),await X(i)},[i]),ee=(0,m.useCallback)(async()=>{T(!0);try{if(!await l())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(d)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,m.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(d)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,m.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:n,pin:i,setPin:a,operatorName:o,setOperatorName:c,pinError:u,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var g=t();function _({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,m.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,g.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,g.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function v(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:l,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:h}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,g.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,g.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>h(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,g.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,g.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(u,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})]}),l&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:l})]})})}function y(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:l,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,g.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,g.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,g.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(`div`,{className:`pin-options`,children:(0,g.jsx)(u,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})})]}),l&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:l})]})]})}function b(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:a,pinError:s,setPinError:l,setAppState:u}=e,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){h(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}h(!1)}async function T(){a(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),a(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}a(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||d?(0,g.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,g.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,g.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,g.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,g.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,g.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,g.jsx)(`div`,{style:{marginTop:`12px`},children:(0,g.jsx)(c,{variant:`primary`,onClick:T,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&_===`native`&&(0,g.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,g.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,g.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,g.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,g.jsx)(c,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,g.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,g.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,g.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsxs)(`div`,{className:`connect-logos`,children:[(0,g.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,g.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,g.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,g.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,g.jsx)(c,{variant:`primary`,onClick:T,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,g.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,g.jsx)(`button`,{onClick:w,disabled:p,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:p?`Launching…`:`Open browser first`}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function x({auth:e}){return e.appState===`loading`?(0,g.jsx)(n,{surface:`gate`}):e.appState===`set-pin`?(0,g.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,g.jsx)(b,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,g.jsx)(y,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{h as n,x as t};
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,H as r,I as i,K as a,R as o}from"./useSubAccountSwitcher-0PfRrN6i.js";import{D as s}from"./useVoiceRecorder-BP6CpYQD.js";import{C as c,T as l,w as u}from"./AdminShell-Ckht9hmU.js";var d=`admin-landing-redirected`,f=`/graph`;function p(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var m=e(a(),1);function h(e=`admin`){let[t,n]=(0,m.useState)(`loading`),[i,a]=(0,m.useState)(``),[o,c]=(0,m.useState)(``),[u,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(void 0),[M,N]=(0,m.useState)(null),[P,F]=(0,m.useState)(void 0),[I,L]=(0,m.useState)(null),[R,z]=(0,m.useState)(null),[B,V]=(0,m.useState)(void 0),H=(0,m.useRef)(void 0),[U,W]=(0,m.useState)(!1),[G,K]=(0,m.useState)(!0);(0,m.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,m.useRef)(null),J=(0,m.useRef)(null);(0,m.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=s(r.thinkingView);return H.current=i,V(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,m.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,m.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(d)===`1`}catch{}if(p({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(d,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${f}`),window.location.replace(f)}},[t,e]);let Y=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){r(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,m.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!i.ok){let e=await i.json().catch(()=>({}));if(i.status===401&&e?.code===`remote-auth-required`){r(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let o=await i.json();D(o.session_key),z(o.sessionId??null),j(o.businessName),N(o.role??null),F(o.userName===void 0?null:o.userName),L(o.avatar??null);let c=s(o.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,m.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=o.trim();if(!t){h(`Please enter your name.`);return}if(i.length<4){h(`PIN must be at least 4 characters.`);return}let s=i;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){r(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let i=await fetch(`/api/health`);if((i.ok?await i.json():null)?.claude_authenticated){await X(s);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[i,v,o]),Q=(0,m.useCallback)(async e=>{e.preventDefault(),h(``),await X(i)},[i]),ee=(0,m.useCallback)(async()=>{T(!0);try{if(!await l())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(d)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,m.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(d)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,m.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:n,pin:i,setPin:a,operatorName:o,setOperatorName:c,pinError:u,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var g=t();function _({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,m.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,g.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,g.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function v(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:l,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:h}=e;return(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,g.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,g.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>h(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,g.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,g.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(u,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})]}),l&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:l})]})})}function y(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:l,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,g.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,g.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,g.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,g.jsxs)(`div`,{className:`pin-input-row`,children:[(0,g.jsx)(_,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,g.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,g.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,g.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,g.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,g.jsx)(`div`,{className:`pin-options`,children:(0,g.jsx)(u,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})})]}),l&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:l})]})]})}function b(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:a,pinError:s,setPinError:l,setAppState:u}=e,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){h(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}h(!1)}async function T(){a(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),a(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}a(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||d?(0,g.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,g.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,g.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,g.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,g.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,g.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,g.jsx)(`div`,{style:{marginTop:`12px`},children:(0,g.jsx)(c,{variant:`primary`,onClick:T,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&_===`native`&&(0,g.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,g.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,g.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,g.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,g.jsx)(c,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,g.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,g.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,g.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,g.jsx)(`div`,{className:`connect-page`,children:(0,g.jsxs)(`div`,{className:`connect-content`,children:[(0,g.jsxs)(`div`,{className:`connect-logos`,children:[(0,g.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,g.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,g.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,g.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,g.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,g.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,g.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,g.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,g.jsx)(c,{variant:`primary`,onClick:T,disabled:r,children:r?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,g.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,g.jsx)(`button`,{onClick:w,disabled:p,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:p?`Launching…`:`Open browser first`}),s&&(0,g.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function x({auth:e}){return e.appState===`loading`?(0,g.jsx)(n,{surface:`gate`}):e.appState===`set-pin`?(0,g.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,g.jsx)(b,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,g.jsx)(y,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{h as n,x as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,I as c,K as l,L as u,M as d,N as f,O as p,P as m,S as h,T as g,_,a as v,b as ee,d as te,f as y,g as b,h as x,k as S,m as ne,o as C,r as w,t as re,u as ie,v as ae,w as oe,x as T,z as se}from"./useSubAccountSwitcher-DSW9vDi2.js";async function ce(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var E=n();function le({checked:e,onChange:t,label:n,disabled:r,ariaLabel:i=n}){return(0,E.jsxs)(`label`,{className:`maxy-checkbox${r?` maxy-checkbox--disabled`:``}`,children:[(0,E.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,E.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),n&&(0,E.jsx)(`span`,{className:`maxy-checkbox__label`,children:n})]})}var D=e(l(),1),ue={sm:14,md:16,lg:18},O={sm:30,md:38,lg:46};function k({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,"aria-pressed":u,style:d,className:f,children:p}){let m=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,f].filter(Boolean).join(` `),h=ue[t],g={...e===`send`?{width:O[t],height:O[t]}:{},...d},_=Object.keys(g).length>0;return(0,E.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,E.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,E.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,E.jsx)(n,{size:h})]}),i&&(0,E.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var de=m(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),fe=m(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),pe=m(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=m(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),me=m(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),he=m(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ge=m(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),j=m(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),_e=m(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ve=m(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),ye=m(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),be=m(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),xe=m(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),Se=m(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);function Ce({connected:e,onConnectClaude:t}){return e?(0,E.jsxs)(`span`,{className:`claude-status-pill`,"data-connected":`true`,title:`Claude is connected`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connected`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--live`,"aria-hidden":`true`})]}):(0,E.jsxs)(`button`,{type:`button`,className:`claude-status-pill claude-status-pill--action`,"data-connected":`false`,onClick:t,title:`Connect Claude`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connect`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--down`,"aria-hidden":`true`})]})}function we(e){return e===`/`||e===``?`Dashboard`:e.startsWith(`/chat`)?`Chat`:e.startsWith(`/tasks`)?`Tasks`:e.startsWith(`/data`)?`Data`:e.startsWith(`/calendar`)?`Calendar`:e.startsWith(`/graph`)?`Graph`:e.startsWith(`/activity`)?`Activity`:e.startsWith(`/browser`)?`Browser`:`Dashboard`}function Te({title:e,sidebarOpen:t,onToggleSidebar:n,claudeConnected:r,onConnectClaude:i}){let a=e??we(typeof window<`u`?window.location.pathname:`/`),o=r!==void 0&&i!==void 0;return(0,E.jsxs)(`header`,{className:`admin-page-header`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`admin-page-header__toggle`,"aria-label":t?`Hide sidebar`:`Show sidebar`,title:t?`Hide sidebar`:`Show sidebar`,"aria-expanded":t,onClick:n,children:[(0,E.jsx)(ve,{className:`admin-page-header__toggle-desktop`,size:18,strokeWidth:1.75}),(0,E.jsx)(oe,{className:`admin-page-header__toggle-mobile`,size:22,strokeWidth:1.75})]}),(0,E.jsx)(`h1`,{className:`admin-page-header__title`,children:a}),o&&(0,E.jsx)(`div`,{className:`admin-page-header__right`,children:(0,E.jsx)(Ce,{connected:r,onConnectClaude:i})})]})}var Ee=[{label:`Home`,href:`/`,Icon:a,match:e=>e===`/`||e===``},{label:`Chat`,href:`/chat`,Icon:r,match:e=>e.startsWith(`/chat`)},{label:`Tasks`,href:`/tasks`,Icon:j,match:e=>e.startsWith(`/tasks`)},{label:`Data`,href:`/data`,Icon:t,match:e=>e.startsWith(`/data`)},{label:`Calendar`,href:`/calendar`,Icon:d,match:e=>e.startsWith(`/calendar`)}],De=[{label:`Chat`,href:`/`,Icon:r,match:e=>e===`/`||e===``||e.startsWith(`/chat`)},{label:`Data`,href:`/data`,Icon:t,match:e=>e.startsWith(`/data`)}];function Oe(e){let t=Ee.find(t=>t.match(e));return t?t.href:`/`}function M({variant:e=`admin`,onOpenConversations:t}={}){let n=typeof window<`u`?window.location.pathname:`/`,i=e===`operator`?De:Ee,a=e===`operator`?De.find(e=>e.match(n))?.href??`/`:Oe(n),o=e=>{let t=e.href===a,{Icon:n}=e;return(0,E.jsxs)(`a`,{href:e.href,className:`bottom-tab${t?` is-active`:``}`,"aria-current":t?`page`:void 0,children:[(0,E.jsx)(n,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:e.label})]},e.href)};return(0,E.jsxs)(`nav`,{className:`bottom-tab-bar`,"aria-label":`Primary`,children:[i.slice(0,1).map(o),e===`operator`&&t&&(0,E.jsxs)(`button`,{type:`button`,className:`bottom-tab`,onClick:t,children:[(0,E.jsx)(r,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:`Conversations`})]}),i.slice(1).map(o)]})}var ke=`maxy-shell-side-px`;function Ae(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function N(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-Ae());return Math.min(Math.max(e,248),n)}function je(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(ke);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return N(t)}catch{}return 264}function Me({targetSelector:e=`.platform`}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(()=>je()),i=(0,D.useRef)(n);(0,D.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,D.useCallback)(()=>{r(e=>{let t=N(e);return t===e?e:t})},[]);(0,D.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(N(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(ke,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=N(264);r(e);try{window.localStorage.removeItem(ke)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,E.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var Ne=s();function Pe(e){return Math.max(14,e/2-386)}function Fe(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var Ie={position:`fixed`,visibility:`hidden`};function P({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,D.useRef)(null),[c,l]=(0,D.useState)(Ie),u=(0,D.useRef)(null),d=(0,D.useCallback)(()=>{let t=s.current;if(!t)return;let r=e.current,i=[n,a].filter(Boolean).join(`:`)||`unknown`,o=t.getBoundingClientRect(),c=window.innerWidth,d=window.innerHeight,f=o.width>0&&o.height>0,p=r?r.getBoundingClientRect():null,m=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${d}`),h=e=>{e!==u.current&&(u.current=e,console.log(e))};if(h(`[anchored-popover] op=anchor id=${i} present=${!!r} rect=${p?`${p.left},${p.top},${p.width},${p.height}`:`none`}`),!p){let e=Math.max(4,c-o.width-Pe(c)),t=Math.max(4,d-o.height-14);l({position:`fixed`,left:e,top:t,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${e} top=${t} w=${o.width} h=${o.height} flipped=false clampedLeft=false clampedRight=false`);return}if(f&&Fe(p)){l(Ie),m(p.left,p.top);return}let g=p.right-o.width,_=c-o.width-4,v=!1,ee=!1;g>_&&(g=_,v=!0),g<4&&(g=4,ee=!0);let te=d-p.bottom-4,y=p.top-4,b=o.height+8<=te?!1:o.height+8<=y?!0:y>te,x=Math.max(0,b?y:te),S=b?Math.max(4,p.top-Math.min(o.height,x)):p.bottom;l({position:`fixed`,left:g,top:S,maxHeight:x,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${g} top=${S} w=${o.width} h=${o.height} maxH=${x} flipped=${b} clampedLeft=${ee} clampedRight=${v}`);let ne=Math.min(o.height,x);f&&(g+o.width<=0||g>=c||S+ne<=0||S>=d)&&m(g,S)},[e,a,n]);return(0,D.useLayoutEffect)(()=>{if(d(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>d());return s.current&&e.observe(s.current),()=>e.disconnect()},[d]),(0,D.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||s.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,Ne.createPortal)((0,E.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function Le({actions:e,disabled:t}){let[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),o=(0,D.useRef)(null),s=(0,D.useCallback)(()=>{r(!1),a(null)},[]);return(0,E.jsxs)(`div`,{className:`conv-actions`,children:[(0,E.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,E.jsx)(oe,{size:12})}),n&&(0,E.jsx)(P,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,E.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,E.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var F=`claude-opus-5[1m]`,Re=`claude-sonnet-5`,I=`claude-haiku-4-5`,ze={[F]:`Opus 5 (1M context)`,[Re]:`Sonnet 5`,[I]:`Haiku 4.5`};function L(e){return ze[e]??e}var R=[F,Re,I];function Be(e){return e.replace(/\[1m\]$/,``)}function z(e){return R.find(t=>Be(t)===Be(e))??e}var Ve=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...Ve],[...B],[...B];var V=[F,Re,I],He={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},H=Ve.map(e=>({value:e,label:He[e]??e})),U={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},Ue=B.map(e=>({value:e,label:U[e]??e}));function We(e){if(e){let t=V.find(t=>Be(t)===Be(e));if(t)return t}return F}function Ge({row:e,adminFetch:t,onError:n}){let[r,i]=(0,D.useState)(()=>We(e.model)),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(``),[l,u]=(0,D.useState)(!1),d=(0,D.useRef)(!1);(0,D.useEffect)(()=>{i(We(e.model))},[e.model]);let f=async()=>{if(!d.current){d.current=!0,u(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),d.current=!1,u(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),d.current=!1,u(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),d.current=!1,u(!1)}}};return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Model`}),(0,E.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:V.map(e=>(0,E.jsx)(`option`,{value:e,children:L(e)},e))})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Mode`}),(0,E.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Effort`}),(0,E.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),Ue.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void f(),children:l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(g,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function Ke(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function qe(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Je({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,D.useRef)(null);return i.current=t,e?(0,E.jsxs)(P,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Delete this conversation?`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,E.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,E.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,E.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsx)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function Ye({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,E.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsxs)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}var Xe=`auth-refresh-failed`;function Ze({error:e,onClose:t}){if(!e)return null;let n=e.reason===Xe,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:r}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,E.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Qe(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,D.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,E.jsx)(`span`,{children:`Claude Code`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,E.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:p>0?qe(p):`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:Ke(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await w(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function $e({open:e,onConnect:t,onClose:n}){return e?(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Claude isn’t connected`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,E.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,E.jsx)(k,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function et(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function W(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function tt(e){return e.toLocaleString(`en-GB`)}function nt(e){return`£${e.toFixed(2)}`}function rt(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 5 (GBP)`,`Sonnet 5 (GBP)`],n=(e,t)=>[e,et(W(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,C as r,D as i,E as a,F as o,G as s,I as c,K as l,L as u,M as d,N as f,O as p,P as m,S as h,T as g,_,a as v,b as ee,d as te,f as y,g as b,h as x,k as S,m as ne,o as C,r as w,t as re,u as ie,v as ae,w as oe,x as T,z as se}from"./useSubAccountSwitcher-0PfRrN6i.js";async function ce(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var E=n();function le({checked:e,onChange:t,label:n,disabled:r,ariaLabel:i=n}){return(0,E.jsxs)(`label`,{className:`maxy-checkbox${r?` maxy-checkbox--disabled`:``}`,children:[(0,E.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,E.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),n&&(0,E.jsx)(`span`,{className:`maxy-checkbox__label`,children:n})]})}var D=e(l(),1),ue={sm:14,md:16,lg:18},O={sm:30,md:38,lg:46};function k({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,"aria-pressed":u,style:d,className:f,children:p}){let m=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,f].filter(Boolean).join(` `),h=ue[t],g={...e===`send`?{width:O[t],height:O[t]}:{},...d},_=Object.keys(g).length>0;return(0,E.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,E.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,E.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,E.jsx)(n,{size:h})]}),i&&(0,E.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var de=m(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),fe=m(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),pe=m(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),A=m(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),me=m(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),he=m(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ge=m(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),j=m(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),_e=m(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ve=m(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),ye=m(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),be=m(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),xe=m(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),Se=m(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);function Ce({connected:e,onConnectClaude:t}){return e?(0,E.jsxs)(`span`,{className:`claude-status-pill`,"data-connected":`true`,title:`Claude is connected`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connected`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--live`,"aria-hidden":`true`})]}):(0,E.jsxs)(`button`,{type:`button`,className:`claude-status-pill claude-status-pill--action`,"data-connected":`false`,onClick:t,title:`Connect Claude`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,E.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connect`}),(0,E.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--down`,"aria-hidden":`true`})]})}function we(e){return e===`/`||e===``?`Dashboard`:e.startsWith(`/chat`)?`Chat`:e.startsWith(`/tasks`)?`Tasks`:e.startsWith(`/data`)?`Data`:e.startsWith(`/calendar`)?`Calendar`:e.startsWith(`/graph`)?`Graph`:e.startsWith(`/activity`)?`Activity`:e.startsWith(`/browser`)?`Browser`:`Dashboard`}function Te({title:e,sidebarOpen:t,onToggleSidebar:n,claudeConnected:r,onConnectClaude:i}){let a=e??we(typeof window<`u`?window.location.pathname:`/`),o=r!==void 0&&i!==void 0;return(0,E.jsxs)(`header`,{className:`admin-page-header`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`admin-page-header__toggle`,"aria-label":t?`Hide sidebar`:`Show sidebar`,title:t?`Hide sidebar`:`Show sidebar`,"aria-expanded":t,onClick:n,children:[(0,E.jsx)(ve,{className:`admin-page-header__toggle-desktop`,size:18,strokeWidth:1.75}),(0,E.jsx)(oe,{className:`admin-page-header__toggle-mobile`,size:22,strokeWidth:1.75})]}),(0,E.jsx)(`h1`,{className:`admin-page-header__title`,children:a}),o&&(0,E.jsx)(`div`,{className:`admin-page-header__right`,children:(0,E.jsx)(Ce,{connected:r,onConnectClaude:i})})]})}var Ee=[{label:`Home`,href:`/`,Icon:a,match:e=>e===`/`||e===``},{label:`Chat`,href:`/chat`,Icon:r,match:e=>e.startsWith(`/chat`)},{label:`Tasks`,href:`/tasks`,Icon:j,match:e=>e.startsWith(`/tasks`)},{label:`Data`,href:`/data`,Icon:t,match:e=>e.startsWith(`/data`)},{label:`Calendar`,href:`/calendar`,Icon:d,match:e=>e.startsWith(`/calendar`)}],De=[{label:`Chat`,href:`/`,Icon:r,match:e=>e===`/`||e===``||e.startsWith(`/chat`)},{label:`Data`,href:`/data`,Icon:t,match:e=>e.startsWith(`/data`)}];function Oe(e){let t=Ee.find(t=>t.match(e));return t?t.href:`/`}function M({variant:e=`admin`,onOpenConversations:t}={}){let n=typeof window<`u`?window.location.pathname:`/`,i=e===`operator`?De:Ee,a=e===`operator`?De.find(e=>e.match(n))?.href??`/`:Oe(n),o=e=>{let t=e.href===a,{Icon:n}=e;return(0,E.jsxs)(`a`,{href:e.href,className:`bottom-tab${t?` is-active`:``}`,"aria-current":t?`page`:void 0,children:[(0,E.jsx)(n,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:e.label})]},e.href)};return(0,E.jsxs)(`nav`,{className:`bottom-tab-bar`,"aria-label":`Primary`,children:[i.slice(0,1).map(o),e===`operator`&&t&&(0,E.jsxs)(`button`,{type:`button`,className:`bottom-tab`,onClick:t,children:[(0,E.jsx)(r,{size:19,strokeWidth:1.75}),(0,E.jsx)(`span`,{className:`bottom-tab__label`,children:`Conversations`})]}),i.slice(1).map(o)]})}var ke=`maxy-shell-side-px`;function Ae(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function N(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-Ae());return Math.min(Math.max(e,248),n)}function je(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(ke);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return N(t)}catch{}return 264}function Me({targetSelector:e=`.platform`}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(()=>je()),i=(0,D.useRef)(n);(0,D.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,D.useCallback)(()=>{r(e=>{let t=N(e);return t===e?e:t})},[]);(0,D.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(N(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(ke,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=N(264);r(e);try{window.localStorage.removeItem(ke)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,E.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var Ne=s();function Pe(e){return Math.max(14,e/2-386)}function Fe(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var Ie={position:`fixed`,visibility:`hidden`};function P({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,D.useRef)(null),[c,l]=(0,D.useState)(Ie),u=(0,D.useRef)(null),d=(0,D.useCallback)(()=>{let t=s.current;if(!t)return;let r=e.current,i=[n,a].filter(Boolean).join(`:`)||`unknown`,o=t.getBoundingClientRect(),c=window.innerWidth,d=window.innerHeight,f=o.width>0&&o.height>0,p=r?r.getBoundingClientRect():null,m=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${d}`),h=e=>{e!==u.current&&(u.current=e,console.log(e))};if(h(`[anchored-popover] op=anchor id=${i} present=${!!r} rect=${p?`${p.left},${p.top},${p.width},${p.height}`:`none`}`),!p){let e=Math.max(4,c-o.width-Pe(c)),t=Math.max(4,d-o.height-14);l({position:`fixed`,left:e,top:t,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${e} top=${t} w=${o.width} h=${o.height} flipped=false clampedLeft=false clampedRight=false`);return}if(f&&Fe(p)){l(Ie),m(p.left,p.top);return}let g=p.right-o.width,_=c-o.width-4,v=!1,ee=!1;g>_&&(g=_,v=!0),g<4&&(g=4,ee=!0);let te=d-p.bottom-4,y=p.top-4,b=o.height+8<=te?!1:o.height+8<=y?!0:y>te,x=Math.max(0,b?y:te),S=b?Math.max(4,p.top-Math.min(o.height,x)):p.bottom;l({position:`fixed`,left:g,top:S,maxHeight:x,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${g} top=${S} w=${o.width} h=${o.height} maxH=${x} flipped=${b} clampedLeft=${ee} clampedRight=${v}`);let ne=Math.min(o.height,x);f&&(g+o.width<=0||g>=c||S+ne<=0||S>=d)&&m(g,S)},[e,a,n]);return(0,D.useLayoutEffect)(()=>{if(d(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>d());return s.current&&e.observe(s.current),()=>e.disconnect()},[d]),(0,D.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||s.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,Ne.createPortal)((0,E.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function Le({actions:e,disabled:t}){let[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null),o=(0,D.useRef)(null),s=(0,D.useCallback)(()=>{r(!1),a(null)},[]);return(0,E.jsxs)(`div`,{className:`conv-actions`,children:[(0,E.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,E.jsx)(oe,{size:12})}),n&&(0,E.jsx)(P,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,E.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,E.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,E.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,E.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var F=`claude-opus-5[1m]`,Re=`claude-sonnet-5`,I=`claude-haiku-4-5`,ze={[F]:`Opus 5 (1M context)`,[Re]:`Sonnet 5`,[I]:`Haiku 4.5`};function L(e){return ze[e]??e}var R=[F,Re,I];function Be(e){return e.replace(/\[1m\]$/,``)}function z(e){return R.find(t=>Be(t)===Be(e))??e}var Ve=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...Ve],[...B],[...B];var V=[F,Re,I],He={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},H=Ve.map(e=>({value:e,label:He[e]??e})),U={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},Ue=B.map(e=>({value:e,label:U[e]??e}));function We(e){if(e){let t=V.find(t=>Be(t)===Be(e));if(t)return t}return F}function Ge({row:e,adminFetch:t,onError:n}){let[r,i]=(0,D.useState)(()=>We(e.model)),[a,o]=(0,D.useState)(``),[s,c]=(0,D.useState)(``),[l,u]=(0,D.useState)(!1),d=(0,D.useRef)(!1);(0,D.useEffect)(()=>{i(We(e.model))},[e.model]);let f=async()=>{if(!d.current){d.current=!0,u(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),d.current=!1,u(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),d.current=!1,u(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),d.current=!1,u(!1)}}};return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Model`}),(0,E.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:V.map(e=>(0,E.jsx)(`option`,{value:e,children:L(e)},e))})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Mode`}),(0,E.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsxs)(`label`,{className:`reseat-field`,children:[(0,E.jsx)(`span`,{children:`Effort`}),(0,E.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,E.jsx)(`option`,{value:``,children:`Keep current`}),Ue.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,E.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void f(),children:l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(g,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function Ke(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function qe(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Je({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,D.useRef)(null);return i.current=t,e?(0,E.jsxs)(P,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Delete this conversation?`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,E.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,E.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,E.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,E.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsx)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function Ye({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,E.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,E.jsxs)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,E.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}var Xe=`auth-refresh-failed`;function Ze({error:e,onClose:t}){if(!e)return null;let n=e.reason===Xe,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:r}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,E.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Qe(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,D.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,E.jsx)(`span`,{children:`Claude Code`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,E.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,E.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,children:[(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:p>0?qe(p):`—`})]}),(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`span`,{className:`claude-info-value`,children:Ke(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,E.jsxs)(`div`,{className:`claude-info-row`,children:[(0,E.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await w(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function $e({open:e,onConnect:t,onClose:n}){return e?(0,E.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,E.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsx)(`span`,{children:`Claude isn’t connected`}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,E.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,E.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,E.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,E.jsx)(k,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,E.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function et(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function W(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function tt(e){return e.toLocaleString(`en-GB`)}function nt(e){return`£${e.toFixed(2)}`}function rt(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 5 (GBP)`,`Sonnet 5 (GBP)`],n=(e,t)=>[e,et(W(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
|
|
2
2
|
`)}function it({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,E.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,E.jsx)(r,{className:`usage-day`,children:e}),(0,E.jsx)(r,{children:et(W(t))}),(0,E.jsx)(r,{children:tt(t.tokens.output)}),(0,E.jsx)(r,{children:tt(t.tokens.input)}),(0,E.jsx)(r,{children:tt(t.tokens.cacheWrite)}),(0,E.jsx)(r,{children:tt(t.tokens.cacheRead)}),(0,E.jsx)(r,{children:nt(t.costGBP.opus)}),(0,E.jsx)(r,{children:nt(t.costGBP.sonnet)})]})}function at({show:e,onClose:t,anchorEl:n,sessionId:r,summary:i,loading:a,error:o}){let s=(0,D.useRef)(null);if(s.current=n,!e)return null;let c=!!i&&i.days.length>0;return(0,E.jsxs)(P,{anchorRef:s,onClose:t,className:`usage-popover`,role:`dialog`,ariaLabel:`Session usage and cost`,anchorId:r??void 0,children:[(0,E.jsxs)(`div`,{className:`claude-info-header`,children:[(0,E.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),c&&(0,E.jsx)(`button`,{className:`usage-download`,onClick:()=>{if(!i)return;let e=new Blob([rt(i)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usage-${r?r.slice(0,8):`session`}.csv`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)},"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,E.jsx)(S,{size:14})}),(0,E.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,E.jsx)(b,{size:14})})]}),(0,E.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,E.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,E.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&i&&i.days.length===0&&(0,E.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&i&&i.days.length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`usage-table-scroll`,children:(0,E.jsxs)(`table`,{className:`usage-table`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,E.jsx)(`th`,{children:`Active`}),(0,E.jsx)(`th`,{children:`Output tok`}),(0,E.jsx)(`th`,{children:`Input tok`}),(0,E.jsx)(`th`,{children:`Cache write`}),(0,E.jsx)(`th`,{children:`Cache read`}),(0,E.jsx)(`th`,{children:`Opus 5 (£)`}),(0,E.jsx)(`th`,{children:`Sonnet 5 (£)`})]})}),(0,E.jsxs)(`tbody`,{children:[i.days.map(e=>(0,E.jsx)(it,{label:e.date,d:e},e.date)),(0,E.jsx)(it,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,E.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,i.pricing.opusPriceDate,` · £/$ `,i.pricing.usdPerGbp,` · Sonnet tokenizer factor `,i.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost.`]})]})]})]})}var ot=`https://claude.ai/code`,st=200,ct=[500,1e3,1500,2e3,2500,3e3,3e3];function lt(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${ot}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function ut(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function dt(e){let{businessName:n,cacheKey:o,onConnectClaude:s,role:l,userName:m,userAvatar:te,onSelectProjects:b,onSelectTasks:S,onCloseMobileDrawer:w,collapsed:re,onSelectData:oe,initialDataSurface:ce=!1,onLogout:ue,onDisconnect:O,disconnecting:k,claudeConnected:ve=!0,subAccounts:Ce,activeAccountId:we,switchingAccount:Te,onSwitchAccount:Ee,refreshAccounts:De,onOpenConversations:Oe}=e,M=ne(o),ke=(0,D.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,E.jsx)(ye,{size:12}),panel:()=>(0,E.jsx)(Ge,{row:e,adminFetch:M,onError:e=>R({message:e,failed:!0})})}),[M]),Ae=c.productName,N=n||Ae,je=typeof m==`string`?m:m===null?`name unavailable`:N,Me=(je.trim().charAt(0)||`?`).toUpperCase(),[Ne,Pe]=(0,D.useState)(ce?`data`:`sessions`),[Fe,Ie]=(0,D.useState)(!1),[P,F]=(0,D.useState)(!1),Re=!re&&(Ce?.length??0)>1&&!!Ee,I=Ce?.find(e=>e.isHouse)??null,ze=(0,D.useCallback)(()=>{if(I){if(I.accountId===we){console.info(`[admin-ui] op=subaccount-switch-house anchor=brand-icon accountId=${I.accountId.slice(0,8)} switched=false reason=already-house`);return}console.info(`[admin-ui] op=subaccount-switch-house anchor=brand-icon accountId=${I.accountId.slice(0,8)} switched=true`),F(!1),Ee?.(I.accountId,`/`)}},[I,we,Ee]),[L,R]=(0,D.useState)(null),[Be,z]=(0,D.useState)(null),[Ve,B]=(0,D.useState)(!1),[V,He]=(0,D.useState)([]),[H]=(0,D.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[U,Ue]=(0,D.useState)(!1),[We,Ke]=(0,D.useState)(null),[qe,Xe]=(0,D.useState)(!1),[Qe,et]=(0,D.useState)(!1),[W,tt]=(0,D.useState)(!1),[nt,rt]=(0,D.useState)(null),[it,ot]=(0,D.useState)(new Set),dt=(0,D.useRef)(new Map),[G,mt]=(0,D.useState)(!1),[K,ht]=(0,D.useState)(new Set),[gt,_t]=(0,D.useState)(!1),[q,vt]=(0,D.useState)(null),[yt,bt]=(0,D.useState)(new Set),[xt,St]=(0,D.useState)(new Set),[Ct,wt]=(0,D.useState)(new Set),[J,Y]=(0,D.useState)(null),[Tt,Et]=(0,D.useState)(``),[Dt,Ot]=(0,D.useState)(!1),[kt,At]=(0,D.useState)(null),[jt,Mt]=(0,D.useState)(null),[Nt,Pt]=(0,D.useState)(!1),[Ft,It]=(0,D.useState)(null),[X,Lt]=(0,D.useState)(!1),Rt=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(!L)return;let e=setTimeout(()=>R(null),2500);return()=>clearTimeout(e)},[L]);let zt=H!=null&&V.some(e=>e.sessionId===H);(0,D.useEffect)(()=>{H==null||!U||console.info(`[sidebar-sessions] op=select-highlight session=${H.slice(0,8)} matched=${zt}`)},[H,zt,U]);let Z=(0,D.useCallback)(async()=>{if(!o)return null;let e=++Rt.current;Xe(!0),Ke(null);try{let t=await M(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Rt.current?(He(r),rt(n.accountId??null),Ue(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===Rt.current&&Ke(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Rt.current&&Xe(!1)}},[o,M]);(0,D.useEffect)(()=>{!o||U||Z()},[o,U,Z]),(0,D.useEffect)(()=>{if(!o)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Z()}function n(){e===null&&(e=setInterval(t,ft))}function r(){e!==null&&(clearInterval(e),e=null)}function i(){document.hidden?r():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,i),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[o,Z]);let Bt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Z()},Vt=()=>{Pe(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${re}`),oe(),w()},Q=typeof window<`u`&&window.location?.pathname||`/`,Ht=Ne===`data`,Ut=typeof window<`u`&&window.location?.search||``,Wt=new URLSearchParams(Ut),Gt=Wt.has(`label`)&&!Wt.has(`nodeId`),$=e=>{w(),window.location.href=e},Kt=[{key:`dashboard`,label:`Dashboard`,icon:(0,E.jsx)(a,{size:17,strokeWidth:1.75}),active:Q===`/`&&!Ht,onClick:()=>$(`/`)},{key:`chat`,label:`Chat`,icon:(0,E.jsx)(r,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/chat`),onClick:()=>$(`/chat`)},{key:`tasks`,label:`Tasks`,icon:(0,E.jsx)(j,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/tasks`),onClick:()=>{S(),w()}},{key:`calendar`,label:`Calendar`,icon:(0,E.jsx)(d,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/calendar`),onClick:()=>$(`/calendar`)},{key:`routines`,label:`Routines`,icon:(0,E.jsx)(Se,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/routines`),onClick:()=>$(`/routines`)},{key:`skills`,label:`Skills`,icon:(0,E.jsx)(be,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/skills`),onClick:()=>$(`/skills`)},{key:`agents`,label:`Agents`,icon:(0,E.jsx)(pe,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/agents`),onClick:()=>$(`/agents`)},{key:`data`,label:`Data`,icon:(0,E.jsx)(t,{size:17,strokeWidth:1.75}),active:Ht,onClick:Vt},{key:`container`,label:se().term,icon:(0,E.jsx)(p,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&Gt,onClick:()=>{b(),w()}},{key:`graph`,label:`Graph`,icon:(0,E.jsx)(xe,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&!Gt,onClick:()=>$(`/graph`)},{key:`activity`,label:`Activity`,icon:(0,E.jsx)(f,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/activity`),onClick:()=>$(`/activity`)},{key:`browser`,label:`Browser`,icon:(0,E.jsx)(i,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/browser`),onClick:()=>$(`/browser`)}],qt=(0,D.useCallback)(async e=>{if(yt.has(e.sessionId))return;bt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=lt(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(w(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),z(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),z({sessionId:e.sessionId,reason:r})}finally{bt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,w,yt]),Jt=(0,D.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=ct.length;n++){await new Promise(e=>setTimeout(e,ct[n-1]));let r=await Z();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Z]),Yt=(0,D.useCallback)(async()=>{if(!X){Lt(!0);try{let e=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=lt(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Jt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),B(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),z(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),z({sessionId:null,reason:t})}finally{Lt(!1)}}},[M,X,Jt]),Xt=(0,D.useCallback)((e,t)=>{e.stopPropagation(),vt(t)},[]),Zt=(0,D.useCallback)(async(e,t)=>{e.stopPropagation(),At(t),Mt(null),It(null),Pt(!0);try{let e=await M(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?Mt(n):It(n.error??`status ${e.status}`)}catch(e){It(e instanceof Error?e.message:String(e))}finally{Pt(!1)}},[M]),Qt=(0,D.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if(it.has(e.sessionId))return!1;ot(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await M(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),R({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0}),!1}let r=await t.json();return console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${r.pidKilled??`?`} deleted=${r.deleted??`?`}`),He(t=>t.filter(t=>t.sessionId!==e.sessionId)),n&&Z(),!0}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),R({message:`Delete failed: ${n}`,failed:!0}),!1}finally{ot(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,it,Z]),$t=(0,D.useCallback)(e=>{ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),en=(0,D.useCallback)(()=>{mt(!1),ht(new Set)},[]),tn=(0,D.useCallback)(async()=>{let e=[...K].map(e=>V.find(t=>t.sessionId===e)).filter(e=>!!e),t=e.filter(e=>e.live).length;console.info(`[admin-ui] sidebar-bulk-delete op=start count=${e.length} live=${t}`);let n=(await Promise.all(e.map(e=>Qt(e,{refresh:!1})))).filter(Boolean).length;console.info(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${n} failed=${e.length-n}`),Z(),en()},[K,V,Qt,Z,en]),nn=(0,D.useCallback)(async(e,t)=>{if(e.stopPropagation(),!xt.has(t.sessionId)){St(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),R({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Z()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),R({message:`Stop failed: ${n}`,failed:!0})}finally{St(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,xt,Z]),rn=(0,D.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Ct.has(t.sessionId)){wt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),R({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Z()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),R({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{wt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,Ct,Z]),an=(0,D.useCallback)(async e=>{let t=Tt.trim();if(!t){R({message:`Title can’t be empty`,failed:!0});return}if(t.length>st){R({message:`Title too long (max ${st})`,failed:!0});return}Ot(!0);try{let n=await M(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),R({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),Y(null),Et(``),Z()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),R({message:`Rename failed: ${n}`,failed:!0})}finally{Ot(!1)}},[M,Tt,Z]);return(0,E.jsxs)(`aside`,{className:`side`,children:[(0,E.jsxs)(`div`,{className:`side-brand`,children:[Re?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,className:`side-brand-icon-btn`,"aria-label":`Switch to house account`,disabled:!I,onClick:ze,children:(0,E.jsx)(`img`,{className:`side-brand-icon`,src:u,alt:``,"aria-hidden":`true`})}),(0,E.jsxs)(`button`,{type:`button`,className:`side-brand-trigger`,"aria-haspopup":`menu`,"aria-expanded":P,"aria-label":`Switch sub-account`,onClick:()=>{let e=!P;F(e),e&&De?.(),console.info(`[admin-ui] op=subaccount-switcher-toggle anchor=brand-head open=${e} available=true accounts=${Ce?.length??0}`)},children:[(0,E.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,E.jsx)(`span`,{className:`side-brand-business`,children:N}),(0,E.jsx)(`span`,{className:`side-brand-product`,children:c.productName})]}),(0,E.jsx)(A,{size:14,className:`side-brand-caret`,"aria-hidden":`true`})]})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`img`,{className:`side-brand-icon`,src:u,alt:``,"aria-hidden":`true`}),(0,E.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,E.jsx)(`span`,{className:`side-brand-business`,children:N}),(0,E.jsx)(`span`,{className:`side-brand-product`,children:c.productName})]})]}),P&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`side-brand-scrim`,"aria-hidden":`true`,onClick:()=>F(!1)}),(0,E.jsx)(x,{open:P,accounts:Ce??[],activeAccountId:we??null,switching:Te??!1,onSelect:e=>Ee?.(e),onClose:()=>F(!1)})]})]}),(0,E.jsx)(`nav`,{className:`side-nav`,children:Kt.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`admin-row nav-row${e.active?` active`:``}`,"aria-current":e.active?`page`:void 0,onClick:e.onClick,children:[e.icon,(0,E.jsx)(`span`,{className:`label`,children:e.label}),(0,E.jsx)(`span`,{className:`kbd`})]},e.key))}),(()=>{let e=V.filter(e=>Qe?!0:!e.isSubagent).filter(e=>W?!0:!e.archived),t=V.some(e=>e.isSubagent),n=V.some(e=>e.archived);return(0,E.jsx)(`div`,{className:`side-sessions`,children:(0,E.jsxs)(`div`,{className:`side-list`,children:[(0,E.jsxs)(`div`,{className:`group-head`,children:[(0,E.jsx)(`span`,{children:`Sessions`}),(0,E.jsxs)(`span`,{className:`group-head-meta`,children:[(0,E.jsx)(`button`,{type:`button`,className:`group-head-select${G?` active`:``}`,"aria-pressed":G,title:G?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{mt(e=>!e),ht(new Set),Y(null),Et(``)},children:`Select`}),(0,E.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Bt,disabled:qe,children:(0,E.jsx)(ee,{size:12,className:qe?`spinning`:void 0})}),(0,E.jsx)(`span`,{children:qe?`…`:String(e.length)}),(0,E.jsxs)(`button`,{type:`button`,className:`admin-btn-cta side-sessions-new`,onClick:Yt,disabled:X,"aria-busy":X,"aria-label":X?`Spawning session`:`New session`,title:X?`Spawning session`:`New session`,children:[X?(0,E.jsx)(g,{size:13,className:`spinning`}):(0,E.jsx)(T,{size:13}),(0,E.jsx)(`span`,{children:X?`Spawning…`:`New session`})]})]})]}),G&&(0,E.jsxs)(`div`,{className:`session-select-bar`,children:[(0,E.jsxs)(`span`,{className:`session-select-count`,children:[K.size,` selected`]}),(0,E.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:K.size===0,onClick:()=>_t(!0),children:[`Delete `,K.size]}),(0,E.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:en,children:`Cancel`})]}),nt&&(0,E.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,E.jsx)(`code`,{children:nt})}),(t||n)&&(0,E.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,E.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Qe?` active`:``}`,"aria-pressed":Qe,onClick:()=>et(e=>!e),title:Qe?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,E.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${W?` active`:``}`,"aria-pressed":W,onClick:()=>tt(e=>!e),title:W?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),We&&(0,E.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:We}),U&&!We&&e.length===0&&(0,E.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=ut(e.startedAt),n=yt.has(e.sessionId),r=it.has(e.sessionId),i=xt.has(e.sessionId),a=Ct.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},c=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,E.jsx)(he,{size:12}),busy:n,onClick:()=>{qt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,E.jsx)(_e,{size:12}),onClick:()=>{s()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,E.jsx)(ge,{size:12}),onClick:t=>{Zt(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,E.jsx)(ae,{size:12}),busy:i,onClick:t=>{nn(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,E.jsx)(de,{size:12}),busy:a,onClick:t=>{rn(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,E.jsx)(fe,{size:12}),busy:a,onClick:t=>{rn(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,E.jsx)(h,{size:12}),busy:Dt&&J===e.sessionId,onClick:t=>{t.stopPropagation(),Y(e.sessionId),Et(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,E.jsx)(_,{size:12}),danger:!0,busy:r,onClick:t=>{Xt(t,e)}},ke({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})],l=e.channel===`whatsapp`?` conv-channel-whatsapp`:e.channel===`telegram`?` conv-channel-telegram`:``,u=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`,d=C.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?v({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title}):e.personName??e.title;return(0,E.jsxs)(`div`,{ref:t=>{let n=dt.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${l}${e.sessionId===H?` active`:``}`,children:[(0,E.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${d} in webchat`,onClick:()=>{if(J!==e.sessionId){if(G){$t(e.sessionId);return}s()}},onKeyDown:t=>{J!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),G?$t(e.sessionId):s())},children:[G&&(0,E.jsx)(`span`,{className:`conv-select-check`,onClick:e=>e.stopPropagation(),children:(0,E.jsx)(le,{checked:K.has(e.sessionId),ariaLabel:`Select ${d}`,onChange:()=>$t(e.sessionId)})}),(0,E.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"data-archived":e.archived?`1`:`0`,"aria-label":e.archived?`archived session`:e.live?`live session`:`ended session`}),(0,E.jsxs)(`span`,{className:`conv-stack`,children:[(0,E.jsxs)(`span`,{className:`conv-name-line`,children:[u&&(0,E.jsx)(ie,{channel:e.channel,size:13}),J===e.sessionId?(0,E.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:Tt,disabled:Dt,"aria-label":`New title for session ${e.title}`,onChange:e=>Et(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),an(e)):t.key===`Escape`&&(t.preventDefault(),Y(null),Et(``))},onBlur:()=>{J===e.sessionId&&!Dt&&(Y(null),Et(``))}}):(0,E.jsx)(`span`,{className:`conv-name`,title:d,children:d})]}),(0,E.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,E.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,E.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!G&&(0,E.jsx)(Le,{actions:c,disabled:o})]},e.sessionId)})]})})})(),(0,E.jsxs)(`div`,{className:`side-foot`,children:[(0,E.jsx)(`div`,{className:`avatar`,children:te?(0,E.jsx)(`img`,{src:te,alt:je}):Me}),(0,E.jsxs)(`div`,{className:`who`,children:[(0,E.jsx)(`span`,{className:`name`,children:je}),(0,E.jsx)(pt,{})]}),(0,E.jsx)(`button`,{type:`button`,className:`side-foot-kebab`,"aria-label":`Account menu`,"aria-haspopup":`menu`,"aria-expanded":Fe,onClick:()=>Ie(e=>!e),children:(0,E.jsx)(me,{size:16})}),Fe&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`side-foot-menu-scrim`,"aria-hidden":`true`,onClick:()=>Ie(!1)}),(0,E.jsx)(`div`,{className:`side-foot-menu`,role:`menu`,children:(0,E.jsx)(y,{variant:`admin`,onCloseMenu:()=>Ie(!1),onLogout:ue??(()=>{}),onDisconnect:O,disconnecting:k,claudeConnected:ve,onConnectClaude:s,cacheKey:o,onOpenConversations:Oe})})]})]}),L&&(0,E.jsx)(`div`,{className:`copy-toast${L.failed?` copy-toast-failed`:``}`,role:`status`,children:L.message}),(0,E.jsx)(Ze,{error:Be,onClose:()=>z(null)}),(0,E.jsx)($e,{open:Ve,onConnect:()=>{B(!1),s?.()},onClose:()=>B(!1)}),(0,E.jsx)(Je,{target:q,anchorEl:q?dt.current.get(q.sessionId)??null:null,onCancel:()=>vt(null),onConfirm:()=>{let e=q;vt(null),e&&Qt(e)}},q?.sessionId??`none`),(0,E.jsx)(Ye,{open:gt,count:K.size,liveCount:V.filter(e=>K.has(e.sessionId)&&e.live).length,onConfirm:()=>{_t(!1),tn()},onCancel:()=>_t(!1)}),(0,E.jsx)(at,{show:kt!==null,onClose:()=>{At(null),Mt(null),It(null)},anchorEl:kt?dt.current.get(kt.sessionId)??null:null,sessionId:kt?.sessionId??null,summary:jt,loading:Nt,error:Ft},kt?.sessionId??`none`)]})}var G=5e3,ft=3e4;function pt(){let[e,t]=(0,D.useState)(null);if((0,D.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},G))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=[`system-stats`];return c&&d.push(`system-stats--warn`),l&&d.push(`system-stats--crit`),(0,E.jsxs)(`span`,{className:d.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,E.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),` · `,(0,E.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]})]})}var mt=`admin-sidebar-collapsed`,K=`admin-sidebar-drawer-open`,ht=1080;function gt(){if(typeof window>`u`)return!1;let e=null;try{e=window.sessionStorage.getItem(mt)}catch{e=null}return e===null?typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 721px) and (max-width: ${ht}px)`).matches:!1:e===`1`}function _t(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(mt,`1`):window.sessionStorage.removeItem(mt)}catch{}}function q(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(K)===`1`}catch{return!1}}function vt(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(K,`1`):window.sessionStorage.removeItem(K)}catch{}}function yt(e){let[t,n]=(0,D.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,D.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var bt=720;function xt(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function St(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function Ct(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function wt(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function J(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:e===`activity`?`/activity`:`/browser`}function Y(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:s,claudeConnected:c,onConnectClaude:l,userName:u,userAvatar:d,role:f,onOpenConversations:p,children:m,footer:h}=e,{subAccounts:g,activeAccountId:_,switching:v,switchAccount:ee,refreshAccounts:y}=re(t),[b,x]=(0,D.useState)(!0);(0,D.useEffect)(()=>{if(c!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||x(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[c,r]);let S=c??b,ne=l??(()=>{window.location.assign(`/?connect=claude`)}),[C,w]=(0,D.useState)(()=>gt()),[ie,ae]=(0,D.useState)(!1),oe=(0,D.useRef)(!0);(0,D.useEffect)(()=>{if(oe.current){oe.current=!1;return}ae(!0);let e=setTimeout(()=>ae(!1),260);return()=>clearTimeout(e)},[C]);let[T,ce]=(0,D.useState)(()=>q()),le=yt(`(max-width: ${bt}px)`),[ue,O]=(0,D.useState)(()=>typeof window>`u`||wt(window.location.pathname,window.location.search)?null:Ct(window.location.pathname,window.location.search)),[k,de]=(0,D.useState)(()=>typeof window>`u`?!1:wt(window.location.pathname,window.location.search)),[fe]=(0,D.useState)(()=>k),pe=(0,D.useCallback)(e=>{_t(e),w(e)},[]),A=(0,D.useCallback)(e=>{vt(e),ce(e)},[]);(0,D.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${C} drawer=${T}`)},[]),(0,D.useEffect)(()=>{typeof window>`u`||!ue||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${ue.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,D.useEffect)(()=>{typeof window>`u`||!k||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let me=(0,D.useCallback)(e=>{if(de(!1),e===null){O(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=xt(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?O(e):window.location.href=n.href},[]),he=(0,D.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=St(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}O(null),de(!0)},[]),ge=le?T:!C,j=(0,D.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${bt}px)`).matches){let e=T;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),A(!e)}else{let e=C;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),pe(!e)}},[C,T,pe,A]),_e=(0,D.useCallback)(e=>{let t=J(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),ve={collapsed:C,mobileDrawerOpen:T,sidebarOpen:ge,onToggleSidebar:j,setMobileDrawerOpen:A,selectedWhatsapp:ue,onClearWhatsapp:()=>O(null),onSelectWhatsappConversation:me,dataOpen:k};return r===`operator`?(0,E.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[v&&(0,E.jsx)(o,{surface:`switch`}),(0,E.jsx)(te,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:p,onToggleSidebar:j,sidebarOpen:ge,onLogout:i,onDisconnect:a,disconnecting:s,cacheKey:t,subAccounts:g,activeAccountId:_,switchingAccount:v,onSwitchAccount:ee,refreshAccounts:y}),(0,E.jsx)(`div`,{className:`platform platform-operator`,children:typeof m==`function`?m(ve):m}),(0,E.jsx)(M,{variant:`operator`,onOpenConversations:p}),h]}):(0,E.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[v&&(0,E.jsx)(o,{surface:`switch`}),(0,E.jsxs)(`div`,{className:`platform${T?` menu-open`:``}${!le&&C?` sidebar-collapsed`:``}${ie?` sidebar-animating`:``}`,"data-artefact":`closed`,children:[(0,E.jsx)(dt,{businessName:n,cacheKey:t,onConnectClaude:ne,role:f??null,userName:u,userAvatar:d??null,onSelectProjects:()=>{window.location.href=`/graph?label=${se().label}`},onSelectTasks:()=>{window.location.href=`/tasks`},onCloseMobileDrawer:()=>A(!1),collapsed:C,mobileDrawerOpen:T,onSelectData:he,onCloseData:()=>de(!1),initialDataSurface:fe,onLogout:i,onDisconnect:a,disconnecting:s,claudeConnected:S,subAccounts:g,activeAccountId:_,switchingAccount:v,onSwitchAccount:ee,refreshAccounts:y,onOpenConversations:p}),!le&&(0,E.jsx)(Me,{}),(0,E.jsx)(Te,{sidebarOpen:ge,onToggleSidebar:j,claudeConnected:S,onConnectClaude:ne}),typeof m==`function`?m(ve):m]}),T&&(0,E.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>A(!1)}),(0,E.jsx)(M,{}),h]})}export{k as C,de as S,ce as T,he as _,Qe as a,pe as b,Re as c,Se as d,be as f,ge as g,j as h,$e as i,z as l,_e as m,yt as n,I as o,ye as p,lt as r,F as s,Y as t,L as u,me as v,le as w,fe as x,A as y};
|