@rubytech/create-maxy-code 0.1.373 → 0.1.375

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/__tests__/cgroup-memory-controller-install-flow.test.js +41 -0
  2. package/dist/__tests__/cgroup-memory-controller.test.js +32 -0
  3. package/dist/cgroup-memory-controller.js +33 -0
  4. package/dist/index.js +54 -0
  5. package/package.json +1 -1
  6. package/payload/platform/neo4j/schema.cypher +9 -4
  7. package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
  8. package/payload/platform/plugins/admin/PLUGIN.md +7 -1
  9. package/payload/platform/plugins/admin/mcp/dist/index.js +43 -8
  10. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  11. package/payload/platform/plugins/admin/mcp/dist/tools/__tests__/account-lifecycle.test.js +50 -2
  12. package/payload/platform/plugins/admin/mcp/dist/tools/__tests__/account-lifecycle.test.js.map +1 -1
  13. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +17 -0
  14. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
  15. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +40 -1
  16. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
  17. package/payload/platform/plugins/scheduling/mcp/dist/index.js +1 -4
  18. package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
  19. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js +18 -36
  20. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js.map +1 -1
  21. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/ics-graph-ingest.test.d.ts +2 -0
  22. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/ics-graph-ingest.test.d.ts.map +1 -0
  23. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/ics-graph-ingest.test.js +153 -0
  24. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/ics-graph-ingest.test.js.map +1 -0
  25. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/meeting-write.test.js +11 -19
  26. package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/meeting-write.test.js.map +1 -1
  27. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts +0 -2
  28. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts.map +1 -1
  29. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js +10 -17
  30. package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js.map +1 -1
  31. package/payload/platform/plugins/scheduling/mcp/dist/lib/ics-graph-ingest.d.ts +13 -7
  32. package/payload/platform/plugins/scheduling/mcp/dist/lib/ics-graph-ingest.d.ts.map +1 -1
  33. package/payload/platform/plugins/scheduling/mcp/dist/lib/ics-graph-ingest.js +38 -33
  34. package/payload/platform/plugins/scheduling/mcp/dist/lib/ics-graph-ingest.js.map +1 -1
  35. package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.d.ts.map +1 -1
  36. package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.js +13 -19
  37. package/payload/platform/plugins/scheduling/mcp/dist/lib/meeting-write.js.map +1 -1
  38. package/payload/platform/plugins/whatsapp/PLUGIN.md +6 -4
  39. package/payload/platform/plugins/whatsapp/mcp/dist/index.js +31 -15
  40. package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
  41. package/payload/platform/scripts/migrate-whatsapp-to-disk.mjs +115 -0
  42. package/payload/platform/scripts/rss-sampler.sh +18 -2
  43. package/payload/platform/scripts/seed-neo4j.sh +17 -0
  44. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  45. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +2 -0
  46. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  47. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  48. package/payload/platform/services/claude-session-manager/dist/http-server.js +34 -14
  49. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  50. package/payload/platform/services/claude-session-manager/dist/index.js +2 -2
  51. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  52. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts +19 -0
  53. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts.map +1 -1
  54. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js +42 -0
  55. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js.map +1 -1
  56. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +1 -1
  57. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  58. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +1 -1
  59. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  60. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts +10 -1
  61. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts.map +1 -1
  62. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +25 -1
  63. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
  64. package/payload/platform/services/claude-session-manager/dist/session-cap-audit.d.ts +75 -4
  65. package/payload/platform/services/claude-session-manager/dist/session-cap-audit.d.ts.map +1 -1
  66. package/payload/platform/services/claude-session-manager/dist/session-cap-audit.js +138 -15
  67. package/payload/platform/services/claude-session-manager/dist/session-cap-audit.js.map +1 -1
  68. package/payload/server/public/assets/AdminLoginScreens-3vFueaZy.js +1 -0
  69. package/payload/server/public/assets/AdminShell-DvczcTdp.js +1 -0
  70. package/payload/server/public/assets/{Checkbox-BagcrE4Q.js → Checkbox-KbEWQEVU.js} +1 -1
  71. package/payload/server/public/assets/{admin-CodAEpgQ.js → admin-Cm1tZXbf.js} +1 -1
  72. package/payload/server/public/assets/{browser-CRTlI7ck.js → browser-C38YYs28.js} +1 -1
  73. package/payload/server/public/assets/{calendar-BBEivUAw.js → calendar-CCN9px9o.js} +1 -1
  74. package/payload/server/public/assets/chat-fj5J5aKV.js +1 -0
  75. package/payload/server/public/assets/data-D1EXeX7P.js +1 -0
  76. package/payload/server/public/assets/{graph-HoHcI7qv.js → graph-DGXKuRbL.js} +3 -3
  77. package/payload/server/public/assets/{graph-labels-BJfK0tbH.js → graph-labels-DYRDEL2l.js} +1 -1
  78. package/payload/server/public/assets/{operator-5wtImBoF.js → operator-Bhtayf9U.js} +1 -1
  79. package/payload/server/public/assets/{page-CzTgPTp3.js → page-BSMtFFmx.js} +5 -5
  80. package/payload/server/public/assets/{public-CUopv7Ro.js → public-DO_OqjJa.js} +1 -1
  81. package/payload/server/public/assets/{rotate-ccw-DttFB1nY.js → rotate-ccw-DQfsmjLr.js} +1 -1
  82. package/payload/server/public/assets/useSubAccountSwitcher-CSCcvysa.css +1 -0
  83. package/payload/server/public/assets/useSubAccountSwitcher-z8xhukFw.js +9 -0
  84. package/payload/server/public/browser.html +4 -4
  85. package/payload/server/public/calendar.html +4 -4
  86. package/payload/server/public/chat.html +6 -6
  87. package/payload/server/public/data.html +4 -4
  88. package/payload/server/public/graph.html +7 -7
  89. package/payload/server/public/index.html +6 -6
  90. package/payload/server/public/operator.html +8 -8
  91. package/payload/server/public/public.html +6 -6
  92. package/payload/server/server.js +1169 -964
  93. package/payload/server/public/assets/AdminLoginScreens-CGTA9noi.js +0 -1
  94. package/payload/server/public/assets/AdminShell-CNwb23_A.js +0 -1
  95. package/payload/server/public/assets/OperatorConversations-BX9t3jgm.css +0 -1
  96. package/payload/server/public/assets/OperatorConversations-CivR0bnD.js +0 -9
  97. package/payload/server/public/assets/chat-r1qKuzHk.js +0 -1
  98. package/payload/server/public/assets/data-BkY0bFYS.js +0 -1
@@ -61,17 +61,72 @@ export function parseOomKilledScopes(stdout) {
61
61
  }
62
62
  return out;
63
63
  }
