@rubytech/create-maxy-code 0.1.365 → 0.1.367
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -0
- package/package.json +1 -1
- package/payload/platform/plugins/admin/mcp/dist/content-producer-authoring-skills.d.ts.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/content-producer-authoring-skills.js +5 -4
- package/payload/platform/plugins/admin/mcp/dist/content-producer-authoring-skills.js.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/__tests__/account-lifecycle.test.js +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/__tests__/account-lifecycle.test.js.map +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +37 -31
- package/payload/platform/plugins/docs/references/admin-ui.md +2 -0
- package/payload/platform/plugins/docs/references/graph.md +34 -30
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/schema-write-path-task802.test.js +62 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/schema-write-path-task802.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.d.ts +14 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js +18 -0
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-validator.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-validator.js +16 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/schema-validator.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-search-fields.test.js +40 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-search-fields.test.js.map +1 -1
- package/payload/platform/plugins/memory/references/schema-construction.md +7 -0
- package/payload/platform/plugins/url-get/mcp/vitest.config.ts +14 -0
- package/payload/platform/services/claude-session-manager/dist/session-cap-audit.d.ts +46 -1
- package/payload/platform/services/claude-session-manager/dist/session-cap-audit.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-cap-audit.js +131 -7
- package/payload/platform/services/claude-session-manager/dist/session-cap-audit.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/stuck-turn.d.ts +5 -7
- package/payload/platform/services/claude-session-manager/dist/stuck-turn.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/stuck-turn.js +48 -32
- package/payload/platform/services/claude-session-manager/dist/stuck-turn.js.map +1 -1
- package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +73 -27
- package/payload/premium-plugins/writer-craft/PLUGIN.md +1 -1
- package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +2 -2
- package/payload/server/public/assets/{AdminLoginScreens-CJatEEai.js → AdminLoginScreens-B45MFjWG.js} +1 -1
- package/payload/server/public/assets/AdminShell-CyZPfbzd.js +1 -0
- package/payload/server/public/assets/{Checkbox-DqnBuFEU.js → Checkbox-BPYEJJPq.js} +1 -1
- package/payload/server/public/assets/OperatorConversations-Civ7TETM.css +1 -0
- package/payload/server/public/assets/{OperatorConversations-BwnO3IUP.js → OperatorConversations-D_o_59Oc.js} +1 -1
- package/payload/server/public/assets/{admin-Cocx_If1.js → admin-DcuJ3_xm.js} +1 -1
- package/payload/server/public/assets/{browser-BsFHTA93.js → browser-Be9LRtM2.js} +1 -1
- package/payload/server/public/assets/{calendar-hwGeTmWC.js → calendar-BeofvK7c.js} +1 -1
- package/payload/server/public/assets/chat-BWNFeIjw.js +1 -0
- package/payload/server/public/assets/{data-DOjJ8031.js → data-lTmU53k6.js} +1 -1
- package/payload/server/public/assets/{graph-DfUM66RH.js → graph-XYK2qT5D.js} +19 -19
- package/payload/server/public/assets/{graph-labels-CXt55mIP.js → graph-labels-DNCXtQVn.js} +1 -1
- package/payload/server/public/assets/{operator-CRRc0nD-.js → operator-B3hpbhNo.js} +1 -1
- package/payload/server/public/assets/page-DFOoEKVK.js +32 -0
- package/payload/server/public/assets/{public-Ba5G74iP.js → public-Bd_0QBGJ.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-BfYwa6ew.js → rotate-ccw-BxD1B_G-.js} +1 -1
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +4 -4
- package/payload/server/public/chat.html +6 -6
- package/payload/server/public/data.html +4 -4
- package/payload/server/public/graph.html +7 -7
- package/payload/server/public/index.html +6 -6
- package/payload/server/public/operator.html +8 -8
- package/payload/server/public/public.html +6 -6
- package/payload/server/server.js +51 -45
- package/payload/server/public/assets/AdminShell-D0MDlfI1.js +0 -1
- package/payload/server/public/assets/OperatorConversations-DDUzu1h8.css +0 -1
- package/payload/server/public/assets/chat-DMssYitp.js +0 -1
- package/payload/server/public/assets/page-wUvf2I5u.js +0 -32
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Browser — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/browser-
|
|
8
|
+
<script type="module" crossorigin src="/assets/browser-Be9LRtM2.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Calendar — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/calendar-
|
|
8
|
+
<script type="module" crossorigin src="/assets/calendar-BeofvK7c.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Chat — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/chat-
|
|
8
|
+
<script type="module" crossorigin src="/assets/chat-BWNFeIjw.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-DJoj6VJv.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CQ36nxok.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-BxD1B_G-.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/page-DFOoEKVK.js">
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="root"></div>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Data — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/data-
|
|
8
|
+
<script type="module" crossorigin src="/assets/data-lTmU53k6.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-DNCXtQVn.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
15
|
<div id="root"></div>
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Graph — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/graph-
|
|
8
|
+
<script type="module" crossorigin src="/assets/graph-XYK2qT5D.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/Checkbox-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
15
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-DNCXtQVn.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/Checkbox-BPYEJJPq.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-BxD1B_G-.js">
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
18
|
<div id="root"></div>
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-DcuJ3_xm.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-DJoj6VJv.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/Checkbox-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-
|
|
15
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/Checkbox-BPYEJJPq.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-B45MFjWG.js">
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
|
|
17
17
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
18
18
|
</head>
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Operator — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/operator-
|
|
8
|
+
<script type="module" crossorigin src="/assets/operator-B3hpbhNo.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-DJoj6VJv.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/Checkbox-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/Checkbox-BPYEJJPq.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-B45MFjWG.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CQ36nxok.js">
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-BxD1B_G-.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/page-DFOoEKVK.js">
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/public-
|
|
8
|
+
<script type="module" crossorigin src="/assets/public-Bd_0QBGJ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/OperatorConversations-D_o_59Oc.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-CyZPfbzd.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-DJoj6VJv.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CQ36nxok.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-BxD1B_G-.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/page-DFOoEKVK.js">
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/OperatorConversations-Civ7TETM.css">
|
|
17
17
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body class="public-surface">
|
package/payload/server/server.js
CHANGED
|
@@ -5060,14 +5060,25 @@ var SUPPORTED_MIME_TYPES = /* @__PURE__ */ new Set([
|
|
|
5060
5060
|
"text/html",
|
|
5061
5061
|
"text/calendar",
|
|
5062
5062
|
"application/zip",
|
|
5063
|
-
"application/x-zip-compressed"
|
|
5063
|
+
"application/x-zip-compressed",
|
|
5064
|
+
// Task 1240 — voice recordings persist as playable clips in the admin bubble.
|
|
5065
|
+
// These match AUDIO_MIME_TYPES in app/lib/stt/audio-mime.ts exactly.
|
|
5066
|
+
"audio/ogg",
|
|
5067
|
+
"audio/opus",
|
|
5068
|
+
"audio/webm",
|
|
5069
|
+
"audio/mp4",
|
|
5070
|
+
"audio/x-m4a",
|
|
5071
|
+
"audio/mpeg",
|
|
5072
|
+
"audio/wav",
|
|
5073
|
+
"video/mp4"
|
|
5064
5074
|
]);
|
|
5065
5075
|
var MAX_FILE_SIZE_BYTES = 50 * 1024 * 1024;
|
|
5066
5076
|
var MAX_FILES_PER_MESSAGE = 5;
|
|
5067
5077
|
var MAX_DATA_UPLOAD_BYTES = 2 * 1024 * 1024 * 1024;
|
|
5068
5078
|
var MAX_ZIP_UNCOMPRESSED_BYTES = 100 * 1024 * 1024;
|
|
5069
5079
|
function assertSupportedMime(mimeType) {
|
|
5070
|
-
|
|
5080
|
+
const bare = mimeType.split(";")[0].trim().toLowerCase();
|
|
5081
|
+
if (!SUPPORTED_MIME_TYPES.has(bare)) {
|
|
5071
5082
|
throw new Error(
|
|
5072
5083
|
`Unsupported file type: "${mimeType}". Supported types: ${[...SUPPORTED_MIME_TYPES].join(", ")}.`
|
|
5073
5084
|
);
|
|
@@ -7314,6 +7325,11 @@ var SOURCE_MAP = {
|
|
|
7314
7325
|
webchat: "webchat",
|
|
7315
7326
|
"webchat-channel": "webchat"
|
|
7316
7327
|
};
|
|
7328
|
+
function isScheduleSource(text) {
|
|
7329
|
+
const m = text.match(CHANNEL_WRAPPER2);
|
|
7330
|
+
if (!m) return false;
|
|
7331
|
+
return m[1].match(SOURCE_ATTR2)?.[1] === "schedule";
|
|
7332
|
+
}
|
|
7317
7333
|
function unwrapChannel(text) {
|
|
7318
7334
|
const m = text.match(CHANNEL_WRAPPER2);
|
|
7319
7335
|
if (!m) return { text };
|
|
@@ -7458,7 +7474,7 @@ function parseTranscript(lines, queuedPendingSuppress = /* @__PURE__ */ new Map(
|
|
|
7458
7474
|
}
|
|
7459
7475
|
if (row.type === "queue-operation" && row.operation === "enqueue") {
|
|
7460
7476
|
const content = asString(row.content);
|
|
7461
|
-
if (content !== null && CHANNEL_WRAPPER2.test(content)) {
|
|
7477
|
+
if (content !== null && CHANNEL_WRAPPER2.test(content) && !isScheduleSource(content)) {
|
|
7462
7478
|
const u = unwrapChannel(content);
|
|
7463
7479
|
out.push(operatorInboundTurn(u, ts));
|
|
7464
7480
|
queuedPendingSuppress.set(u.text, (queuedPendingSuppress.get(u.text) ?? 0) + 1);
|
|
@@ -7468,7 +7484,7 @@ function parseTranscript(lines, queuedPendingSuppress = /* @__PURE__ */ new Map(
|
|
|
7468
7484
|
if (row.type === "attachment") {
|
|
7469
7485
|
const att = row.attachment;
|
|
7470
7486
|
const isChannelQueued = att?.type === "queued_command" && att.isMeta === true && typeof att.origin === "object" && att.origin !== null && att.origin.kind === "channel" && typeof att.prompt === "string";
|
|
7471
|
-
if (isChannelQueued) {
|
|
7487
|
+
if (isChannelQueued && !isScheduleSource(att.prompt)) {
|
|
7472
7488
|
renderOrSuppressChannelInbound(unwrapChannel(att.prompt), ts, out, queuedPendingSuppress);
|
|
7473
7489
|
}
|
|
7474
7490
|
continue;
|
|
@@ -7489,7 +7505,9 @@ function parseTranscript(lines, queuedPendingSuppress = /* @__PURE__ */ new Map(
|
|
|
7489
7505
|
// enqueue row AND this row both render and every channel message doubles.
|
|
7490
7506
|
CHANNEL_WRAPPER2.test(text);
|
|
7491
7507
|
if (isChannel) {
|
|
7492
|
-
|
|
7508
|
+
if (!isScheduleSource(text)) {
|
|
7509
|
+
renderOrSuppressChannelInbound(unwrapChannel(text), ts, out, queuedPendingSuppress);
|
|
7510
|
+
}
|
|
7493
7511
|
} else {
|
|
7494
7512
|
out.push({ kind: "operator-typed", text, ts });
|
|
7495
7513
|
}
|
|
@@ -8849,20 +8867,6 @@ function createWebchatRoutes(deps) {
|
|
|
8849
8867
|
}
|
|
8850
8868
|
const audioFile = files.find((f) => isAudioMime(f.type));
|
|
8851
8869
|
const regularFiles = files.filter((f) => !isAudioMime(f.type));
|
|
8852
|
-
if (audioFile) {
|
|
8853
|
-
if (audioFile.size > MAX_FILE_SIZE_BYTES) {
|
|
8854
|
-
console.error(`[webchat:inbound] op=send-refused kind=voice reason=oversize bytes=${audioFile.size}`);
|
|
8855
|
-
return c.json({ error: "Recording too long. Try a shorter voice note." }, 422);
|
|
8856
|
-
}
|
|
8857
|
-
const result = await transcribeVoiceNote(audioFile, "admin");
|
|
8858
|
-
if (!result.ok) {
|
|
8859
|
-
console.error(`[webchat:inbound] op=send-refused kind=voice reason=stt-failed detail=${result.error}`);
|
|
8860
|
-
return c.json({ error: result.error }, 422);
|
|
8861
|
-
}
|
|
8862
|
-
text = text.length > 0 ? `${text}
|
|
8863
|
-
|
|
8864
|
-
${result.result.text}` : result.result.text;
|
|
8865
|
-
}
|
|
8866
8870
|
for (const file of regularFiles) {
|
|
8867
8871
|
try {
|
|
8868
8872
|
assertSupportedMime(file.type);
|
|
@@ -8876,6 +8880,27 @@ ${result.result.text}` : result.result.text;
|
|
|
8876
8880
|
}
|
|
8877
8881
|
}
|
|
8878
8882
|
const stored = [];
|
|
8883
|
+
if (audioFile) {
|
|
8884
|
+
if (audioFile.size > MAX_FILE_SIZE_BYTES) {
|
|
8885
|
+
console.error(`[webchat:inbound] op=send-refused kind=voice reason=oversize bytes=${audioFile.size}`);
|
|
8886
|
+
return c.json({ error: "Recording too long. Try a shorter voice note." }, 422);
|
|
8887
|
+
}
|
|
8888
|
+
try {
|
|
8889
|
+
stored.push(await storeAttachment(accountId, audioFile));
|
|
8890
|
+
} catch (err) {
|
|
8891
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
8892
|
+
console.error(`[webchat:inbound] op=send-refused kind=voice reason=audio-store-failed detail=${detail}`);
|
|
8893
|
+
return c.json({ error: "failed to store voice recording" }, 500);
|
|
8894
|
+
}
|
|
8895
|
+
const result = await transcribeVoiceNote(audioFile, "admin");
|
|
8896
|
+
if (result.ok) {
|
|
8897
|
+
text = text.length > 0 ? `${text}
|
|
8898
|
+
|
|
8899
|
+
${result.result.text}` : result.result.text;
|
|
8900
|
+
} else {
|
|
8901
|
+
console.error(`[webchat:inbound] op=stt-failed kind=voice detail=${result.error}`);
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8879
8904
|
try {
|
|
8880
8905
|
for (const file of regularFiles) {
|
|
8881
8906
|
stored.push(await storeAttachment(accountId, file));
|
|
@@ -10173,7 +10198,7 @@ app10.post("/", async (c) => {
|
|
|
10173
10198
|
const safe = typeof v === "string" ? truncate(v, 200) : typeof v === "number" || typeof v === "boolean" ? String(v) : JSON.stringify(v).slice(0, 200);
|
|
10174
10199
|
return `${k}=${safe}`;
|
|
10175
10200
|
}).join(" ");
|
|
10176
|
-
const TAGGED_PREFIX_SOURCES = /* @__PURE__ */ new Set(["stream-log-click", "pwa", "graph-
|
|
10201
|
+
const TAGGED_PREFIX_SOURCES = /* @__PURE__ */ new Set(["stream-log-click", "pwa", "graph-settle"]);
|
|
10177
10202
|
if (TAGGED_PREFIX_SOURCES.has(source)) {
|
|
10178
10203
|
console.log(
|
|
10179
10204
|
`[${source}] ts=${ts} ip=${ip} version=${version || "unknown"}${extra ? " " + extra : ""}`
|
|
@@ -14653,8 +14678,6 @@ var FILTER_TOP_LEVEL_LABELS = Object.freeze(
|
|
|
14653
14678
|
"Part",
|
|
14654
14679
|
"PurchaseOrder",
|
|
14655
14680
|
"PpmContract",
|
|
14656
|
-
"AdminConversation",
|
|
14657
|
-
"PublicConversation",
|
|
14658
14681
|
"Task",
|
|
14659
14682
|
"Project",
|
|
14660
14683
|
"Event",
|
|
@@ -14735,10 +14758,6 @@ async function handleDefault(c, accountId) {
|
|
|
14735
14758
|
return handleDefaultTopLevel(c, accountId, { includeTrashed, includeAgentActions });
|
|
14736
14759
|
}
|
|
14737
14760
|
const agentActionLabels = includeAgentActions ? [] : [...AGENT_ACTION_LABELS];
|
|
14738
|
-
const rawChannel = c.req.query("channel") ?? "";
|
|
14739
|
-
const channel = rawChannel.split(",").map((s) => s.trim()).filter(Boolean);
|
|
14740
|
-
const rawMessageSublabel = c.req.query("messageSublabel") ?? "";
|
|
14741
|
-
const messageSublabel = rawMessageSublabel.split(",").map((s) => s.trim()).filter(Boolean);
|
|
14742
14761
|
if (labels.length === 0) {
|
|
14743
14762
|
console.error(
|
|
14744
14763
|
`[graph-page] load rejected reason=missing-filter account=${accountId} labels=`
|
|
@@ -14770,7 +14789,7 @@ async function handleDefault(c, accountId) {
|
|
|
14770
14789
|
try {
|
|
14771
14790
|
const countCypher = includeTrashed ? DEFAULT_COUNT_CYPHER_INCLUDE_TRASHED : DEFAULT_COUNT_CYPHER;
|
|
14772
14791
|
const fetchCypher = includeTrashed ? DEFAULT_FETCH_CYPHER_INCLUDE_TRASHED : DEFAULT_FETCH_CYPHER;
|
|
14773
|
-
const cypherParams = { accountId, labels, agentActionLabels
|
|
14792
|
+
const cypherParams = { accountId, labels, agentActionLabels };
|
|
14774
14793
|
const result = await session.executeRead(async (tx) => {
|
|
14775
14794
|
const countResult = await tx.run(countCypher, cypherParams);
|
|
14776
14795
|
const matchedRaw = countResult.records[0]?.get("matched");
|
|
@@ -14802,10 +14821,8 @@ async function handleDefault(c, accountId) {
|
|
|
14802
14821
|
const nodes = result.rawNodes.map((n) => pruneNode(n, warnedClasses, conversationWarnings));
|
|
14803
14822
|
const edges = result.rawEdges.filter((e) => e && e.id != null).map((e) => pruneEdge(e, warnedClasses));
|
|
14804
14823
|
const trashedSuffix = includeTrashed ? " includeTrashed=1" : "";
|
|
14805
|
-
const channelSuffix = channel.length > 0 ? ` channel=${channel.join(",")}` : "";
|
|
14806
|
-
const sublabelSuffix = messageSublabel.length > 0 ? ` messageSublabel=${messageSublabel.join(",")}` : "";
|
|
14807
14824
|
console.error(
|
|
14808
|
-
`[graph-page] load mode=default account=${accountId} agentActions=${includeAgentActions} labels=${labels.join(",")}${trashedSuffix}
|
|
14825
|
+
`[graph-page] load mode=default account=${accountId} agentActions=${includeAgentActions} labels=${labels.join(",")}${trashedSuffix} nodes=${nodes.length} edges=${edges.length} ms=${elapsed}`
|
|
14809
14826
|
);
|
|
14810
14827
|
return c.json({ nodes, edges });
|
|
14811
14828
|
} catch (err) {
|
|
@@ -14833,8 +14850,6 @@ async function handleDefaultTopLevel(c, accountId, flags) {
|
|
|
14833
14850
|
accountId,
|
|
14834
14851
|
labels,
|
|
14835
14852
|
agentActionLabels,
|
|
14836
|
-
channel: [],
|
|
14837
|
-
messageSublabel: [],
|
|
14838
14853
|
topLevelLimit: neo4j2.int(TOP_LEVEL_LIMIT)
|
|
14839
14854
|
};
|
|
14840
14855
|
const result = await session.executeRead(async (tx) => {
|
|
@@ -15003,22 +15018,13 @@ async function handleNeighbourhood(c, accountId) {
|
|
|
15003
15018
|
}
|
|
15004
15019
|
}
|
|
15005
15020
|
}
|
|
15006
|
-
var SUBFACET_PREDICATE = `
|
|
15007
|
-
AND (size($channel) = 0
|
|
15008
|
-
OR NOT any(lbl IN labels(n) WHERE lbl IN ['Conversation','AdminConversation','PublicConversation'])
|
|
15009
|
-
OR n.channel IS NULL
|
|
15010
|
-
OR n.channel IN $channel)
|
|
15011
|
-
AND (size($messageSublabel) = 0
|
|
15012
|
-
OR NOT any(lbl IN labels(n) WHERE lbl IN ['Message','UserMessage','AssistantMessage','WhatsAppMessage'])
|
|
15013
|
-
OR any(lbl IN labels(n) WHERE lbl IN $messageSublabel))
|
|
15014
|
-
`;
|
|
15015
15021
|
var DEFAULT_COUNT_CYPHER = `
|
|
15016
15022
|
MATCH (n)
|
|
15017
15023
|
WHERE n.accountId = $accountId
|
|
15018
15024
|
AND any(lbl IN labels(n) WHERE lbl IN $labels)
|
|
15019
15025
|
AND NOT any(lbl IN labels(n) WHERE lbl IN $agentActionLabels)
|
|
15020
15026
|
AND NOT n:Trashed
|
|
15021
|
-
AND n.deletedAt IS NULL
|
|
15027
|
+
AND n.deletedAt IS NULL
|
|
15022
15028
|
RETURN count(n) AS matched
|
|
15023
15029
|
`;
|
|
15024
15030
|
var CONVERSATION_PROPS_PROJECTION = `CASE
|
|
@@ -15032,7 +15038,7 @@ var DEFAULT_FETCH_CYPHER = `
|
|
|
15032
15038
|
AND any(lbl IN labels(n) WHERE lbl IN $labels)
|
|
15033
15039
|
AND NOT any(lbl IN labels(n) WHERE lbl IN $agentActionLabels)
|
|
15034
15040
|
AND NOT n:Trashed
|
|
15035
|
-
AND n.deletedAt IS NULL
|
|
15041
|
+
AND n.deletedAt IS NULL
|
|
15036
15042
|
WITH collect(n) AS nodes, collect(elementId(n)) AS nodeIds
|
|
15037
15043
|
UNWIND nodes AS n
|
|
15038
15044
|
OPTIONAL MATCH (n)-[r]-(m)
|
|
@@ -15054,7 +15060,7 @@ var DEFAULT_COUNT_CYPHER_INCLUDE_TRASHED = `
|
|
|
15054
15060
|
WHERE n.accountId = $accountId
|
|
15055
15061
|
AND any(lbl IN labels(n) WHERE lbl IN $labels)
|
|
15056
15062
|
AND NOT any(lbl IN labels(n) WHERE lbl IN $agentActionLabels)
|
|
15057
|
-
AND n.deletedAt IS NULL
|
|
15063
|
+
AND n.deletedAt IS NULL
|
|
15058
15064
|
RETURN count(n) AS matched
|
|
15059
15065
|
`;
|
|
15060
15066
|
var DEFAULT_FETCH_CYPHER_INCLUDE_TRASHED = `
|
|
@@ -15062,7 +15068,7 @@ var DEFAULT_FETCH_CYPHER_INCLUDE_TRASHED = `
|
|
|
15062
15068
|
WHERE n.accountId = $accountId
|
|
15063
15069
|
AND any(lbl IN labels(n) WHERE lbl IN $labels)
|
|
15064
15070
|
AND NOT any(lbl IN labels(n) WHERE lbl IN $agentActionLabels)
|
|
15065
|
-
AND n.deletedAt IS NULL
|
|
15071
|
+
AND n.deletedAt IS NULL
|
|
15066
15072
|
WITH collect(n) AS nodes, collect(elementId(n)) AS nodeIds
|
|
15067
15073
|
UNWIND nodes AS n
|
|
15068
15074
|
OPTIONAL MATCH (n)-[r]-(m)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{C as t,E as n,F as r,I as i,N as a,O as o,P as s,U as c,W as l,_ as u,b as d,f,g as p,h as m,j as h,k as g,m as _,t as ee,w as te,y as ne,z as v}from"./OperatorConversations-BwnO3IUP.js";async function y(){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 b=v(`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`}]]),re=v(`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`}]]),x=v(`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`}]]),S=v(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),ie=v(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),C=v(`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`}]]),w=v(`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`}]]),ae=v(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),oe=v(`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`}]]),se=v(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),T=v(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),E=e(l(),1),D=te(),O={sm:14,md:16,lg:18},k={sm:30,md:38,lg:46};function A({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,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=O[t],h={...e===`send`?{width:k[t],height:k[t]}:{},...u},g=Object.keys(h).length>0;return(0,D.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,D.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,D.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,D.jsx)(n,{size:m})]}),i&&(0,D.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var j=`maxy-shell-side-px`;function ce(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function M(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-ce());return Math.min(Math.max(e,248),n)}function le(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(j);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 M(t)}catch{}return 264}function ue({targetSelector:e=`.platform`}){let t=(0,E.useRef)(null),[n,r]=(0,E.useState)(()=>le()),i=(0,E.useRef)(n);(0,E.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,E.useCallback)(()=>{r(e=>{let t=M(e);return t===e?e:t})},[]);(0,E.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(M(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(j,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=M(264);r(e);try{window.localStorage.removeItem(j)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,D.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var de=c();function fe({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,E.useRef)(null),[s,c]=(0,E.useState)({position:`fixed`,visibility:`hidden`}),l=(0,E.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,E.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,E.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.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,de.createPortal)((0,D.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function N({action:e,disabled:t,open:n,onToggle:r,onClose:i}){let a=(0,E.useRef)(null);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{ref:a,type:`button`,className:`conv-action`,onClick:r,disabled:t,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":e.label,title:e.title,children:e.icon}),n&&(0,D.jsx)(fe,{anchorRef:a,onClose:i,className:e.panelClassName,role:`dialog`,ariaLabel:e.label,children:e.panel()})]})}function pe({actions:e,disabled:t,collapsed:n}){let[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)(null),u=(0,E.useRef)(null);(0,E.useEffect)(()=>{a(null),s(!1),l(null)},[n]);let d=(0,E.useCallback)(()=>{s(!1),l(null)},[]);return n?(0,D.jsxs)(`div`,{className:`conv-actions`,children:[(0,D.jsx)(`button`,{ref:u,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>s(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":o,"aria-label":`Session actions`,title:`Session actions`,children:(0,D.jsx)(r,{size:12})}),o&&(0,D.jsx)(fe,{anchorRef:u,onClose:d,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,D.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":c===e.key,disabled:t,onClick:()=>l(t=>t===e.key?null:e.key),children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]}),c===e.key&&(0,D.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,D.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),d()},children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]},e.key))})]}):(0,D.jsx)(`div`,{className:`conv-actions`,children:e.map(e=>e.panel?(0,D.jsx)(N,{action:e,disabled:t,open:i===e.key,onToggle:()=>a(t=>t===e.key?null:e.key),onClose:()=>a(null)},e.key):(0,D.jsx)(`button`,{type:`button`,className:e.danger?`conv-action conv-action-danger`:`conv-action`,onClick:e.onClick,disabled:t,"aria-busy":e.busy,"aria-label":e.label,title:e.title,children:e.icon},e.key))})}var P=`claude-opus-4-8[1m]`,F=`claude-sonnet-4-6`,I=`claude-haiku-4-5`,L={[P]:`Opus 4.8 (1M context)`,[F]:`Sonnet 4.6`,[I]:`Haiku 4.5`};function me(e){return L[e]??e}var R=[P,F,I];function z(e){return e.replace(/\[1m\]$/,``)}function he(e){return R.find(t=>z(t)===z(e))??e}var ge=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...ge],[...B],[...B];var _e=[P,F,I],V={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},H=ge.map(e=>({value:e,label:V[e]??e})),ve={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},U=B.map(e=>({value:e,label:ve[e]??e}));function W(e){if(e){let t=_e.find(t=>z(t)===z(e));if(t)return t}return P}function ye({row:e,adminFetch:t,onError:n}){let[r,i]=(0,E.useState)(()=>W(e.model)),[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(!1),d=(0,E.useRef)(!1);(0,E.useEffect)(()=>{i(W(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,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Model`}),(0,D.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:_e.map(e=>(0,D.jsx)(`option`,{value:e,children:me(e)},e))})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Mode`}),(0,D.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Effort`}),(0,D.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),U.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void f(),children:l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}var be=[`whatsapp`,`telegram`];function xe(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 G(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function Se(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ce({target:e,onConfirm:t,onCancel:n}){return e?(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:`Delete this conversation?`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,D.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,D.jsx)(A,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,D.jsx)(A,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var we=`auth-refresh-failed`;function Te({error:e,onClose:t}){if(!e)return null;let n=e.reason===we,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,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:r}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,D.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ee(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,E.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,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,D.jsx)(`span`,{children:`Claude Code`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,D.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:p>0?G(p):`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:xe(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.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 Se(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var De=`https://claude.ai/code`,Oe=200,ke=[500,1e3,1500,2e3,2500,3e3,3e3];function Ae(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:`${De}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function je(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Me(e){let{businessName:r,cacheKey:c,role:l,userName:u,userAvatar:h,onSelectProjects:ee,onSelectPeople:te,onSelectTasks:v,onSelectAgents:y,onCloseMobileDrawer:O,collapsed:k,selectedWhatsappId:A,onSelectWhatsappConversation:j,initialWhatsappSurface:ce=!1}=e,M=ne(c),le=(0,E.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,D.jsx)(oe,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,D.jsx)(ye,{row:e,adminFetch:M,onError:e=>H({message:e,failed:!0})})}),[M]),ue=d.productName,de=typeof u==`string`?u:u===null?`name unavailable`:r||ue,fe=(de.trim().charAt(0)||`?`).toUpperCase(),[N,P]=(0,E.useState)(ce?`whatsapp`:`sessions`),[F,I]=(0,E.useState)([]),[L,me]=(0,E.useState)(!1),[R,z]=(0,E.useState)(null),[he,ge]=(0,E.useState)(!1),[B,_e]=(0,E.useState)(`file`),[V,H]=(0,E.useState)(null),[ve,U]=(0,E.useState)(null),[W,xe]=(0,E.useState)([]),[G,Se]=(0,E.useState)(!1),[we,Ee]=(0,E.useState)(null),[De,Me]=(0,E.useState)(!1),[K,Ie]=(0,E.useState)(!1),[q,Le]=(0,E.useState)(!1),[Re,ze]=(0,E.useState)(null),[J,Be]=(0,E.useState)([]),[Y,Ve]=(0,E.useState)(null),[He,Ue]=(0,E.useState)(new Set),[We,Ge]=(0,E.useState)(null),[Ke,qe]=(0,E.useState)(new Set),[Je,Ye]=(0,E.useState)(new Set),[Xe,Ze]=(0,E.useState)(new Set),[Qe,$e]=(0,E.useState)(null),[et,X]=(0,E.useState)(``),[tt,nt]=(0,E.useState)(!1),[Z,rt]=(0,E.useState)(!1),it=(0,E.useRef)(null),at=(0,E.useRef)(0),[ot,st]=(0,E.useState)(0);(0,E.useEffect)(()=>{let e=it.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;st(e=>Math.abs(e-t)<1?e:t)});return t.observe(e),()=>t.disconnect()},[N]);let ct=ot>0&&ot<400,[lt,ut]=(0,E.useState)([]),[dt,ft]=(0,E.useState)(!1),[pt,mt]=(0,E.useState)(null),[ht,gt]=(0,E.useState)(`whatsapp`),_t=(0,E.useCallback)(e=>{if(O(),!c){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),H({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),H({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),f(c,e.downloadPath,e.downloadRoot??`data`),H({message:`Downloading ${e.name}`,failed:!1})},[c,O]);(0,E.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>H(null),2500);return()=>clearTimeout(e)},[V]);let vt=(0,E.useCallback)(async()=>{if(c){ge(!0),z(null);try{let e=await M(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);I((await e.json()).artefacts??[]),me(!0)}catch(e){let t=e instanceof Error?e.message:String(e);z(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{ge(!1)}}},[c,M]),Q=(0,E.useCallback)(async()=>{if(!c)return null;let e=++at.current;Me(!0),Ee(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===at.current?(xe(r),ze(n.accountId??null),Be(n.accounts??[]),Ve(e=>e??n.accountId??null),Se(!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===at.current&&Ee(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===at.current&&Me(!1)}},[c,M]),yt=(0,E.useCallback)(async()=>{if(c){mt(null);try{let e=await M(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);ut((await e.json()).conversations??[]),ft(!0)}catch(e){let t=e instanceof Error?e.message:String(e);mt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[c,M]);(0,E.useEffect)(()=>{!c||G||Q()},[c,G,Q]),(0,E.useEffect)(()=>{if(!c)return;let e=null;return yt(),e=setInterval(()=>{yt()},Ne),()=>{e!==null&&clearInterval(e)}},[c,yt]),(0,E.useEffect)(()=>{if(!c)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Pe))}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)}},[c,Q]);let bt=(0,E.useMemo)(()=>{let e=new Map;for(let t of be)e.set(t,[]);for(let t of lt)e.get(t.channel)?.push(t);for(let t of be)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[lt]),xt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},St=()=>{j(null),P(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${L?F.length:0} collapsed=${k}`),vt()},$=1.5,Ct=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),vt()},wt=()=>{j(null),P(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${G?W.length:0} collapsed=${k}`),G||Q()},Tt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Et=e=>{P(`whatsapp`),gt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${bt.get(e)?.length??0} collapsed=${k}`)},Dt=(0,E.useCallback)(async e=>{if(Ke.has(e.sessionId))return;qe(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=Ae(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`?(O(),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}`),U(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}`),U({sessionId:e.sessionId,reason:r})}finally{qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,O,Ke]),Ot=(0,E.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=ke.length;n++){await new Promise(e=>setTimeout(e,ke[n-1]));let r=await Q();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}`)},[Q]),kt=(0,E.useCallback)(async()=>{if(!Z){rt(!0);try{let e=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(J.length>1&&Y?{targetAccountId:Y}:{})}),t=await e.json().catch(()=>({})),n=Ae(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?Ot(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),U(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),U({sessionId:null,reason:t})}finally{rt(!1)}}},[M,Z,Ot,Y,J]),At=(0,E.useCallback)((e,t)=>{e.stopPropagation(),Ge(t)},[]),jt=(0,E.useCallback)(async e=>{if(!He.has(e.sessionId)){Ue(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(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),H({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),xe(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),H({message:`Delete failed: ${n}`,failed:!0})}finally{Ue(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[M,He,Q]),Mt=(0,E.useCallback)(async(e,t)=>{if(e.stopPropagation(),!Je.has(t.sessionId)){Ye(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`}`),H({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),H({message:`Stop failed: ${n}`,failed:!0})}finally{Ye(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,Je,Q]),Nt=(0,E.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Xe.has(t.sessionId)){Ze(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`}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}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}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Ze(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,Xe,Q]),Pt=(0,E.useCallback)(async e=>{let t=et.trim();if(!t){H({message:`Title can’t be empty`,failed:!0});return}if(t.length>Oe){H({message:`Title too long (max ${Oe})`,failed:!0});return}nt(!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}`),H({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),$e(null),X(``),Q()}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}`),H({message:`Rename failed: ${n}`,failed:!0})}finally{nt(!1)}},[M,et,Q]);return(0,D.jsxs)(`aside`,{className:`side`,children:[(0,D.jsx)(`div`,{className:`side-new-session-row`,children:(0,D.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:kt,disabled:Z,"aria-busy":Z,children:[(0,D.jsx)(ae,{size:14}),(0,D.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,D.jsxs)(`nav`,{className:`side-nav`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),te(),O()},children:[(0,D.jsx)(T,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`People`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),y(),O()},children:[(0,D.jsx)(x,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Agents`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),ee(),O()},children:[(0,D.jsx)(S,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:t().term}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),v(),O()},children:[(0,D.jsx)(C,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`artefacts`?` active`:``}`,onClick:St,children:[(0,D.jsx)(a,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`sessions`?` active`:``}`,onClick:wt,children:[(0,D.jsx)(ie,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,D.jsx)(`span`,{className:`kbd`})]}),dt&&be.filter(e=>bt.get(e).length>0).map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${N===`whatsapp`&&ht===e?` active`:``}`,onClick:()=>Et(e),children:[(0,D.jsx)(m,{channel:e,size:16}),(0,D.jsx)(`span`,{className:`label`,children:xt[e]}),(0,D.jsx)(`span`,{className:`kbd`})]},e)),pt&&(0,D.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,D.jsx)(`span`,{className:`label`,children:pt})})]}),N===`artefacts`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Artefacts`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Ct,disabled:he,children:(0,D.jsx)(o,{size:12,className:he?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:he?`…`:String(F.length)})]})]}),R&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),L&&!R&&F.length>0&&(()=>{let e=F.filter(e=>e.kind===`agent-template`).length,t=F.length-e;return(0,D.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:F.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${B===e.key?` active`:``}`,onClick:()=>_e(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,D.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),L&&!R&&F.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),F.filter(e=>B===`all`?!0:B===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?x:a,r=je(e.updatedAt),o=e.downloadPath!==null;return(0,D.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>_t(e),disabled:!o,style:o?void 0:{cursor:`default`},title:o?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,D.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsx)(`span`,{className:`conv-name-line`,children:(0,D.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),o&&(0,D.jsx)(i,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),N===`sessions`&&(()=>{let e=J.find(e=>e.isHouse)?.accountId??Re,t=J.length>1,r=W.filter(e=>K?!0:!e.isSubagent).filter(e=>q?!0:!e.archived).filter(n=>!t||!Y?!0:(n.accountId??e)===Y),i=W.some(e=>e.isSubagent),a=W.some(e=>e.archived);return(0,D.jsxs)(`div`,{className:`side-list`,ref:it,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Sessions`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Tt,disabled:De,children:(0,D.jsx)(o,{size:12,className:De?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:De?`…`:String(r.length)})]})]}),t&&(0,D.jsxs)(`div`,{className:`side-account-switcher`,children:[(0,D.jsx)(T,{size:12,"aria-hidden":`true`}),(0,D.jsx)(`select`,{"aria-label":`Active account`,title:`The active account. A new session spawns under it, and the list below is scoped to it.`,value:Y??``,onChange:e=>Ve(e.target.value||null),children:J.map(e=>(0,D.jsxs)(`option`,{value:e.accountId,children:[e.businessName||(e.isHouse?`House`:`Client`),` · `,e.accountId.slice(0,8)]},e.accountId))})]}),Re&&(0,D.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,D.jsx)(`code`,{children:Re})}),(i||a)&&(0,D.jsxs)(`div`,{className:`artefact-filter-chips`,children:[i&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ie(e=>!e),title:K?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),a&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${q?` active`:``}`,"aria-pressed":q,onClick:()=>Le(e=>!e),title:q?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),we&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:we}),G&&!we&&r.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),r.map(e=>{let t=je(e.startedAt),r=Ke.has(e.sessionId),i=He.has(e.sessionId),a=Je.has(e.sessionId),o=Xe.has(e.sessionId),c=r||i||a||o,l=[{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,D.jsx)(s,{size:12}),busy:r,onClick:()=>{Dt(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,D.jsx)(w,{size:12}),onClick:()=>{window.location.assign(`/chat?session=${e.sessionId}`)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,D.jsx)(se,{size:12}),busy:a,onClick:t=>{Mt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,D.jsx)(b,{size:12}),busy:o,onClick:t=>{Nt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,D.jsx)(re,{size:12}),busy:o,onClick:t=>{Nt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,D.jsx)(g,{size:12}),busy:tt&&Qe===e.sessionId,onClick:t=>{t.stopPropagation(),$e(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,D.jsx)(n,{size:12}),danger:!0,busy:i,onClick:t=>{At(t,e)}},le({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,D.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,D.jsxs)(`div`,{className:`conv-main-static`,children:[(0,D.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,D.jsx)(p,{channel:e.channel,size:13}),Qe===e.sessionId?(0,D.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:et,disabled:tt,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Pt(e)):t.key===`Escape`&&(t.preventDefault(),$e(null),X(``))},onBlur:()=>{Qe===e.sessionId&&!tt&&($e(null),X(``))}}):(0,D.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,D.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,D.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,D.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,D.jsx)(pe,{actions:l,disabled:c,collapsed:ct})]},e.sessionId)})]})})(),N===`whatsapp`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:xt[ht]}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{yt()},children:(0,D.jsx)(o,{size:12})}),(0,D.jsx)(`span`,{children:String(bt.get(ht).length)})]})]}),bt.get(ht).map(e=>{let t=je(e.lastMessageAt);return(0,D.jsxs)(`div`,{className:`conv conv-with-actions${A===e.sessionId?` active`:``}`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{j(e),O()},title:e.title,children:[(0,D.jsx)(m,{channel:e.channel,size:14}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[(0,D.jsx)(`span`,{className:`conv-name`,children:_(e)}),e.role===`public`&&(0,D.jsx)(`span`,{className:`conv-tag conv-tag-public`,children:`Public`})]}),t&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),(0,D.jsx)(pe,{actions:[le({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1,collapsed:ct})]},e.sessionId)})]}),(0,D.jsx)(Fe,{}),(0,D.jsxs)(`div`,{className:`side-foot`,children:[(0,D.jsx)(`div`,{className:`avatar`,children:h?(0,D.jsx)(`img`,{src:h,alt:de}):fe}),(0,D.jsxs)(`div`,{className:`who`,children:[(0,D.jsx)(`span`,{className:`name`,children:de}),(0,D.jsx)(`span`,{className:`role`,children:l??`operator`})]})]}),V&&(0,D.jsx)(`div`,{className:`copy-toast${V.failed?` copy-toast-failed`:``}`,role:`status`,children:V.message}),(0,D.jsx)(Te,{error:ve,onClose:()=>U(null)}),(0,D.jsx)(Ce,{target:We,onCancel:()=>Ge(null),onConfirm:()=>{let e=We;Ge(null),e&&jt(e)}})]})}var K=5e3,Ne=3e4,Pe=3e4;function Fe(){let[e,t]=(0,E.useState)(null);if((0,E.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()},K))}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=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,D.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var Ie=`admin-sidebar-collapsed`,q=`admin-sidebar-drawer-open`;function Le(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ie)===`1`}catch{return!1}}function Re(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ie,`1`):window.sessionStorage.removeItem(Ie)}catch{}}function ze(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}}function J(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(q,`1`):window.sessionStorage.removeItem(q)}catch{}}var Be=720;function Y(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function Ve(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`projectDir`);return!r||!i?null:{sessionId:r,projectDir:i,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`admin`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null}}function He(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function Ue(e){let{cacheKey:n,businessName:r,variant:i=`admin`,onLogout:a,onDisconnect:o,disconnecting:s,userName:c,userAvatar:l,role:d,onOpenConversations:f,children:p,footer:m}=e,[h,g]=(0,E.useState)(()=>Le()),[_,te]=(0,E.useState)(()=>ze()),[ne,v]=(0,E.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${Be}px)`).matches),[y,b]=(0,E.useState)(()=>typeof window>`u`?null:Ve(window.location.pathname,window.location.search)),[re]=(0,E.useState)(()=>y!==null);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${Be}px)`),t=e=>v(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let x=(0,E.useCallback)(e=>{Re(e),g(e)},[]),S=(0,E.useCallback)(e=>{J(e),te(e)},[]);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${i} sidebar=${i===`operator`?`none`:`present`} collapsed=${h} drawer=${_}`)},[]),(0,E.useEffect)(()=>{typeof window>`u`||!y||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${y.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]);let ie=(0,E.useCallback)(e=>{if(e===null){b(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Y(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?b(e):window.location.href=n.href},[]),C=ne?_:!h,w=(0,E.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Be}px)`).matches){let e=_;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),S(!e)}else{let e=h;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),x(!e)}},[h,_,x,S]),ae=(0,E.useCallback)(e=>{let t=He(e,i);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[i]),[oe,se]=(0,E.useState)(`chat`),[T,O]=(0,E.useState)([]);(0,E.useEffect)(()=>{if(i!==`operator`||!n)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(n)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||O(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[i,n]);let k=(0,E.useMemo)(()=>[...new Set(T.map(e=>e.channel))],[T]),A={collapsed:h,mobileDrawerOpen:_,sidebarOpen:C,onToggleSidebar:w,setMobileDrawerOpen:S,selectedWhatsapp:y,onClearWhatsapp:()=>b(null)};return i===`operator`?(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(u,{businessName:r,variant:i,onNavigate:ae,conversationsCount:T.length,conversationsChannels:k,onOpenConversations:()=>se(`conversations`),onToggleSidebar:w,sidebarOpen:C,onLogout:a,onDisconnect:o,disconnecting:s,cacheKey:n}),(0,D.jsx)(`div`,{className:`platform platform-operator`,children:oe===`conversations`?(0,D.jsx)(ee,{conversations:T,sessionKey:n??``,onBack:()=>se(`chat`)}):typeof p==`function`?p(A):p}),m]}):(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(u,{businessName:r,variant:i,onNavigate:ae,onOpenConversations:f,onToggleSidebar:w,sidebarOpen:C,onLogout:a,onDisconnect:o,disconnecting:s,cacheKey:n}),(0,D.jsxs)(`div`,{className:`platform${_?` menu-open`:``}${h?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,D.jsx)(Me,{businessName:r,cacheKey:n,role:d??null,userName:c,userAvatar:l??null,onSelectProjects:()=>{window.location.href=`/graph?label=${t().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>S(!1),collapsed:h,mobileDrawerOpen:_,selectedWhatsappId:y?.sessionId??null,onSelectWhatsappConversation:ie,initialWhatsappSurface:re}),!ne&&(0,D.jsx)(ue,{}),typeof p==`function`?p(A):p]}),_&&(0,D.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>S(!1)}),m]})}export{re as _,I as a,he as c,T as d,se as f,x as g,C as h,Se as i,me as l,ae as m,Ae as n,P as o,oe as p,Ee as r,F as s,Ue as t,A as u,b as v,y};
|