64
+ /** Global (system-wide, non-cgroup) kernel OOM-kill lines from `journalctl
65
+ * -k` (the kernel ring — distinct from the `--user` journal
66
+ * pollJournalKills reads). Matches the classic
67
+ * `Killed process <pid> (<comm>) ... anon-rss:<n>kB` summary line every
68
+ * Linux OOM report emits, converts anon-rss from kB to bytes. Returns every
69
+ * match in the blob, in order — the caller filters to pids it actually
70
+ * tracks. */
71
+ export function parseKernelOomVictims(stdout) {
72
+ const out = [];
73
+ const re = /Killed process (\d+) \([^)]+\).*?anon-rss:(\d+)kB/;
74
+ for (const line of stdout.split('\n')) {
75
+ const m = re.exec(line);
76
+ if (!m)
77
+ continue;
78
+ out.push({ pid: Number(m[1]), rssBytes: Number(m[2]) * 1024 });
79
+ }
80
+ return out;
81
+ }
82
+ export function formatOomVictim(f) {
83
+ return `[claude-session] op=oom-victim sessionId=${f.sessionId} pid=${f.pid} rss=${f.rssBytes}`;
84
+ }
64
85
  export function formatCapKill(f) {
65
86
  return `${TAG} op=cap-killed source=memory-events sessionId=${f.sessionId} scope=${f.scope} oomKills=${f.oomKills} memCurrentMb=${f.memCurrentMb}`;
66
87
  }
67
88
  export function formatCapKillFromJournal(f) {
68
89
  return `${TAG} op=cap-killed source=journal sessionId=${f.sessionId ?? 'unknown'} scope=${f.scope}`;
69
90
  }
70
- /** `systemctl --user show <unit> -p ControlGroup --value` -> cgroup path
71
- * (e.g. /user.slice/.../claude-ptys.slice/<unit>). Empty on failure. */
72
- function readControlGroup(run, unit) {
73
- const r = run(['--user', 'show', unit, '-p', 'ControlGroup', '--value']);
74
- return r.exitCode === 0 ? r.stdout.trim() : '';
91
+ /** True only when the unit's `ActiveState` is actually `active`. Any other
92
+ * state (inactive, failed, activating, not-found) is "the manager believes
93
+ * this session is alive but its scope is not there" — the Task 1297
94
+ * reconciliation this exists for. */
95
+ export function isScopeActive(activeState) {
96
+ return activeState === 'active';
97
+ }
98
+ export function formatScopeMissing(f) {
99
+ return `${TAG} op=scope-missing sessionId=${f.sessionId} scope=${f.scope} state=${f.state}`;
100
+ }
101
+ /** Logs `op=scope-missing` at most once per unit until it becomes active
102
+ * again (the same event-log dedup convention as `capKillLogged`/
103
+ * `oomVictimLogged`) — an unbounded per-tick re-log would defeat the
104
+ * task's own goal of a clean, attributable signal. Clearing the entry on
105
+ * recovery means a later loss is re-logged, not permanently suppressed. */
106
+ export function checkScopeMissing(f) {
107
+ if (isScopeActive(f.activeState)) {
108
+ f.scopeMissingLogged.delete(f.scope);
109
+ return;
110
+ }
111
+ if (f.scopeMissingLogged.has(f.scope))
112
+ return;
113
+ f.scopeMissingLogged.add(f.scope);
114
+ f.logger(formatScopeMissing({ sessionId: f.sessionId, scope: f.scope, state: f.activeState || 'unknown' }));
115
+ }
116
+ /** `systemctl --user show <unit> -p ActiveState -p ControlGroup` (key=value
117
+ * lines, order-independent) -> both values in one systemctl call. Task
118
+ * 1297 originally issued a separate `is-active` call per live session per
119
+ * tick alongside this one; merged here so the reconciliation check and the
120
+ * cap-kill check share a single spawn per session per tick instead of two. */
121
+ export function parseScopeStatus(result) {
122
+ if (result.exitCode !== 0)
123
+ return { activeState: '', controlGroup: '' };
124
+ const activeState = result.stdout.match(/^ActiveState=(.*)$/m)?.[1]?.trim() ?? '';
125
+ const controlGroup = result.stdout.match(/^ControlGroup=(.*)$/m)?.[1]?.trim() ?? '';
126
+ return { activeState, controlGroup };
127
+ }
128
+ function readScopeStatus(run, unit) {
129
+ return parseScopeStatus(run(['--user', 'show', unit, '-p', 'ActiveState', '-p', 'ControlGroup']));
75
130
  }
76
131
  function readCgroupFileNumber(cgroup, file) {
77
132
  try {
@@ -121,13 +176,50 @@ export function pollJournalKills(deps) {
121
176
  }
122
177
  deps.state.lastSinceMs = deps.nowMs - deps.marginMs;
123
178
  }
124
- /** Drop `capKillLogged` entries older than `ttlTicks` so the map stays
125
- * bounded. A reported scope's journal line falls out of the `--since`
126
- * window within ~1 interval, so it can never reappear after the ttl. */
179
+ /** One kernel-journal poll, folded into the same audit tick as
180
+ * pollJournalKills. A global (system-wide) OOM kill is invisible to the
181
+ * memory.events/scope-failure paths above the kernel picks a victim
182
+ * outside any cgroup ceiling, so those never fire. This is the correlation
183
+ * Task 1297's incident review found completely missing: the killed pid
184
+ * could not be tied to a session from any available journal field. Scoped
185
+ * to pids the manager actually tracks (a monitored session's PTY leader) —
186
+ * a global OOM victim outside that set (neo4j, the brand server, an
187
+ * untracked process) is not this module's concern and is not logged. */
188
+ export function pollKernelOomVictims(deps) {
189
+ const sinceMs = deps.state.lastSinceMs ?? deps.nowMs;
190
+ const sinceSec = Math.floor(sinceMs / 1000);
191
+ const r = deps.run(['-k', '--since', `@${sinceSec}`, '--no-pager', '--output=cat']);
192
+ if (r.exitCode !== 0) {
193
+ deps.logger(`[claude-session] op=kernel-journal-read-failed exitCode=${r.exitCode} stderr=${r.stderr.trim()}`);
194
+ return;
195
+ }
196
+ for (const victim of parseKernelOomVictims(r.stdout)) {
197
+ if (deps.oomVictimLogged.has(victim.pid))
198
+ continue;
199
+ const sessionId = deps.resolveSessionId(victim.pid);
200
+ if (!sessionId)
201
+ continue;
202
+ deps.logger(formatOomVictim({ sessionId, pid: victim.pid, rssBytes: victim.rssBytes }));
203
+ deps.oomVictimLogged.set(victim.pid, deps.tickIndex);
204
+ }
205
+ deps.state.lastSinceMs = deps.nowMs - deps.marginMs;
206
+ }
207
+ /** Drop `capKillLogged` (or the Task 1297 `oomVictimLogged`) entries older
208
+ * than `ttlTicks` so the map stays bounded. A reported scope/pid's journal
209
+ * line falls out of the `--since` window within ~1 interval, so it can
210
+ * never reappear after the ttl. */
127
211
  export function pruneCapKillLogged(map, tickIndex, ttlTicks) {
128
- for (const [unit, t] of map)
212
+ for (const [key, t] of map)
129
213
  if (tickIndex - t > ttlTicks)
130
- map.delete(unit);
214
+ map.delete(key);
215
+ }
216
+ /** Same TTL-prune rule as pruneCapKillLogged, generalized to a map whose
217
+ * value is a record carrying the last-seen tick rather than a bare number
218
+ * (unitToSessionId, pidToSessionId) — `getTick` extracts it. */
219
+ export function pruneByLastSeen(map, tickIndex, ttlTicks, getTick) {
220
+ for (const [key, v] of map)
221
+ if (tickIndex - getTick(v) > ttlTicks)
222
+ map.delete(key);
131
223
  }
132
224
  export function createSessionCapAudit(deps) {
133
225
  const run = deps.runSystemctl ?? defaultSystemctlRunner;
@@ -145,6 +237,15 @@ export function createSessionCapAudit(deps) {
145
237
  // scope that dies between ticks is still resolvable on the next journal read.
146
238
  const unitToSessionId = new Map();
147
239
  const journalState = { lastSinceMs: null };
240
+ // Task 1297 — pid -> {sessionId, lastSeenTick} for the manager's own
241
+ // tracked PTY leaders, and the pids a global OOM-victim line has already
242
+ // been logged for. Same shape/TTL pattern as unitToSessionId/capKillLogged.
243
+ const pidToSessionId = new Map();
244
+ const oomVictimLogged = new Map();
245
+ const kernelJournalState = { lastSinceMs: null };
246
+ // Task 1297 — units a scope-missing line has already been logged for,
247
+ // cleared once the scope is active again so a later loss re-logs.
248
+ const scopeMissingLogged = new Set();
148
249
  let tickIndex = 0;
149
250
  let timer = null;
150
251
  function tickOnce() {
@@ -159,7 +260,16 @@ export function createSessionCapAudit(deps) {
159
260
  const unit = scopeUnitName(t.scopeUnitToken);
160
261
  seen.add(unit);
161
262
  unitToSessionId.set(unit, { sessionId: t.sessionId, lastSeenTick: tickIndex });
162
- const cgroup = readControlGroup(run, unit);
263
+ pidToSessionId.set(t.pid, { sessionId: t.sessionId, lastSeenTick: tickIndex });
264
+ const status = readScopeStatus(run, unit);
265
+ checkScopeMissing({
266
+ activeState: status.activeState,
267
+ sessionId: t.sessionId,
268
+ scope: unit,
269
+ scopeMissingLogged,
270
+ logger: deps.logger,
271
+ });
272
+ const cgroup = status.controlGroup;
163
273
  if (!cgroup)
164
274
  return;
165
275
  const oomKills = readMemoryEventsOomKill(cgroup);
@@ -179,6 +289,9 @@ export function createSessionCapAudit(deps) {
179
289
  for (const unit of prior.keys())
180
290
  if (!seen.has(unit))
181
291
  prior.delete(unit);
292
+ for (const unit of scopeMissingLogged)
293
+ if (!seen.has(unit))
294
+ scopeMissingLogged.delete(unit);
182
295
  // Second source: the durable journal record of whole-scope teardowns,
183
296
  // de-duped against what the memory.events read above already logged.
184
297
  pollJournalKills({
@@ -191,11 +304,20 @@ export function createSessionCapAudit(deps) {
191
304
  state: journalState,
192
305
  logger: deps.logger,
193
306
  });
307
+ pollKernelOomVictims({
308
+ run: runJournalctl,
309
+ nowMs,
310
+ marginMs: JOURNAL_SINCE_MARGIN_MS,
311
+ tickIndex,
312
+ oomVictimLogged,
313
+ resolveSessionId: (pid) => pidToSessionId.get(pid)?.sessionId,
314
+ state: kernelJournalState,
315
+ logger: deps.logger,
316
+ });
194
317
  pruneCapKillLogged(capKillLogged, tickIndex, CAP_KILL_TTL_TICKS);
195
- for (const [unit, v] of unitToSessionId) {
196
- if (tickIndex - v.lastSeenTick > CAP_KILL_TTL_TICKS)
197
- unitToSessionId.delete(unit);
198
- }
318
+ pruneCapKillLogged(oomVictimLogged, tickIndex, CAP_KILL_TTL_TICKS);
319
+ pruneByLastSeen(unitToSessionId, tickIndex, CAP_KILL_TTL_TICKS, (v) => v.lastSeenTick);
320
+ pruneByLastSeen(pidToSessionId, tickIndex, CAP_KILL_TTL_TICKS, (v) => v.lastSeenTick);
199
321
  }
200
322
  return {
201
323
  tickOnce,
@@ -205,6 +327,7 @@ export function createSessionCapAudit(deps) {
205
327
  // Seed the journal window at start so the first tick captures the full
206
328
  // first interval without backfilling kills from before the audit ran.
207
329
  journalState.lastSinceMs = now();
330
+ kernelJournalState.lastSinceMs = now();
208
331
  timer = setInterval(() => {
209
332
  try {
210
333
  tickOnce();
@@ -1 +1 @@
1
- {"version":3,"file":"session-cap-audit.js","sourceRoot":"","sources":["../src/session-cap-audit.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,sEAAsE;AACtE,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AACxE,EAAE;AACF,4EAA4E;AAC5E,2EA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K,CAAC,CAAC;gBAAC,KAAK,GAAG,IAAI,CAAA;YAAC,CAAC;QACnD,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{H as t,K as n,L as r,V as i,z as a}from"./useSubAccountSwitcher-z8xhukFw.js";import{i as o}from"./admin-types-DJoj6VJv.js";import{v as s,y as c}from"./AdminShell-DvczcTdp.js";import{t as l}from"./Checkbox-KbEWQEVU.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(n(),1);function m(e=`admin`){let[n,r]=(0,p.useState)(`loading`),[i,a]=(0,p.useState)(``),[s,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let G=(0,p.useRef)(null),K=(0,p.useRef)(null);(0,p.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 n=await t.json();D(n.session_key),z(n.sessionId??null),j(n.businessName),N(n.role??null),F(n.userName===void 0?null:n.userName),L(n.avatar??null);let i=o(n.thinkingView);return H.current=i,V(i),r(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(n=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(n>0)return await new Promise(e=>setTimeout(e,1500)),t(n-1);console.error(`[admin] health check returned ${i.status} after retries`),r(`set-pin`);return}let a=await i.json();if(!a.pin_configured){r(`set-pin`);return}if(!a.claude_authenticated){r(`connect-claude`);return}if(await e())return;r(`enter-pin`)}catch(e){if(n>0)return await new Promise(e=>setTimeout(e,1500)),t(n-1);console.error(`[admin] health check failed:`,e),r(`set-pin`)}}t()},[]),(0,p.useEffect)(()=>{n===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[n]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let t=!1;try{t=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:n,alreadyRedirected:t,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[n,e]);let q=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(n!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();if(t.auth_status===`dead`||t.auth_status===`missing`){r(`connect-claude`);return}}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let n=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(n===`remote-auth-required`){t(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${n}`),q.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[n,E]),(0,p.useEffect)(()=>{n===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&r(`enter-pin`)}).catch(()=>{})},[n]);async function J(e,n){y(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...n?{accountId:n}:{}})});if(!i.ok){let e=await i.json().catch(()=>({}));if(i.status===401&&e?.code===`remote-auth-required`){t(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await i.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);if(H.current=c,V(c),n)try{sessionStorage.setItem(`maxy-account-id`,n)}catch{}try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),r(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Y=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let n=s.trim();if(!n){h(`Please enter your name.`);return}if(i.length<4){h(`PIN must be at least 4 characters.`);return}let o=i;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:n})});if(!e.ok){let n=await e.json().catch(()=>({}));if(e.status===401&&n?.code===`remote-auth-required`){t(`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 t=await e.json();t.pin_configured&&t.claude_authenticated?r(`enter-pin`):t.pin_configured?r(`connect-claude`):h(n.error||`Failed to set PIN.`)}else r(`enter-pin`)}catch{r(`enter-pin`)}return}h(n.error||`Failed to set PIN.`);return}let i=await fetch(`/api/health`);if((i.ok?await i.json():null)?.claude_authenticated){await J(o);return}a(``),r(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[i,v,s]),X=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await J(i)},[i]),Z=(0,p.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(u)}catch{}return r(`connect-claude`),!0}finally{T(!1)}},[]),Q=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(`maxy-account-id`),sessionStorage.removeItem(u)}catch{}a(``),h(``),r(`enter-pin`)},[]);return(0,p.useEffect)(()=>{q.current=Q},[Q]),{appState:n,setAppState:r,pin:i,setPin:a,operatorName:s,setOperatorName:l,pinError:m,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,pinInputRef:G,setPinFormRef:K,handleSetPin:Y,handleLogin:X,handleDisconnect:Z,handleLogout:Q}}var h=i();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.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,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.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 _(e){let{pin:t,setPin:n,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,r.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,r.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:i}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!t||!m.trim(),loading:c,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:t,setPin:n,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:r.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!t,loading:c,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:t,setAuthPolling:n,authLoading:i,setAuthLoading:o,pinError:c,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1);async function _(){g(!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.`)}g(!1)}async function v(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){n(!0),f(!0),o(!1);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.`)}o(!1)}async function y(){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,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.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,h.jsx)(`button`,{onClick:y,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,h.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,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.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,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(s,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:c})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:a,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:r.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,r.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(s,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.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,h.jsx)(`button`,{onClick:_,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{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,h.jsx)(y,{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,h.jsx)(v,{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{m as n,b as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,E as i,G as a,I as o,K as s,L as c,M as l,N as u,O as d,T as f,V as p,_ as m,g as h,j as g,m as ee,n as te,t as ne,v as re,x as _,y as ie}from"./useSubAccountSwitcher-z8xhukFw.js";async function v(){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 y=e(s(),1),b=p(),x={sm:14,md:16,lg:18},ae={sm:30,md:38,lg:46};function S({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=x[t],h={...e===`send`?{width:ae[t],height:ae[t]}:{},...u},g=Object.keys(h).length>0;return(0,b.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,b.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,b.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,b.jsx)(n,{size:m})]}),i&&(0,b.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var oe=o(`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`}]]),C=o(`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`}]]),w=o(`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`}]]),se=o(`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`}]]),ce=o(`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`}]]),T=o(`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`}]]),le=o(`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`}]]),E=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),D=o(`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`}]]),ue=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),de=o(`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`}]]),O=`maxy-shell-side-px`;function k(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function A(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-k());return Math.min(Math.max(e,248),n)}function fe(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(O);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 A(t)}catch{}return 264}function pe({targetSelector:e=`.platform`}){let t=(0,y.useRef)(null),[n,r]=(0,y.useState)(()=>fe()),i=(0,y.useRef)(n);(0,y.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,y.useCallback)(()=>{r(e=>{let t=A(e);return t===e?e:t})},[]);(0,y.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(A(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(O,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=A(264);r(e);try{window.localStorage.removeItem(O)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,b.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var j=a();function M({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,y.useRef)(null),[s,c]=(0,y.useState)({position:`fixed`,visibility:`hidden`}),l=(0,y.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,y.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,y.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,j.createPortal)((0,b.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,y.useRef)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.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,b.jsx)(M,{anchorRef:a,onClose:i,className:e.panelClassName,role:`dialog`,ariaLabel:e.label,children:e.panel()})]})}function me({actions:e,disabled:t,collapsed:n}){let[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),u=(0,y.useRef)(null);(0,y.useEffect)(()=>{i(null),o(!1),c(null)},[n]);let d=(0,y.useCallback)(()=>{o(!1),c(null)},[]);return n?(0,b.jsxs)(`div`,{className:`conv-actions`,children:[(0,b.jsx)(`button`,{ref:u,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>o(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`Session actions`,title:`Session actions`,children:(0,b.jsx)(l,{size:12})}),a&&(0,b.jsx)(M,{anchorRef:u,onClose:d,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,b.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,b.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":s===e.key,disabled:t,onClick:()=>c(t=>t===e.key?null:e.key),children:[e.icon,(0,b.jsx)(`span`,{children:e.menuLabel})]}),s===e.key&&(0,b.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,b.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,b.jsx)(`span`,{children:e.menuLabel})]},e.key))})]}):(0,b.jsx)(`div`,{className:`conv-actions`,children:e.map(e=>e.panel?(0,b.jsx)(N,{action:e,disabled:t,open:r===e.key,onToggle:()=>i(t=>t===e.key?null:e.key),onClose:()=>i(null)},e.key):(0,b.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-5`,I=`claude-haiku-4-5`,he={[P]:`Opus 4.8 (1M context)`,[F]:`Sonnet 5`,[I]:`Haiku 4.5`};function L(e){return he[e]??e}var ge=[P,F,I];function R(e){return e.replace(/\[1m\]$/,``)}function _e(e){return ge.find(t=>R(t)===R(e))??e}var z=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],ve=[`low`,`medium`,`high`,`xhigh`];[...z],[...ve],[...ve];var B=[P,F,I],V={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},ye=z.map(e=>({value:e,label:V[e]??e})),H={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},U=ve.map(e=>({value:e,label:H[e]??e}));function be(e){if(e){let t=B.find(t=>R(t)===R(e));if(t)return t}return P}function xe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,y.useState)(()=>be(e.model)),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(!1),f=(0,y.useRef)(!1);(0,y.useEffect)(()=>{i(be(e.model))},[e.model]);let p=async()=>{if(!f.current){f.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}`),f.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`),f.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)}`),f.current=!1,u(!1)}}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Model`}),(0,b.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:B.map(e=>(0,b.jsx)(`option`,{value:e,children:L(e)},e))})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Mode`}),(0,b.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),ye.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsxs)(`label`,{className:`reseat-field`,children:[(0,b.jsx)(`span`,{children:`Effort`}),(0,b.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Keep current`}),U.map(e=>(0,b.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,b.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void p(),children:l?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}var Se=[`whatsapp`,`telegram`];function W(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 Ce(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function G(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 we({target:e,onConfirm:t,onCancel:n}){return e?(0,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:`Delete this conversation?`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.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,b.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,b.jsx)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,b.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var Te=`auth-refresh-failed`;function Ee({error:e,onClose:t}){if(!e)return null;let n=e.reason===Te,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,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`span`,{children:r}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,b.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function De(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,y.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,ee=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,b.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,b.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`claude-info-header`,children:[(0,b.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,b.jsx)(`span`,{children:`Claude Code`}),(0,b.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,b.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,b.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,b.jsxs)(`div`,{className:`claude-info-section`,children:[(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:p>0?Ce(p):`—`})]}),(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.jsx)(`span`,{className:`claude-info-value`,children:W(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,b.jsxs)(`div`,{className:`claude-info-row`,children:[(0,b.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,b.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 G(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var Oe=`https://claude.ai/code`,ke=200,Ae=[500,1e3,1500,2e3,2500,3e3,3e3];function je(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:`${Oe}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Me(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function K(e){let{businessName:a,cacheKey:o,role:s,userName:l,userAvatar:d,onSelectProjects:p,onSelectPeople:te,onSelectTasks:ne,onSelectAgents:ie,onCloseMobileDrawer:v,collapsed:x,selectedWhatsappId:ae,onSelectWhatsappConversation:S,initialWhatsappSurface:O=!1}=e,k=_(o),A=(0,y.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,b.jsx)(D,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,b.jsx)(xe,{row:e,adminFetch:k,onError:e=>V({message:e,failed:!0})})}),[k]),fe=c.productName,pe=typeof l==`string`?l:l===null?`name unavailable`:a||fe,j=(pe.trim().charAt(0)||`?`).toUpperCase(),[M,N]=(0,y.useState)(O?`whatsapp`:`sessions`),[P,F]=(0,y.useState)([]),[I,he]=(0,y.useState)(!1),[L,ge]=(0,y.useState)(null),[R,_e]=(0,y.useState)(!1),[z,ve]=(0,y.useState)(`file`),[B,V]=(0,y.useState)(null),[ye,H]=(0,y.useState)(null),[U,be]=(0,y.useState)([]),[W,Ce]=(0,y.useState)(!1),[G,Te]=(0,y.useState)(null),[De,Oe]=(0,y.useState)(!1),[K,Ne]=(0,y.useState)(!1),[q,Le]=(0,y.useState)(!1),[Re,ze]=(0,y.useState)(null),[Be,Ve]=(0,y.useState)(new Set),[J,He]=(0,y.useState)(null),[Ue,We]=(0,y.useState)(new Set),[Ge,Ke]=(0,y.useState)(new Set),[qe,Je]=(0,y.useState)(new Set),[Ye,Xe]=(0,y.useState)(null),[Ze,Y]=(0,y.useState)(``),[Qe,$e]=(0,y.useState)(!1),[X,et]=(0,y.useState)(!1),tt=(0,y.useRef)(null),Z=(0,y.useRef)(0),[nt,rt]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=tt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;rt(e=>Math.abs(e-t)<1?e:t)});return t.observe(e),()=>t.disconnect()},[M]);let it=nt>0&&nt<400,[at,ot]=(0,y.useState)([]),[st,ct]=(0,y.useState)(!1),[lt,ut]=(0,y.useState)(null),[dt,ft]=(0,y.useState)(`whatsapp`),pt=(0,y.useCallback)(e=>{if(v(),!o){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),V({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`),V({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}`),ee(o,e.downloadPath,e.downloadRoot??`data`),V({message:`Downloading ${e.name}`,failed:!1})},[o,v]);(0,y.useEffect)(()=>{if(!B)return;let e=setTimeout(()=>V(null),2500);return()=>clearTimeout(e)},[B]);let mt=(0,y.useCallback)(async()=>{if(o){_e(!0),ge(null);try{let e=await k(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);F((await e.json()).artefacts??[]),he(!0)}catch(e){let t=e instanceof Error?e.message:String(e);ge(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{_e(!1)}}},[o,k]),Q=(0,y.useCallback)(async()=>{if(!o)return null;let e=++Z.current;Oe(!0),Te(null);try{let t=await k(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Z.current?(be(r),ze(n.accountId??null),Ce(!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===Z.current&&Te(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Z.current&&Oe(!1)}},[o,k]),ht=(0,y.useCallback)(async()=>{if(o){ut(null);try{let e=await k(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);ot((await e.json()).conversations??[]),ct(!0)}catch(e){let t=e instanceof Error?e.message:String(e);ut(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[o,k]);(0,y.useEffect)(()=>{!o||W||Q()},[o,W,Q]),(0,y.useEffect)(()=>{if(!o)return;let e=null;return ht(),e=setInterval(()=>{ht()},Pe),()=>{e!==null&&clearInterval(e)}},[o,ht]),(0,y.useEffect)(()=>{if(!o)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Fe))}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,Q]);let gt=(0,y.useMemo)(()=>{let e=new Map;for(let t of Se)e.set(t,[]);for(let t of at)e.get(t.channel)?.push(t);for(let t of Se)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[at]),_t={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},vt=()=>{S(null),N(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${I?P.length:0} collapsed=${x}`),mt()},$=1.5,yt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),mt()},bt=()=>{S(null),N(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${W?U.length:0} collapsed=${x}`),W||Q()},xt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},St=e=>{N(`whatsapp`),ft(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${gt.get(e)?.length??0} collapsed=${x}`)},Ct=(0,y.useCallback)(async e=>{if(Ue.has(e.sessionId))return;We(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await k(`/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=je(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`?(v(),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}`),H(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}`),H({sessionId:e.sessionId,reason:r})}finally{We(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[k,v,Ue]),wt=(0,y.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Ae.length;n++){await new Promise(e=>setTimeout(e,Ae[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]),Tt=(0,y.useCallback)(async()=>{if(!X){et(!0);try{let e=await k(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=je(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?wt(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}`),H(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),H({sessionId:null,reason:t})}finally{et(!1)}}},[k,X,wt]),Et=(0,y.useCallback)((e,t)=>{e.stopPropagation(),He(t)},[]),Dt=(0,y.useCallback)(async e=>{if(!Be.has(e.sessionId)){Ve(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await k(`/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`}`),V({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??`?`}`),be(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}`),V({message:`Delete failed: ${n}`,failed:!0})}finally{Ve(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[k,Be,Q]),Ot=(0,y.useCallback)(async(e,t)=>{if(e.stopPropagation(),!Ge.has(t.sessionId)){Ke(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await k(`/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`}`),V({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}`),V({message:`Stop failed: ${n}`,failed:!0})}finally{Ke(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[k,Ge,Q]),kt=(0,y.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!qe.has(t.sessionId)){Je(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await k(`/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`}`),V({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}`),V({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Je(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[k,qe,Q]),At=(0,y.useCallback)(async e=>{let t=Ze.trim();if(!t){V({message:`Title can’t be empty`,failed:!0});return}if(t.length>ke){V({message:`Title too long (max ${ke})`,failed:!0});return}$e(!0);try{let n=await k(`/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}`),V({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),Xe(null),Y(``),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}`),V({message:`Rename failed: ${n}`,failed:!0})}finally{$e(!1)}},[k,Ze,Q]);return(0,b.jsxs)(`aside`,{className:`side`,children:[(0,b.jsx)(`div`,{className:`side-new-session-row`,children:(0,b.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Tt,disabled:X,"aria-busy":X,children:[(0,b.jsx)(E,{size:14}),(0,b.jsx)(`span`,{children:X?`Spawning…`:`New session`})]})}),(0,b.jsxs)(`nav`,{className:`side-nav`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),te(),v()},children:[(0,b.jsx)(de,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`People`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ie(),v()},children:[(0,b.jsx)(w,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Agents`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),p(),v()},children:[(0,b.jsx)(se,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:n().term}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),ne(),v()},children:[(0,b.jsx)(T,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`artefacts`?` active`:``}`,onClick:vt,children:[(0,b.jsx)(t,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,b.jsx)(`span`,{className:`kbd`})]}),(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`sessions`?` active`:``}`,onClick:bt,children:[(0,b.jsx)(ce,{size:20,strokeWidth:$}),(0,b.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,b.jsx)(`span`,{className:`kbd`})]}),st&&Se.filter(e=>gt.get(e).length>0).map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`nav-row${M===`whatsapp`&&dt===e?` active`:``}`,onClick:()=>St(e),children:[(0,b.jsx)(m,{channel:e,size:16}),(0,b.jsx)(`span`,{className:`label`,children:_t[e]}),(0,b.jsx)(`span`,{className:`kbd`})]},e)),lt&&(0,b.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,b.jsx)(`span`,{className:`label`,children:lt})})]}),M===`artefacts`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Artefacts`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:yt,disabled:R,children:(0,b.jsx)(f,{size:12,className:R?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:R?`…`:String(P.length)})]})]}),L&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:L}),I&&!L&&P.length>0&&(()=>{let e=P.filter(e=>e.kind===`agent-template`).length,t=P.length-e;return(0,b.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:P.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${z===e.key?` active`:``}`,onClick:()=>ve(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,b.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),I&&!L&&P.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),P.filter(e=>z===`all`?!0:z===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let n=e.kind===`agent-template`,r=n?w:t,i=Me(e.updatedAt),a=e.downloadPath!==null;return(0,b.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>pt(e),disabled:!a,style:a?void 0:{cursor:`default`},title:a?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,b.jsx)(r,{size:14,className:`conv-icon`,"data-kind":n?`agent`:`file`,"aria-label":n?`agent template`:`file`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsx)(`span`,{className:`conv-name-line`,children:(0,b.jsx)(`span`,{className:`conv-name`,children:e.name})}),i&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:i})]}),a&&(0,b.jsx)(u,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),M===`sessions`&&(()=>{let e=U.filter(e=>K?!0:!e.isSubagent).filter(e=>q?!0:!e.archived),t=U.some(e=>e.isSubagent),n=U.some(e=>e.archived);return(0,b.jsxs)(`div`,{className:`side-list`,ref:tt,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:`Sessions`}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:xt,disabled:De,children:(0,b.jsx)(f,{size:12,className:De?`spinning`:void 0})}),(0,b.jsx)(`span`,{children:De?`…`:String(e.length)})]})]}),Re&&(0,b.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,b.jsx)(`code`,{children:Re})}),(t||n)&&(0,b.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,b.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ne(e=>!e),title:K?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,b.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`})]}),G&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:G}),W&&!G&&e.length===0&&(0,b.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Me(e.startedAt),n=Ue.has(e.sessionId),a=Be.has(e.sessionId),o=Ge.has(e.sessionId),s=qe.has(e.sessionId),c=n||a||o||s,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,b.jsx)(g,{size:12}),busy:n,onClick:()=>{Ct(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,b.jsx)(le,{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,b.jsx)(ue,{size:12}),busy:o,onClick:t=>{Ot(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,b.jsx)(oe,{size:12}),busy:s,onClick:t=>{kt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,b.jsx)(C,{size:12}),busy:s,onClick:t=>{kt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,b.jsx)(i,{size:12}),busy:Qe&&Ye===e.sessionId,onClick:t=>{t.stopPropagation(),Xe(e.sessionId),Y(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,b.jsx)(r,{size:12}),danger:!0,busy:a,onClick:t=>{Et(t,e)}},A({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,b.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,b.jsxs)(`div`,{className:`conv-main-static`,children:[(0,b.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,b.jsx)(re,{channel:e.channel,size:13}),Ye===e.sessionId?(0,b.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:Ze,disabled:Qe,"aria-label":`New title for session ${e.title}`,onChange:e=>Y(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),At(e)):t.key===`Escape`&&(t.preventDefault(),Xe(null),Y(``))},onBlur:()=>{Ye===e.sessionId&&!Qe&&(Xe(null),Y(``))}}):(0,b.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,b.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,b.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,b.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,b.jsx)(me,{actions:l,disabled:c,collapsed:it})]},e.sessionId)})]})})(),M===`whatsapp`&&(0,b.jsxs)(`div`,{className:`side-list`,children:[(0,b.jsxs)(`div`,{className:`group-head`,children:[(0,b.jsx)(`span`,{children:_t[dt]}),(0,b.jsxs)(`span`,{className:`group-head-meta`,children:[(0,b.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{ht()},children:(0,b.jsx)(f,{size:12})}),(0,b.jsx)(`span`,{children:String(gt.get(dt).length)})]})]}),gt.get(dt).map(e=>{let t=Me(e.lastMessageAt);return(0,b.jsxs)(`div`,{className:`conv conv-with-actions${ae===e.sessionId?` active`:``}`,children:[(0,b.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{S(e),v()},title:e.title,children:[(0,b.jsx)(m,{channel:e.channel,size:14}),(0,b.jsxs)(`span`,{className:`conv-stack`,children:[(0,b.jsxs)(`span`,{className:`conv-name-line`,children:[(0,b.jsx)(`span`,{className:`conv-name`,children:h(e)}),e.role===`public`&&(0,b.jsx)(`span`,{className:`conv-tag conv-tag-public`,children:`Public`})]}),t&&(0,b.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),(0,b.jsx)(me,{actions:[A({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1,collapsed:it})]},e.sessionId)})]}),(0,b.jsx)(Ie,{}),(0,b.jsxs)(`div`,{className:`side-foot`,children:[(0,b.jsx)(`div`,{className:`avatar`,children:d?(0,b.jsx)(`img`,{src:d,alt:pe}):j}),(0,b.jsxs)(`div`,{className:`who`,children:[(0,b.jsx)(`span`,{className:`name`,children:pe}),(0,b.jsx)(`span`,{className:`role`,children:s??`operator`})]})]}),B&&(0,b.jsx)(`div`,{className:`copy-toast${B.failed?` copy-toast-failed`:``}`,role:`status`,children:B.message}),(0,b.jsx)(Ee,{error:ye,onClose:()=>H(null)}),(0,b.jsx)(we,{target:J,onCancel:()=>He(null),onConfirm:()=>{let e=J;He(null),e&&Dt(e)}})]})}var Ne=5e3,Pe=3e4,Fe=3e4;function Ie(){let[e,t]=(0,y.useState)(null);if((0,y.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()},Ne))}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,b.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,b.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,b.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,b.jsx)(`div`,{className:`system-stats__bar`,children:(0,b.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var q=`admin-sidebar-collapsed`,Le=`admin-sidebar-drawer-open`;function Re(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}}function ze(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(q,`1`):window.sessionStorage.removeItem(q)}catch{}}function Be(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Le)===`1`}catch{return!1}}function Ve(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Le,`1`):window.sessionStorage.removeItem(Le)}catch{}}var J=720;function He(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function Ue(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,rowType:`session`}}function We(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function Ge(e){let{cacheKey:t,businessName:r,conversationLabel:i,variant:a=`admin`,onLogout:o,onDisconnect:s,disconnecting:c,userName:l,userAvatar:u,role:d,onOpenConversations:f,children:p,footer:m}=e,{subAccounts:h,activeAccountId:g,switching:ee,switchAccount:re}=ne(t),[_,v]=(0,y.useState)(()=>Re()),[x,ae]=(0,y.useState)(()=>Be()),[S,oe]=(0,y.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${J}px)`).matches),[C,w]=(0,y.useState)(()=>typeof window>`u`?null:Ue(window.location.pathname,window.location.search)),[se]=(0,y.useState)(()=>C!==null);(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${J}px)`),t=e=>oe(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let ce=(0,y.useCallback)(e=>{ze(e),v(e)},[]),T=(0,y.useCallback)(e=>{Ve(e),ae(e)},[]);(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${a} sidebar=${a===`operator`?`none`:`present`} collapsed=${_} drawer=${x}`)},[]),(0,y.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${C.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]);let le=(0,y.useCallback)(e=>{if(e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=He(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),E=S?x:!_,D=(0,y.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${J}px)`).matches){let e=x;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),T(!e)}else{let e=_;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),ce(!e)}},[_,x,ce,T]),ue=(0,y.useCallback)(e=>{let t=We(e,a);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[a]),[de,O]=(0,y.useState)(`chat`),[k,A]=(0,y.useState)([]);(0,y.useEffect)(()=>{if(a!==`operator`||!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}&includePersistedOnly=1`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||A(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[a,t]);let fe=(0,y.useMemo)(()=>[...new Set(k.map(e=>e.channel))],[k]),j={collapsed:_,mobileDrawerOpen:x,sidebarOpen:E,onToggleSidebar:D,setMobileDrawerOpen:T,selectedWhatsapp:C,onClearWhatsapp:()=>w(null)};return a===`operator`?(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(ie,{businessName:r,conversationLabel:i,variant:a,onNavigate:ue,conversationsCount:k.length,conversationsChannels:fe,onOpenConversations:()=>O(`conversations`),onToggleSidebar:D,sidebarOpen:E,onLogout:o,onDisconnect:s,disconnecting:c,cacheKey:t}),(0,b.jsx)(`div`,{className:`platform platform-operator`,children:de===`conversations`?(0,b.jsx)(te,{conversations:k,sessionKey:t??``,onBack:()=>O(`chat`)}):typeof p==`function`?p(j):p}),m]}):(0,b.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,b.jsx)(ie,{businessName:r,conversationLabel:i,variant:a,onNavigate:ue,onOpenConversations:f,onToggleSidebar:D,sidebarOpen:E,onLogout:o,onDisconnect:s,disconnecting:c,cacheKey:t,subAccounts:h,activeAccountId:g,switchingAccount:ee,onSwitchAccount:re}),(0,b.jsxs)(`div`,{className:`platform${x?` menu-open`:``}${_?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,b.jsx)(K,{businessName:r,cacheKey:t,role:d??null,userName:l,userAvatar:u??null,onSelectProjects:()=>{window.location.href=`/graph?label=${n().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>T(!1),collapsed:_,mobileDrawerOpen:x,selectedWhatsappId:C?.sessionId??null,onSelectWhatsappConversation:le,initialWhatsappSurface:se}),!S&&(0,b.jsx)(pe,{}),typeof p==`function`?p(j):p]}),x&&(0,b.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>T(!1)}),m]})}export{oe as _,I as a,_e as c,ue as d,D as f,C as g,w as h,G as i,L as l,T as m,je as n,P as o,E as p,De as r,F as s,Ge as t,de as u,S as v,v as y};
@@ -1 +1 @@
1
- import{T as e}from"./OperatorConversations-CivR0bnD.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
1
+ import{V as e}from"./useSubAccountSwitcher-z8xhukFw.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{G as t,T as n,U as r,a as i,y as a}from"./OperatorConversations-CivR0bnD.js";import{n as o,t as s}from"./AdminLoginScreens-CGTA9noi.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-CNwb23_A.js";import"./Checkbox-BagcrE4Q.js";var u=r(),d=e(t(),1),f=n();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=o(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,f.jsx)(a,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:r}),(0,f.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(i,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(s,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{K as t,V as n,W as r,b as i,o as a}from"./useSubAccountSwitcher-z8xhukFw.js";import{n as o,t as s}from"./AdminLoginScreens-3vFueaZy.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-DvczcTdp.js";import"./Checkbox-KbEWQEVU.js";var u=r(),d=e(t(),1),f=n();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=o(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,f.jsx)(i,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:r}),(0,f.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(a,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(s,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{B as t,F as n,G as r,M as i,N as a,T as o,U as s,b as c,x as l,y as u}from"./OperatorConversations-CivR0bnD.js";import{t as d,y as f}from"./AdminShell-CNwb23_A.js";var p=t(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=s(),h=e(r(),1),g=o(),_=`maxy-vnc-popout`;function v(){let[e,t]=(0,h.useState)(null),[r,o]=(0,h.useState)(!1),[s,u]=(0,h.useState)(null),d=c(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(n=>{e||(console.info(`[browser-page] op=viewer-probe available=${n.ok}`),t(n.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),t(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(l.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{o(!0),u(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(i,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:r,children:[r?(0,g.jsx)(i,{size:14,className:`spin`}):(0,g.jsx)(a,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(n,{size:14}),` Pop out`]}),s&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:s})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[o,s]=(0,h.useState)(void 0),[c,l]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&s(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(u,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:o,sessionId:c,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(a,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(a,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(i,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{I as t,K as n,L as r,O as i,V as a,W as o,b as s,j as c,k as l,x as u}from"./useSubAccountSwitcher-z8xhukFw.js";import{t as d,y as f}from"./AdminShell-DvczcTdp.js";var p=t(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=o(),h=e(n(),1),g=a(),_=`maxy-vnc-popout`;function v(){let[e,t]=(0,h.useState)(null),[n,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(null),d=u(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(n=>{e||(console.info(`[browser-page] op=viewer-probe available=${n.ok}`),t(n.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),t(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(r.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{a(!0),s(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(i,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:n,children:[n?(0,g.jsx)(i,{size:14,className:`spin`}):(0,g.jsx)(l,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(c,{size:14}),` Pop out`]}),o&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:o})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[c,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(s,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:a,sessionId:c,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(l,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(l,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(i,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,D as r,E as i,F as a,G as o,H as s,L as c,M as l,R as u,T as d,U as f,y as p}from"./OperatorConversations-CivR0bnD.js";import{d as m,t as h,y as g}from"./AdminShell-CNwb23_A.js";var _=n(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=n(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=n(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=n(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=n(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),S=n(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),C=f(),w=e(o(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function ee(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=d(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function te({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var z=1440,B=1.8;function V(e){return e.getHours()*60+e.getMinutes()}function H(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function U({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=V(n),o=N(i,e)?V(i):z,s=a/z*100,c=Math.max((o-a)/z*100,B);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:H(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var W=44;function G(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function K({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${W}px`},children:e===0?``:G(e)},e))}),r.map(e=>(0,F.jsx)(U,{day:e,meetings:t,hourHeight:W,onSelect:n},e.toISOString()))]})]})}var q=52;function J(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Y({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${q}px`},children:e===0?``:J(e)},e))}),(0,F.jsx)(U,{day:e,meetings:t,hourHeight:q,onSelect:n})]})]})}var X=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Z(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>Z(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:ee(e).map(e=>{let t=k(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:X.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(Z(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:a,onSaved:o,onDeleted:s}){let u=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,h]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,ee]=(0,w.useState)(e.title??``),[j,M]=(0,w.useState)(ie(e.startsAt)),[N,P]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,w.useState)(e.location??``),[R,te]=(0,w.useState)(e.privateNote??``),[z,B]=(0,w.useState)(``),[V,H]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,a]);let U=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,j,N,I,R,O]),W=(0,w.useCallback)(async()=>{let t=U();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();k(i.meeting),o(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[n,U,e.meetingId,o]),G=(0,w.useCallback)(async()=>{let t=z.trim(),r=V.trim();if(!(!t&&!r)){T(!0),D(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),o(a.meeting),B(``),H(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[n,z,V,e.meetingId,o]),K=(0,w.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),o(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[n,e.meetingId,o]),q=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);s(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[n,e.meetingId,s]),J=(0,w.useCallback)(async t=>{v(!1),T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[n,e.meetingId]),Y=re[e.kind??`meeting`],X=z.trim().length>0||V.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||a()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:Y}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:a,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,F.jsx)(i,{size:16})})]}),!d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(m,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:Y})]})]}),d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:A,onChange:e=>ee(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:C})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>K(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(i,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:z,onChange:e=>B(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:G,disabled:C||!X,"aria-label":`Add attendee`,children:C?(0,F.jsx)(l,{size:13,className:`spin`}):(0,F.jsx)(S,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>te(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:E}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,F.jsx)(t,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>h(!0),disabled:C,children:[(0,F.jsx)(r,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?v(!0):J(!1)},disabled:C,children:[C?(0,F.jsx)(l,{size:14,className:`spin`}):(0,F.jsx)(c,{size:14}),` Download`]})]}),g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>J(!0),disabled:C,children:[C?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>J(!1),disabled:C,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:C,children:`Cancel`})]}),d&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:W,disabled:C,children:[C?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:q,disabled:C,children:[C?(0,F.jsx)(l,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>h(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(void 0),[o,s]=(0,w.useState)(null),[c,u]=(0,w.useState)(void 0),[d,f]=(0,w.useState)(null),[m,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),f(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await g();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(p,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(h,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:c,userAvatar:d,role:m,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(l,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=s({initialCacheKey:e,surface:`calendar`}),[r,i]=(0,w.useState)(`month`),[o,c]=(0,w.useState)(()=>new Date),[d,f]=(0,w.useState)([]),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(null),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&S(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:i}=j(r,o);return m(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();f(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),f([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[r,o,n,t]);let C=(0,w.useCallback)(()=>c(new Date),[]),T=(0,w.useCallback)(()=>c(e=>M(r,e,-1)),[r]),E=(0,w.useCallback)(()=>c(e=>M(r,e,1)),[r]),D=(0,w.useCallback)(e=>{c(e),i(`month`)},[]);(0,w.useEffect)(()=>{b(null)},[r,o]);let O=(0,w.useCallback)(e=>{f(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),k=(0,w.useCallback)(e=>{f(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:C,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Previous`,children:(0,F.jsx)(u,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:E,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(r,o)}),p&&(0,F.jsx)(l,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>i(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(a,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),r===`day`&&(0,F.jsx)(Y,{anchor:o,meetings:d,onSelect:b}),r===`week`&&(0,F.jsx)(K,{anchor:o,meetings:d,onSelect:b}),r===`month`&&(0,F.jsx)(te,{anchor:o,meetings:d,onSelect:b}),r===`year`&&(0,F.jsx)(ne,{anchor:o,meetings:d,onPickMonth:D})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:O,onDeleted:k})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{C as t,E as n,I as r,K as i,N as a,O as o,P as s,S as c,U as l,V as u,W as d,b as f,j as p}from"./useSubAccountSwitcher-z8xhukFw.js";import{t as m,u as h,y as g}from"./AdminShell-DvczcTdp.js";var _=r(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=r(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=r(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=r(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=r(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),S=r(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),C=d(),w=e(i(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function ee(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=u(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function te({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var z=1440,B=1.8;function V(e){return e.getHours()*60+e.getMinutes()}function H(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function U({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=V(n),o=N(i,e)?V(i):z,s=a/z*100,c=Math.max((o-a)/z*100,B);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:H(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var W=44;function G(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function K({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${W}px`},children:e===0?``:G(e)},e))}),r.map(e=>(0,F.jsx)(U,{day:e,meetings:t,hourHeight:W,onSelect:n},e.toISOString()))]})]})}var q=52;function J(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Y({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${q}px`},children:e===0?``:J(e)},e))}),(0,F.jsx)(U,{day:e,meetings:t,hourHeight:q,onSelect:n})]})]})}var X=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Z(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>Z(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:ee(e).map(e=>{let t=k(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:X.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(Z(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:r,onClose:i,onSaved:s,onDeleted:l}){let u=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,ee]=(0,w.useState)(e.title??``),[j,M]=(0,w.useState)(ie(e.startsAt)),[N,P]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,w.useState)(e.location??``),[R,te]=(0,w.useState)(e.privateNote??``),[z,B]=(0,w.useState)(``),[V,H]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,i]);let U=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,j,N,I,R,O]),W=(0,w.useCallback)(async()=>{let t=U();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();k(i.meeting),s(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[r,U,e.meetingId,s]),G=(0,w.useCallback)(async()=>{let t=z.trim(),n=V.trim();if(!(!t&&!n)){T(!0),D(null);try{let i=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:n||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),s(a.meeting),B(``),H(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[r,z,V,e.meetingId,s]),K=(0,w.useCallback)(async t=>{let n=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),s(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[r,e.meetingId,s]),q=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);l(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[r,e.meetingId,l]),J=(0,w.useCallback)(async t=>{v(!1),T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.blob(),a=se(n.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[r,e.meetingId]),Y=re[e.kind??`meeting`],X=z.trim().length>0||V.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||i()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:Y}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,F.jsx)(c,{size:16})})]}),!d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(h,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:Y})]})]}),d&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:A,onChange:e=>ee(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:C})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>K(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(c,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:z,onChange:e=>B(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:G,disabled:C||!X,"aria-label":`Add attendee`,children:C?(0,F.jsx)(o,{size:13,className:`spin`}):(0,F.jsx)(S,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>te(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:E}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,F.jsx)(n,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,F.jsx)(t,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?v(!0):J(!1)},disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):(0,F.jsx)(a,{size:14}),` Download`]})]}),g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>J(!0),disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>J(!1),disabled:C,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:C,children:`Cancel`})]}),d&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:W,disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:q,disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(void 0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(void 0),[d,p]=(0,w.useState)(null),[h,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await g();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(f,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(m,{cacheKey:e,businessName:i,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:d,role:h,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(o,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=l({initialCacheKey:e,surface:`calendar`}),[r,i]=(0,w.useState)(`month`),[a,c]=(0,w.useState)(()=>new Date),[u,d]=(0,w.useState)([]),[f,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(null),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&S(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:i}=j(r,a);return m(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();d(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),d([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[r,a,n,t]);let C=(0,w.useCallback)(()=>c(new Date),[]),T=(0,w.useCallback)(()=>c(e=>M(r,e,-1)),[r]),E=(0,w.useCallback)(()=>c(e=>M(r,e,1)),[r]),D=(0,w.useCallback)(e=>{c(e),i(`month`)},[]);(0,w.useEffect)(()=>{b(null)},[r,a]);let O=(0,w.useCallback)(e=>{d(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),k=(0,w.useCallback)(e=>{d(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:C,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Previous`,children:(0,F.jsx)(s,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:E,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(r,a)}),f&&(0,F.jsx)(o,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>i(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(p,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),r===`day`&&(0,F.jsx)(Y,{anchor:a,meetings:u,onSelect:b}),r===`week`&&(0,F.jsx)(K,{anchor:a,meetings:u,onSelect:b}),r===`month`&&(0,F.jsx)(te,{anchor:a,meetings:u,onSelect:b}),r===`year`&&(0,F.jsx)(ne,{anchor:a,meetings:u,onPickMonth:D})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:O,onDeleted:k})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
@@ -0,0 +1 @@
1
+ import{V as e,W as t}from"./useSubAccountSwitcher-z8xhukFw.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-DvczcTdp.js";import{n}from"./page-BSMtFFmx.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));