@rubytech/create-maxy-code 0.1.537 → 0.1.539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +121 -7
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +12 -0
- package/payload/platform/plugins/docs/PLUGIN.md +2 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +40 -6
- package/payload/platform/plugins/docs/references/channel-wake-and-prompt.md +75 -0
- package/payload/platform/plugins/scheduling/PLUGIN.md +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.js +59 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-get-description.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js +6 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-get.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js +10 -6
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-update.js.map +1 -1
- package/payload/platform/plugins/whatsapp/PLUGIN.md +2 -0
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +17 -2
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +16 -0
- package/payload/platform/plugins/whatsapp/skills/connect-whatsapp/SKILL.md +1 -1
- package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +29 -9
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +15 -2
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.d.ts +31 -0
- package/payload/platform/services/webchat-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/notification.js +31 -1
- package/payload/platform/services/webchat-channel/dist/notification.js.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
- package/payload/platform/services/webchat-channel/dist/server.js +15 -1
- package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/notification.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.d.ts.map +1 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js +5 -1
- package/payload/platform/services/whatsapp-channel/dist/targets.js.map +1 -1
- package/payload/server/{chunk-44Z4ZFYS.js → chunk-S4FIEM3L.js} +62 -10
- package/payload/server/{manager-AJSPM6X2.js → manager-5QV2EAZ2.js} +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-CYFf2awh.js → AdminLoginScreens-BpHnjHp_.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-BpHnjHp_.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-BpHnjHp_.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js +2 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js.br +0 -0
- package/payload/server/public/assets/AdminShell-D24evn4t.js.gz +0 -0
- package/payload/server/public/assets/{activity-BH65sm9Q.js → activity-ZVUTB5uZ.js} +1 -1
- package/payload/server/public/assets/activity-ZVUTB5uZ.js.br +0 -0
- package/payload/server/public/assets/activity-ZVUTB5uZ.js.gz +0 -0
- package/payload/server/public/assets/{admin-CQtEjRGU.js → admin-XJqQz3QJ.js} +1 -1
- package/payload/server/public/assets/admin-XJqQz3QJ.js.br +0 -0
- package/payload/server/public/assets/admin-XJqQz3QJ.js.gz +0 -0
- package/payload/server/public/assets/{agents-CjhOWwl5.js → agents-Dc9SNC9N.js} +1 -1
- package/payload/server/public/assets/agents-Dc9SNC9N.js.br +0 -0
- package/payload/server/public/assets/agents-Dc9SNC9N.js.gz +0 -0
- package/payload/server/public/assets/{browser-DGXpfL99.js → browser-CCedMIga.js} +1 -1
- package/payload/server/public/assets/browser-CCedMIga.js.br +0 -0
- package/payload/server/public/assets/browser-CCedMIga.js.gz +0 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js +1 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js.br +0 -0
- package/payload/server/public/assets/calendar-BDoMLP2j.js.gz +0 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js +1 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js.br +0 -0
- package/payload/server/public/assets/chat-BAhoqTY9.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-NGLHgPjF.js +1 -0
- package/payload/server/public/assets/chevron-right-B4B7OkG8.js +1 -0
- package/payload/server/public/assets/chevron-right-B4B7OkG8.js.br +0 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js +1 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js.br +0 -0
- package/payload/server/public/assets/clock-7IMwxJdH.js.gz +0 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js +1 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js.br +0 -0
- package/payload/server/public/assets/copy-PkR4EFD6.js.gz +0 -0
- package/payload/server/public/assets/data-yQYhw2IR.js +1 -0
- package/payload/server/public/assets/data-yQYhw2IR.js.br +1 -0
- package/payload/server/public/assets/data-yQYhw2IR.js.gz +0 -0
- package/payload/server/public/assets/{file-text-CbQoZfJD.js → file-text-BA9p7TLU.js} +1 -1
- package/payload/server/public/assets/file-text-BA9p7TLU.js.br +0 -0
- package/payload/server/public/assets/file-text-BA9p7TLU.js.gz +0 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js +51 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js.br +0 -0
- package/payload/server/public/assets/graph-C8cQ6Nqf.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-D695CsC9.js → graph-labels-CiK412vE.js} +1 -1
- package/payload/server/public/assets/graph-labels-CiK412vE.js.br +0 -0
- package/payload/server/public/assets/graph-labels-CiK412vE.js.gz +0 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js +1 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js.br +0 -0
- package/payload/server/public/assets/operator-CaQAEUBu.js.gz +0 -0
- package/payload/server/public/assets/page-CpJpyoPS.js +32 -0
- package/payload/server/public/assets/page-CpJpyoPS.js.br +0 -0
- package/payload/server/public/assets/page-CpJpyoPS.js.gz +0 -0
- package/payload/server/public/assets/page-D0ShNyGE.js +1 -0
- package/payload/server/public/assets/page-D0ShNyGE.js.br +0 -0
- package/payload/server/public/assets/page-D0ShNyGE.js.gz +0 -0
- package/payload/server/public/assets/{play-CbRU6q0T.js → play-huZpq9ra.js} +1 -1
- package/payload/server/public/assets/play-huZpq9ra.js.br +0 -0
- package/payload/server/public/assets/play-huZpq9ra.js.gz +0 -0
- package/payload/server/public/assets/{public-CqbKJ-Q3.js → public--8RWWGjF.js} +1 -1
- package/payload/server/public/assets/public--8RWWGjF.js.br +0 -0
- package/payload/server/public/assets/public--8RWWGjF.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-CjliWBou.js → rotate-ccw-g7l4ZSR3.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-g7l4ZSR3.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-g7l4ZSR3.js.gz +0 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js +2 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js.br +0 -0
- package/payload/server/public/assets/routines-DzFcPNMb.js.gz +0 -0
- package/payload/server/public/assets/{skills-ipK9BJFb.js → skills-5vl_Bt9U.js} +1 -1
- package/payload/server/public/assets/skills-5vl_Bt9U.js.br +0 -0
- package/payload/server/public/assets/skills-5vl_Bt9U.js.gz +0 -0
- package/payload/server/public/assets/{tasks-CGcJHQ3X.js → tasks-DQHtJ8Pq.js} +2 -2
- package/payload/server/public/assets/tasks-DQHtJ8Pq.js.br +0 -0
- package/payload/server/public/assets/tasks-DQHtJ8Pq.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-CjsLPsBD.js → triangle-alert-Cy4Z0uFv.js} +1 -1
- package/payload/server/public/assets/triangle-alert-Cy4Z0uFv.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-Cy4Z0uFv.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-umIgCxI_.js → useCopyFeedback-BwK1RhmF.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-BwK1RhmF.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-BwK1RhmF.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js +14 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-C7TtIbR3.js.gz +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css → useSubAccountSwitcher-DCkivCBS.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-DCkivCBS.css.br +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-D8jXV7R5.css.gz → useSubAccountSwitcher-DCkivCBS.css.gz} +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js +2 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DgyAGgmF.js.gz +0 -0
- package/payload/server/public/assets/{wrench-DtfKfR4s.js → wrench-CICORrSc.js} +1 -1
- package/payload/server/public/assets/wrench-CICORrSc.js.br +0 -0
- package/payload/server/public/assets/wrench-CICORrSc.js.gz +0 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +8 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +11 -11
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +6 -6
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +436 -108
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-CYFf2awh.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js +0 -2
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.br +0 -0
- package/payload/server/public/assets/AdminShell-7l3ubYFZ.js.gz +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.br +0 -0
- package/payload/server/public/assets/activity-BH65sm9Q.js.gz +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.br +0 -0
- package/payload/server/public/assets/admin-CQtEjRGU.js.gz +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.br +0 -0
- package/payload/server/public/assets/agents-CjhOWwl5.js.gz +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.br +0 -0
- package/payload/server/public/assets/browser-DGXpfL99.js.gz +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js +0 -1
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.br +0 -0
- package/payload/server/public/assets/calendar-Cu4yjEuX.js.gz +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js +0 -1
- package/payload/server/public/assets/chat-0na4XVZC.js.br +0 -0
- package/payload/server/public/assets/chat-0na4XVZC.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-DHzJobWp.js +0 -1
- package/payload/server/public/assets/chevron-left-DHzJobWp.js.br +0 -0
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js +0 -1
- package/payload/server/public/assets/chevron-right-yg4DMfLT.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js +0 -1
- package/payload/server/public/assets/clock-BIDzihvp.js.br +0 -0
- package/payload/server/public/assets/clock-BIDzihvp.js.gz +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js +0 -1
- package/payload/server/public/assets/data-Ql9qG3YO.js.br +0 -0
- package/payload/server/public/assets/data-Ql9qG3YO.js.gz +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.br +0 -0
- package/payload/server/public/assets/file-text-CbQoZfJD.js.gz +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js +0 -51
- package/payload/server/public/assets/graph-7414Kjn9.js.br +0 -0
- package/payload/server/public/assets/graph-7414Kjn9.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D695CsC9.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js +0 -1
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.br +0 -0
- package/payload/server/public/assets/maximize-2-CD0gTjW_.js.gz +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js +0 -1
- package/payload/server/public/assets/operator-CLw4PZs5.js.br +0 -0
- package/payload/server/public/assets/operator-CLw4PZs5.js.gz +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js +0 -32
- package/payload/server/public/assets/page-BNRFmFc-.js.br +0 -0
- package/payload/server/public/assets/page-BNRFmFc-.js.gz +0 -0
- package/payload/server/public/assets/page-BRr295G2.js +0 -1
- package/payload/server/public/assets/page-BRr295G2.js.br +0 -0
- package/payload/server/public/assets/page-BRr295G2.js.gz +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.br +0 -0
- package/payload/server/public/assets/play-CbRU6q0T.js.gz +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.br +0 -0
- package/payload/server/public/assets/public-CqbKJ-Q3.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-CjliWBou.js.gz +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js +0 -2
- package/payload/server/public/assets/routines-yJuRuBfn.js.br +0 -0
- package/payload/server/public/assets/routines-yJuRuBfn.js.gz +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.br +0 -0
- package/payload/server/public/assets/skills-ipK9BJFb.js.gz +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.br +0 -0
- package/payload/server/public/assets/tasks-CGcJHQ3X.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CjsLPsBD.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-umIgCxI_.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-D8jXV7R5.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js +0 -14
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-UMg53kKF.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js +0 -2
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-tzfqfXni.js.gz +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.br +0 -0
- package/payload/server/public/assets/wrench-DtfKfR4s.js.gz +0 -0
|
@@ -93,7 +93,7 @@ export interface DoorInbound {
|
|
|
93
93
|
text: string;
|
|
94
94
|
messageId: string;
|
|
95
95
|
media: MediaInbound[];
|
|
96
|
-
source?: 'user' | 'schedule';
|
|
96
|
+
source?: 'user' | 'schedule' | 'public-relay';
|
|
97
97
|
standingRules?: string;
|
|
98
98
|
scheduleProvenance?: ScheduleProvenance;
|
|
99
99
|
/** Task 1897 — the message a WhatsApp reply points at. Carried here for the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../src/targets.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvG,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,CAAA;AAEhD,UAAU,cAAc;IAAG,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AACnF,UAAU,aAAa;IAAG,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE;AAC5E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX;qCACiC;IACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC7B;AACD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ;AAMD,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAQ/D;AAED;4EAC4E;AAC5E,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,aAAa,EAAE,CAS9D;AAED,KAAK,SAAS,GAAG,CACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,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kB,CAAA;IACvC;;;yBAGqB;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AA4BD;;;;;sBAKsB;AACtB,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAWnE;AAED;;8DAE8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3D,+EAA+E;IAC/E,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,IAAI,CAAA;CACjD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,WAAW,EAAE,CA+C1D;AAUD,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,GAAG,eAAe,EAAE,CAUlE"}
|
|
@@ -111,7 +111,11 @@ function cryptoRandomId() {
|
|
|
111
111
|
* parseScheduleProvenance), so a shape guard is all that is needed here. */
|
|
112
112
|
function injectedContext(p) {
|
|
113
113
|
return {
|
|
114
|
-
|
|
114
|
+
// Task 2277 — 'public-relay' is admitted alongside the other two. Narrowing
|
|
115
|
+
// it away would drop a platform-authored turn to undefined, which the
|
|
116
|
+
// downstream label reads as 'user': a synthetic relay turn would present as
|
|
117
|
+
// a message the named manager wrote.
|
|
118
|
+
source: p.source === 'user' || p.source === 'schedule' || p.source === 'public-relay' ? p.source : undefined,
|
|
115
119
|
standingRules: typeof p.standingRules === 'string' ? p.standingRules : undefined,
|
|
116
120
|
scheduleProvenance: p.scheduleProvenance !== null && typeof p.scheduleProvenance === 'object'
|
|
117
121
|
? p.scheduleProvenance
|
|
@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,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,eAAe,CAAC,CAA4B,CAAC,EAAE,CAAA;YAC9G,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,gBAAgB,CAAC,GAAc;IAC7C,MAAM,GAAG,GAAsB,EAAE,CAAA;IACjC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,gCAAgC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAA;IAC1J,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,oEAAoE;QACpE,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,gCAAgC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAA;IAC7J,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -29,6 +29,7 @@ var WhatsAppAccountSchema = z.object({
|
|
|
29
29
|
debounceMs: z.number().int().nonnegative().optional().default(2e3).describe("Wait this many milliseconds after the last message before processing, to batch rapid multi-message input into a single agent turn. Default 2000ms catches most multi-message bursts. 0 means process each message immediately."),
|
|
30
30
|
publicAgent: z.string().optional().describe("Slug of the public agent that handles WhatsApp inbound from non-admin phones for this account. Overrides the top-level publicAgent when set."),
|
|
31
31
|
publicAgentEnabled: z.boolean().optional().describe("When true, WhatsApp inbound from non-admin phones for this account is answered by the resolved public agent. When false (the default), a public inbound notifies the account managers and spawns nothing \u2014 the visitor receives no reply. Overrides the top-level publicAgentEnabled when set."),
|
|
32
|
+
managerNotifyEnabled: z.boolean().optional().describe("When true (the default), every WhatsApp message from a public sender to this account is forwarded verbatim to its registered account managers. When false, that raw copy is not sent; the admin relay the same inbound raises, and the translated reply that relay produces, are unaffected. Overrides the top-level managerNotifyEnabled when set. Set with set-manager-notify-enabled."),
|
|
32
33
|
afterHoursMessage: z.string().optional().describe("Auto-reply text sent to public senders when the business is closed (outside opening hours). If not set, messages received outside business hours are silently skipped with no reply."),
|
|
33
34
|
dispatchInbound: z.boolean().optional().describe("When false, this account's WhatsApp socket only observes: inbound is stored and readable but never dispatched to an agent. Default true. Set with set-dispatch-inbound.")
|
|
34
35
|
}).strict().superRefine((value, ctx) => {
|
|
@@ -77,6 +78,7 @@ var WhatsAppConfigSchema = z.object({
|
|
|
77
78
|
debounceMs: z.number().int().nonnegative().optional().default(2e3).describe("Wait this many milliseconds after the last message before processing, to batch rapid multi-message input into a single agent turn. Default 2000ms catches most multi-message bursts. 0 means process each message immediately."),
|
|
78
79
|
publicAgent: z.string().optional().describe("Slug of the public agent that handles WhatsApp inbound from non-admin phones. Per-account overrides take precedence."),
|
|
79
80
|
publicAgentEnabled: z.boolean().optional().describe("Default for whether WhatsApp inbound from non-admin phones is answered by the resolved public agent. False by default. Per-account overrides take precedence."),
|
|
81
|
+
managerNotifyEnabled: z.boolean().optional().describe("The HOUSE's own value for whether a public sender's message is forwarded verbatim to its registered account managers. True by default. A sub-account never inherits this; it reads its own slice or the default."),
|
|
80
82
|
afterHoursMessage: z.string().optional().describe("Default auto-reply text sent to public senders when the business is closed (outside opening hours). Per-account overrides take precedence. If not set, messages received outside business hours are silently skipped.")
|
|
81
83
|
}).strict().superRefine((value, ctx) => {
|
|
82
84
|
if (value.dmPolicy !== "open") return;
|
|
@@ -360,6 +362,21 @@ function classifyCompanionReg(node) {
|
|
|
360
362
|
return { stage, children, parseable: children.includes(PRIMARY_IDENTITY_PUB) };
|
|
361
363
|
}
|
|
362
364
|
|
|
365
|
+
// app/lib/whatsapp/inbound/frame-census.ts
|
|
366
|
+
var WIRE_TAG = "[whatsapp:wire]";
|
|
367
|
+
function recordFrame(counts, frame) {
|
|
368
|
+
if (!frame || typeof frame !== "object" || frame instanceof Uint8Array) return;
|
|
369
|
+
const node = frame;
|
|
370
|
+
if (typeof node.tag !== "string") return;
|
|
371
|
+
const type = node.attrs?.type;
|
|
372
|
+
const key = `${node.tag}/${type === void 0 || type === null ? "none" : String(type)}`;
|
|
373
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
374
|
+
}
|
|
375
|
+
function formatFrameCensusLine(account, counts) {
|
|
376
|
+
const pairs = [...counts.entries()].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0).map(([key, n]) => `${key}=${n}`).join(" ");
|
|
377
|
+
return `${WIRE_TAG} op=frame-census account=${account} ${pairs}`;
|
|
378
|
+
}
|
|
379
|
+
|
|
363
380
|
// app/lib/whatsapp/ingest-ledger.ts
|
|
364
381
|
import { existsSync, mkdirSync, appendFileSync, readFileSync, writeFileSync, readdirSync } from "fs";
|
|
365
382
|
import { join } from "path";
|
|
@@ -619,7 +636,8 @@ function startVersionDriftCensus(intervalMs = CENSUS_INTERVAL_MS) {
|
|
|
619
636
|
|
|
620
637
|
// app/lib/whatsapp/session.ts
|
|
621
638
|
var TAG5 = "[whatsapp:session]";
|
|
622
|
-
var
|
|
639
|
+
var WIRE_TAG2 = "[whatsapp:wire]";
|
|
640
|
+
var FRAME_CENSUS_MS = 6e4;
|
|
623
641
|
console.error(`${TAG5} baileys package loaded version=${BAILEYS_PKG_VERSION}`);
|
|
624
642
|
var __BAILEYS_TAG = "[whatsapp:baileys]";
|
|
625
643
|
var INSPECT_OPTS = {
|
|
@@ -775,6 +793,22 @@ async function createWaSocket(opts) {
|
|
|
775
793
|
markOnlineOnConnect: false,
|
|
776
794
|
fireInitQueries: false
|
|
777
795
|
});
|
|
796
|
+
const frameCounts = /* @__PURE__ */ new Map();
|
|
797
|
+
let lastFrameCensus = "";
|
|
798
|
+
const emitFrameCensus = () => {
|
|
799
|
+
if (frameCounts.size === 0) return;
|
|
800
|
+
const line = formatFrameCensusLine(acct, frameCounts);
|
|
801
|
+
if (line === lastFrameCensus) return;
|
|
802
|
+
lastFrameCensus = line;
|
|
803
|
+
console.error(line);
|
|
804
|
+
};
|
|
805
|
+
const stopFrameCensus = () => {
|
|
806
|
+
emitFrameCensus();
|
|
807
|
+
clearInterval(frameCensusTimer);
|
|
808
|
+
};
|
|
809
|
+
sock.ws.on("frame", (frame) => recordFrame(frameCounts, frame));
|
|
810
|
+
sock.ws.on("close", stopFrameCensus);
|
|
811
|
+
const frameCensusTimer = setInterval(emitFrameCensus, FRAME_CENSUS_MS);
|
|
778
812
|
sock.ev.on("creds.update", () => {
|
|
779
813
|
console.error(`${TAG5} creds.update received \u2014 saving to ${authDir}`);
|
|
780
814
|
enqueueSaveCreds(authDir, saveCreds);
|
|
@@ -819,6 +853,7 @@ async function createWaSocket(opts) {
|
|
|
819
853
|
onQr(update.qr);
|
|
820
854
|
}
|
|
821
855
|
if (update.connection === "close") {
|
|
856
|
+
stopFrameCensus();
|
|
822
857
|
const status = getStatusCode(update.lastDisconnect?.error);
|
|
823
858
|
if (!silent) {
|
|
824
859
|
console.error(
|
|
@@ -845,7 +880,7 @@ async function createWaSocket(opts) {
|
|
|
845
880
|
sock.ws.on("CB:message", (node) => {
|
|
846
881
|
const attrs = node?.attrs ?? {};
|
|
847
882
|
console.error(
|
|
848
|
-
`${
|
|
883
|
+
`${WIRE_TAG2} op=stanza msgId=${attrs.id ?? "none"} from=${attrs.from ?? "none"} type=${attrs.type ?? "none"} offline=${attrs.offline ?? "none"} account=${acct}`
|
|
849
884
|
);
|
|
850
885
|
if (attrs.id) {
|
|
851
886
|
appendStanza({
|
|
@@ -1388,7 +1423,7 @@ import {
|
|
|
1388
1423
|
extractMessageContent as extractMessageContent2,
|
|
1389
1424
|
normalizeMessageContent as normalizeMessageContent2
|
|
1390
1425
|
} from "@whiskeysockets/baileys";
|
|
1391
|
-
var
|
|
1426
|
+
var WIRE_TAG3 = "[whatsapp:wire]";
|
|
1392
1427
|
function formatLiveLocationPayloadLine(msg) {
|
|
1393
1428
|
const content = msg.message ? normalizeMessageContent2(msg.message) : null;
|
|
1394
1429
|
const inner = content ? extractMessageContent2(content) : null;
|
|
@@ -1397,7 +1432,7 @@ function formatLiveLocationPayloadLine(msg) {
|
|
|
1397
1432
|
const num = (v) => v === null || v === void 0 ? "none" : String(v);
|
|
1398
1433
|
const captionBytes = live.caption ? Buffer.byteLength(live.caption, "utf8") : 0;
|
|
1399
1434
|
const thumbBytes = live.jpegThumbnail ? live.jpegThumbnail.length : 0;
|
|
1400
|
-
return `${
|
|
1435
|
+
return `${WIRE_TAG3} op=live-location-payload msgKeyId=${msg.key?.id ?? "none"} seq=${num(live.sequenceNumber)} timeOffsetS=${num(live.timeOffset)} accuracyM=${num(live.accuracyInMeters)} speedMps=${num(live.speedInMps)} headingDeg=${num(live.degreesClockwiseFromMagneticNorth)} captionBytes=${captionBytes} thumbBytes=${thumbBytes} envDurationS=${num(msg.duration)} envFinal=${msg.finalLiveLocation ? "yes" : "no"}`;
|
|
1401
1436
|
}
|
|
1402
1437
|
function liveLocationTargetJid(msg) {
|
|
1403
1438
|
if (msg.key?.fromMe) return null;
|
|
@@ -1407,11 +1442,26 @@ function liveLocationTargetJid(msg) {
|
|
|
1407
1442
|
}
|
|
1408
1443
|
function formatMessageUpdateLine(u) {
|
|
1409
1444
|
const names = u.update ? Object.keys(u.update) : [];
|
|
1410
|
-
return `${
|
|
1445
|
+
return `${WIRE_TAG3} op=message-update msgKeyId=${u.key?.id ?? "none"} fields=${names.length ? names.join(",") : "none"}`;
|
|
1446
|
+
}
|
|
1447
|
+
function formatSubscribeReplyLine(account, jid, reply) {
|
|
1448
|
+
const head = `${WIRE_TAG3} op=live-location-subscribe-reply account=${account} jid=${jid}`;
|
|
1449
|
+
if (!reply || typeof reply !== "object") {
|
|
1450
|
+
return `${head} type=no-reply from=none children=`;
|
|
1451
|
+
}
|
|
1452
|
+
const node = reply;
|
|
1453
|
+
const attrs = node.attrs ?? {};
|
|
1454
|
+
const children = Array.isArray(node.content) ? node.content.map((c) => {
|
|
1455
|
+
const child = c ?? {};
|
|
1456
|
+
const ca = child.attrs ?? {};
|
|
1457
|
+
const pairs = Object.keys(ca).map((k) => `${k}=${String(ca[k])}`).join(",");
|
|
1458
|
+
return `${child.tag ?? "none"}${pairs ? `[${pairs}]` : ""}`;
|
|
1459
|
+
}).join(" ").slice(0, 200) : "";
|
|
1460
|
+
return `${head} type=${attrs.type ?? "none"} from=${attrs.from ?? "none"} children=${children}`;
|
|
1411
1461
|
}
|
|
1412
1462
|
|
|
1413
1463
|
// app/lib/whatsapp/live-location.ts
|
|
1414
|
-
var
|
|
1464
|
+
var WIRE_TAG4 = "[whatsapp:wire]";
|
|
1415
1465
|
var REARM_MS = 3e4;
|
|
1416
1466
|
var SILENCE_MS = 9e4;
|
|
1417
1467
|
var subscriptions = /* @__PURE__ */ new Map();
|
|
@@ -1422,9 +1472,11 @@ function sendEnrolment(sock, account, jid) {
|
|
|
1422
1472
|
attrs: { xmlns: "location", type: "get", to: "s.whatsapp.net", target: jid },
|
|
1423
1473
|
content: [{ tag: "subscribe", attrs: { participants: "true" } }]
|
|
1424
1474
|
};
|
|
1425
|
-
Promise.resolve(sock.query(node)).
|
|
1475
|
+
Promise.resolve(sock.query(node)).then((reply) => {
|
|
1476
|
+
console.error(formatSubscribeReplyLine(account, jid, reply));
|
|
1477
|
+
}).catch((err) => {
|
|
1426
1478
|
console.error(
|
|
1427
|
-
`${
|
|
1479
|
+
`${WIRE_TAG4} op=live-location-subscribe account=${account} jid=${jid} outcome=fail reason=${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`
|
|
1428
1480
|
);
|
|
1429
1481
|
});
|
|
1430
1482
|
}
|
|
@@ -1440,7 +1492,7 @@ function subscribeLiveLocation(sock, account, jid) {
|
|
|
1440
1492
|
if (!sub) return;
|
|
1441
1493
|
if (Date.now() - sub.lastSeenAt >= SILENCE_MS) {
|
|
1442
1494
|
console.error(
|
|
1443
|
-
`${
|
|
1495
|
+
`${WIRE_TAG4} op=live-location-subscribe account=${account} jid=${jid} outcome=stopped reason=silence`
|
|
1444
1496
|
);
|
|
1445
1497
|
stopLiveLocation(account, jid);
|
|
1446
1498
|
return;
|
|
@@ -1449,7 +1501,7 @@ function subscribeLiveLocation(sock, account, jid) {
|
|
|
1449
1501
|
}, REARM_MS);
|
|
1450
1502
|
subscriptions.set(key, { timer, lastSeenAt: Date.now(), account });
|
|
1451
1503
|
console.error(
|
|
1452
|
-
`${
|
|
1504
|
+
`${WIRE_TAG4} op=live-location-subscribe account=${account} jid=${jid} outcome=armed rearmMs=${REARM_MS}`
|
|
1453
1505
|
);
|
|
1454
1506
|
sendEnrolment(sock, account, jid);
|
|
1455
1507
|
}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Activity — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/activity-
|
|
8
|
+
<script type="module" crossorigin src="/assets/activity-ZVUTB5uZ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CltuBf4Z.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/triangle-alert-
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-C7TtIbR3.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-D24evn4t.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/triangle-alert-Cy4Z0uFv.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-DCkivCBS.css">
|
|
14
14
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Agents — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/agents-
|
|
8
|
+
<script type="module" crossorigin src="/assets/agents-Dc9SNC9N.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CltuBf4Z.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
12
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-C7TtIbR3.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-D24evn4t.js">
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-DCkivCBS.css">
|
|
13
13
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/payload/server/public/assets/{AdminLoginScreens-CYFf2awh.js → AdminLoginScreens-BpHnjHp_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,H as n,K as r,W as i,X as a,_ as o}from"./useSubAccountSwitcher-UMg53kKF.js";import{k as s}from"./useVoiceRecorder-tzfqfXni.js";import{D as c,O as l,k as u,m as d}from"./AdminShell-7l3ubYFZ.js";var f=e(a(),1);function p(e=`admin`){let[t,n]=(0,f.useState)(`loading`),[i,a]=(0,f.useState)(``),[o,c]=(0,f.useState)(``),[l,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(void 0),[k,A]=(0,f.useState)(null),[j,M]=(0,f.useState)(void 0),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(void 0),z=(0,f.useRef)(void 0),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!0);(0,f.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&V(!0)}).catch(()=>{})},[]);let W=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();w(r.session_key),I(r.sessionId??null),O(r.businessName),A(r.role??null),M(r.userName===void 0?null:r.userName),P(r.avatar??null);let i=s(r.thinkingView);return z.current=i,R(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}U(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,f.useEffect)(()=>{t===`chat`&&C&&fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(C)}`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&E(e)}).catch(()=>{})},[t,C]);let K=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();U(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(C)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(C)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){r(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),K.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,C]),(0,f.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(U(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function q(e,t){g(!0);try{let i=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!i.ok){let e=await i.json().catch(()=>({}));if(i.status===401&&e?.code===`remote-auth-required`){r(`enter-pin`,`/api/admin/session`);return}d(e.error||`Invalid PIN`);return}let o=await i.json();w(o.session_key),I(o.sessionId??null),O(o.businessName),A(o.role??null),M(o.userName===void 0?null:o.userName),P(o.avatar??null);let c=s(o.thinkingView);z.current=c,R(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}}let J=(0,f.useCallback)(async e=>{if(e.preventDefault(),h)return;d(``);let t=o.trim();if(!t){d(`Please enter your name.`);return}if(i.length<4){d(`PIN must be at least 4 characters.`);return}let s=i;g(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){r(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):d(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}d(t.error||`Failed to set PIN.`);return}let i=await fetch(`/api/health`);if((i.ok?await i.json():null)?.claude_authenticated){await q(s);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}},[i,h,o]),Y=(0,f.useCallback)(async e=>{e.preventDefault(),d(``),await q(i)},[i]),X=(0,f.useCallback)(async()=>{S(!0);try{if(!await u())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;U(!1),w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return n(`connect-claude`),!0}finally{S(!1)}},[]),Z=(0,f.useCallback)(()=>{w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}a(``),d(``),n(`enter-pin`)},[]);return(0,f.useEffect)(()=>{K.current=Z},[Z]),{appState:t,setAppState:n,pin:i,setPin:a,operatorName:o,setOperatorName:c,pinError:l,setPinError:d,showPin:p,setShowPin:m,pinLoading:h,authPolling:_,setAuthPolling:v,authLoading:y,setAuthLoading:b,disconnecting:x,cacheKey:C,setCacheKey:w,claudeInfo:T,setClaudeInfo:E,businessName:D,role:k,userName:j,userAvatar:N,sessionId:F,setSessionId:I,expandAll:L,setExpandAll:R,expandAllDefaultRef:z,remoteAuthEnabled:B,claudeConnected:H,pinInputRef:W,setPinFormRef:G,handleSetPin:J,handleLogin:Y,handleDisconnect:X,handleLogout:Z}}var m=i();function h({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,f.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,m.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,m.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 g(e){let{pin:r,setPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:g,setOperatorName:_}=e;return(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:n,alt:t.productName,className:`connect-logo connect-logo--maxy`}),!t.logoContainsName&&(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,t.productName]}),(0,m.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,t.productName,` who you are, then choose a PIN.`]}),(0,m.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:g,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,m.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:r,onChange:i,onComplete:()=>{},showPin:a}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!r||!g.trim(),loading:s,"aria-label":`Set PIN`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(l,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function _(e){let{pin:r,setPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:g}=e;return(0,m.jsxs)(`div`,{className:`connect-page`,children:[p&&g&&(0,m.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:g,children:`Sign out`}),(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:n,alt:t.productName,className:`connect-logo connect-logo--maxy`}),!t.logoContainsName&&(0,m.jsx)(`h1`,{className:`connect-title`,children:t.productName}),(0,m.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:r,onChange:i,onComplete:()=>{},showPin:a,autoFocus:!0}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!r,loading:s,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(`div`,{className:`pin-options`,children:(0,m.jsx)(l,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function v(e){let{authPolling:r,setAuthPolling:i,authLoading:a,setAuthLoading:o,pinError:s,setPinError:l,setAppState:u}=e,[p,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1);(0,f.useEffect)(()=>{try{D(sessionStorage.getItem(`maxy-admin-session-key`))}catch{}k(!0)},[]);async function A(){C(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:b})})).json();e.accepted?(C(`Code submitted. Finishing sign-in…`),x(``)):C(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),C(`Could not submit code.`)}}async function j(){_(!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?h(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}_(!1)}async function M(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){i(!0),h(!0),o(!1),y(e.transport||``);for(let e=0;e<120;e++){await new Promise(e=>setTimeout(e,2e3));let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json();if(typeof e.authTargetId==`string`&&T(e.authTargetId),e.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.`),i(!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 N(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),i(!1),l(``)}return r||p?(0,m.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,m.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[r?(0,m.jsx)(`button`,{onClick:N,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,m.jsx)(`button`,{onClick:()=>h(!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,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,m.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,m.jsx)(`p`,{className:`chat-intro`,children:r?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!r&&(0,m.jsx)(`div`,{style:{marginTop:`12px`},children:(0,m.jsx)(c,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),r&&v===`native`&&(0,m.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,m.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,m.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,m.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,m.jsx)(c,{variant:`primary`,onClick:A,disabled:!b.trim(),children:`Submit`})]}),S&&(0,m.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:S})]})]}),(0,m.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:O&&(0,m.jsx)(d,{preferTargetId:w,cacheKey:E,chrome:!1})}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsxs)(`div`,{className:`connect-logos`,children:[(0,m.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,m.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,m.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,m.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,m.jsx)(`img`,{src:n,alt:t.productName,className:`connect-logo connect-logo--maxy`}),!t.logoContainsName&&(0,m.jsx)(`span`,{className:`connect-logo-label`,children:t.productName})]})]}),(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,t.productName]}),(0,m.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,m.jsx)(c,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,m.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,m.jsx)(`button`,{onClick:j,disabled:g,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:g?`Launching…`:`Open browser first`}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function y({auth:e}){return e.appState===`loading`?(0,m.jsx)(o,{surface:`gate`}):e.appState===`set-pin`?(0,m.jsx)(g,{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,m.jsx)(v,{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,m.jsx)(_,{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:()=>{window.location.href=`/__remote-auth/logout`}}):null}export{p as n,y as t};
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,U as n,V as r,Z as i,_ as a,q as o}from"./useSubAccountSwitcher-C7TtIbR3.js";import{A as s}from"./useVoiceRecorder-DgyAGgmF.js";import{A as c,O as l,k as u,m as d}from"./AdminShell-D24evn4t.js";var f=e(i(),1);function p(e=`admin`){let[t,n]=(0,f.useState)(`loading`),[r,i]=(0,f.useState)(``),[a,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(void 0),[k,A]=(0,f.useState)(null),[j,M]=(0,f.useState)(void 0),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(void 0),z=(0,f.useRef)(void 0),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!0);(0,f.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&V(!0)}).catch(()=>{})},[]);let W=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();w(r.session_key),I(r.sessionId??null),O(r.businessName),A(r.role??null),M(r.userName===void 0?null:r.userName),P(r.avatar??null);let i=s(r.thinkingView);return z.current=i,R(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}U(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,f.useEffect)(()=>{t===`chat`&&C&&fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(C)}`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&E(e)}).catch(()=>{})},[t,C]);let K=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();U(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(C)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(C)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){o(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),K.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,C]),(0,f.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(U(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function q(e,t){g(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){o(`enter-pin`,`/api/admin/session`);return}d(e.error||`Invalid PIN`);return}let a=await r.json();w(a.session_key),I(a.sessionId??null),O(a.businessName),A(a.role??null),M(a.userName===void 0?null:a.userName),P(a.avatar??null);let c=s(a.thinkingView);z.current=c,R(c);try{sessionStorage.setItem(`maxy-admin-session-key`,a.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}}let J=(0,f.useCallback)(async e=>{if(e.preventDefault(),h)return;d(``);let t=a.trim();if(!t){d(`Please enter your name.`);return}if(r.length<4){d(`PIN must be at least 4 characters.`);return}let s=r;g(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){o(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):d(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}d(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await q(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}},[r,h,a]),Y=(0,f.useCallback)(async e=>{e.preventDefault(),d(``),await q(r)},[r]),X=(0,f.useCallback)(async()=>{S(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;U(!1),w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return n(`connect-claude`),!0}finally{S(!1)}},[]),Z=(0,f.useCallback)(()=>{w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}i(``),d(``),n(`enter-pin`)},[]);return(0,f.useEffect)(()=>{K.current=Z},[Z]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:a,setOperatorName:l,pinError:u,setPinError:d,showPin:p,setShowPin:m,pinLoading:h,authPolling:_,setAuthPolling:v,authLoading:y,setAuthLoading:b,disconnecting:x,cacheKey:C,setCacheKey:w,claudeInfo:T,setClaudeInfo:E,businessName:D,role:k,userName:j,userAvatar:N,sessionId:F,setSessionId:I,expandAll:L,setExpandAll:R,expandAllDefaultRef:z,remoteAuthEnabled:B,claudeConnected:H,pinInputRef:W,setPinFormRef:G,handleSetPin:J,handleLogin:Y,handleDisconnect:X,handleLogout:Z}}var m=t();function h({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,f.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,m.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,m.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 g(e){let{pin:t,setPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:g,setOperatorName:_}=e;return(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:n,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,r.productName]}),(0,m.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,r.productName,` who you are, then choose a PIN.`]}),(0,m.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:g,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,m.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:i,onComplete:()=>{},showPin:a}),(0,m.jsx)(l,{variant:`send`,type:`submit`,disabled:!t||!g.trim(),loading:s,"aria-label":`Set PIN`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(u,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})]}),c&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function _(e){let{pin:t,setPin:i,showPin:a,setShowPin:o,pinLoading:s,pinError:c,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:g}=e;return(0,m.jsxs)(`div`,{className:`connect-page`,children:[p&&g&&(0,m.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:g,children:`Sign out`}),(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:n,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,m.jsx)(`h1`,{className:`connect-title`,children:r.productName}),(0,m.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:i,onComplete:()=>{},showPin:a,autoFocus:!0}),(0,m.jsx)(l,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(`div`,{className:`pin-options`,children:(0,m.jsx)(u,{checked:a,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),c&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:c})]})]})}function v(e){let{authPolling:t,setAuthPolling:i,authLoading:a,setAuthLoading:o,pinError:s,setPinError:c,setAppState:u}=e,[p,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1);(0,f.useEffect)(()=>{try{D(sessionStorage.getItem(`maxy-admin-session-key`))}catch{}k(!0)},[]);async function A(){C(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:b})})).json();e.accepted?(C(`Code submitted. Finishing sign-in…`),x(``)):C(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),C(`Could not submit code.`)}}async function j(){_(!0),c(``);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?h(!0):e.error&&c(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),c(`Could not launch browser.`)}_(!1)}async function M(){o(!0),c(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){i(!0),h(!0),o(!1),y(e.transport||``);for(let e=0;e<120;e++){await new Promise(e=>setTimeout(e,2e3));let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json();if(typeof e.authTargetId==`string`&&T(e.authTargetId),e.authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}}c(`Timed out waiting for sign-in. Try again.`),i(!1)}else e.error&&c(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),c(`Could not start auth flow.`)}o(!1)}async function N(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),i(!1),c(``)}return t||p?(0,m.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,m.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,m.jsx)(`button`,{onClick:N,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,m.jsx)(`button`,{onClick:()=>h(!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,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,m.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,m.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,m.jsx)(`div`,{style:{marginTop:`12px`},children:(0,m.jsx)(l,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&v===`native`&&(0,m.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,m.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,m.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,m.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,m.jsx)(l,{variant:`primary`,onClick:A,disabled:!b.trim(),children:`Submit`})]}),S&&(0,m.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:S})]})]}),(0,m.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:O&&(0,m.jsx)(d,{preferTargetId:w,cacheKey:E,chrome:!1})}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsxs)(`div`,{className:`connect-logos`,children:[(0,m.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,m.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,m.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,m.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,m.jsx)(`img`,{src:n,alt:r.productName,className:`connect-logo connect-logo--maxy`}),!r.logoContainsName&&(0,m.jsx)(`span`,{className:`connect-logo-label`,children:r.productName})]})]}),(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,r.productName]}),(0,m.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,m.jsx)(l,{variant:`primary`,onClick:M,disabled:a,children:a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,m.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,m.jsx)(`button`,{onClick:j,disabled:g,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:g?`Launching…`:`Open browser first`}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function y({auth:e}){return e.appState===`loading`?(0,m.jsx)(a,{surface:`gate`}):e.appState===`set-pin`?(0,m.jsx)(g,{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,m.jsx)(v,{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,m.jsx)(_,{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:()=>{window.location.href=`/__remote-auth/logout`}}):null}export{p as n,y as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,B as n,D as r,E as i,F as a,G as o,H as s,K as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,V as _,W as v,X as y,Z as b,_ as ee,b as x,g as S,h as C,i as w,j as T,k as te,m as ne,o as E,p as D,r as O,s as re,t as ie,w as ae,x as oe,y as se,z as ce}from"./useSubAccountSwitcher-C7TtIbR3.js";async function k(){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 A=o();function le({checked:e,onChange:t,label:n,disabled:r,ariaLabel:i=n}){return(0,A.jsxs)(`label`,{className:`maxy-checkbox${r?` maxy-checkbox--disabled`:``}`,children:[(0,A.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:e,onChange:e=>t(e.target.checked),disabled:r}),(0,A.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),n&&(0,A.jsx)(`span`,{className:`maxy-checkbox__label`,children:n})]})}var j=e(b(),1),ue={sm:14,md:16,lg:18},de={sm:30,md:38,lg:46};function M({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,"aria-pressed":u,style:d,className:f,children:p}){let m=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,f].filter(Boolean).join(` `),h=ue[t],g={...e===`send`?{width:de[t],height:de[t]}:{},...d},_=Object.keys(g).length>0;return(0,A.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,A.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,A.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,A.jsx)(n,{size:h})]}),i&&(0,A.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var N=n(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),fe=n(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),pe=n(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),me=n(`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`}]]),he=n(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),P=n(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ge=n(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),_e=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ve=n(`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`}]]),ye=n(`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`}]]),be=n(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),F=n(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),xe=n(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Se=n(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),Ce=n(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),we=n(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),Te=`/cdp-screencast`;function Ee(e){return{format:`jpeg`,quality:60,maxWidth:e?Math.max(320,Math.round(e.width)):1280,maxHeight:e?Math.max(320,Math.round(e.height)):800,everyNthFrame:1}}function I(e,t,n,r){return n.width<=0||n.height<=0?{x:0,y:0}:{x:e/n.width*r.deviceWidth,y:t/n.height*r.deviceHeight}}function De(e){return e===0?`left`:e===1?`middle`:e===2?`right`:`none`}function Oe(e,t){let n=De(t.button);return{type:e,x:t.x,y:t.y,button:n,buttons:t.buttons,clickCount:e===`mouseMoved`?0:1,modifiers:t.modifiers}}function ke(e){return{type:`mouseWheel`,x:e.x,y:e.y,button:`none`,buttons:0,clickCount:0,modifiers:e.modifiers,deltaX:e.deltaX,deltaY:e.deltaY}}var Ae={Backspace:8,Tab:9,Enter:13,Escape:27,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Delete:46},je={Enter:`\r`,Tab:` `};function Me(e,t){let n=t.key.length===1,r=n&&/[a-z0-9]/i.test(t.key)?t.key.toUpperCase().charCodeAt(0):Ae[t.key]??0,i={type:e,key:t.key,code:t.code,modifiers:t.modifiers,windowsVirtualKeyCode:r,nativeVirtualKeyCode:r};if(e===`keyDown`){let e=n?t.key:je[t.key];e!==void 0&&(i.text=e,i.unmodifiedText=e)}return i}function Ne(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`:``}function Pe(e){try{return new URL(Ne(e)).host}catch{return``}}function Fe(e,t,n){return`${e.protocol===`https:`?`wss`:`ws`}://${e.host}${Te}?targetId=${encodeURIComponent(t)}&sid=${encodeURIComponent(n)}`}var Ie=class{nextId=1;startId=null;frames=0;stopped=!1;lastMetadata=null;lastInputLogAtMs=null;inputsSinceLog=0;pending=new Map;constructor(e,t){this.ws=e,this.opts=t}frameCount(){return this.frames}start(e){this.send(`Page.enable`,{}),e&&this.setPaneSize(e);let t=Ee(e);this.startId=this.send(`Page.startScreencast`,t)}setPaneSize(e){let t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.send(`Emulation.setDeviceMetricsOverride`,{width:t,height:n,deviceScaleFactor:0,mobile:!1})}stop(){if(this.stopped)return;this.stopped=!0;let e=this.send(`Page.stopScreencast`,{})!==null;this.send(`Emulation.clearDeviceMetricsOverride`,{}),this.opts.onLog(`teardown`,{stopSent:e})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t.id==`number`){let e=this.pending.get(t.id);if(e){this.pending.delete(t.id),e(t.error?null:t.result);return}}if(typeof t.id==`number`&&t.id===this.startId){if(t.error)this.opts.onLog(`start-failed`,{err:t.error.message??`unknown`});else{let e=Ee();this.opts.onLog(`screencast-started`,{format:e.format,everyNthFrame:e.everyNthFrame})}return}if(t.method===`Page.frameNavigated`){let e=t.params?.frame;e&&e.parentId===void 0&&typeof e.url==`string`&&this.opts.onUrlChange?.(e.url);return}if(t.method!==`Page.screencastFrame`||this.stopped)return;let n=t.params;if(typeof n?.data!=`string`||typeof n?.metadata!=`object`||n.metadata===null)return;let r=n.metadata;typeof n.sessionId==`number`&&this.send(`Page.screencastFrameAck`,{sessionId:n.sessionId}),this.frames+=1,this.lastMetadata=r,this.frames%30==0&&this.opts.onLog(`frame`,{seq:this.frames}),this.opts.onFrame({data:n.data,metadata:r})}dispatchMouse(e,t){let n=this.lastMetadata;if(!n)return;let r=I(t.canvasX,t.canvasY,t.rendered,n);this.send(`Input.dispatchMouseEvent`,Oe(e,{x:r.x,y:r.y,button:t.button,buttons:t.buttons,modifiers:t.modifiers})),this.logInput(`mouse`)}dispatchWheel(e){let t=this.lastMetadata;if(!t)return;let n=I(e.canvasX,e.canvasY,e.rendered,t);this.send(`Input.dispatchMouseEvent`,ke({x:n.x,y:n.y,deltaX:e.deltaX,deltaY:e.deltaY,modifiers:e.modifiers})),this.logInput(`wheel`)}dispatchKey(e,t){this.send(`Input.dispatchKeyEvent`,Me(e,t)),this.logInput(`key`)}insertText(e){e&&(this.send(`Input.insertText`,{text:e}),this.logInput(`paste`))}navigate(e){let t=Ne(e);t&&(this.send(`Page.navigate`,{url:t}),this.opts.onLog(`navigate`,{host:Pe(t)}))}async goHistory(e){let t=e<0?`back`:`forward`,n=await this.command(`Page.getNavigationHistory`,{});if(!n){this.opts.onLog(`history`,{dir:t,outcome:`no-result`});return}let{currentIndex:r,entries:i}=n,a=typeof r==`number`?i?.[r+e]:void 0;if(!a||typeof a.id!=`number`){this.opts.onLog(`history`,{dir:t,outcome:`no-entry`});return}this.send(`Page.navigateToHistoryEntry`,{entryId:a.id}),this.opts.onLog(`history`,{dir:t})}command(e,t){let n=this.send(e,t);return n===null?Promise.resolve(null):new Promise(e=>this.pending.set(n,e))}logInput(e){this.inputsSinceLog+=1;let t=(this.opts.now??Date.now)();if(this.lastInputLogAtMs!==null&&t-this.lastInputLogAtMs<1e3)return;this.lastInputLogAtMs=t;let n=this.inputsSinceLog;this.inputsSinceLog=0,this.opts.onLog(`input`,{kind:e,count:n})}send(e,t){let n=this.nextId++;try{return this.ws.send(JSON.stringify({id:n,method:e,params:t})),n}catch(t){return this.opts.onLog(`send-failed`,{method:e,err:t instanceof Error?t.message:String(t)}),null}}};function Le(e){let{targets:t,activeId:n,url:r,busy:i}=e,[a,o]=(0,j.useState)(r),s=(0,j.useRef)(null);return(0,j.useEffect)(()=>{s.current&&document.activeElement===s.current||o(r)},[r]),(0,j.useEffect)(()=>{o(e.url)},[n]),(0,A.jsxs)(`div`,{className:`browser-chrome`,children:[(0,A.jsxs)(`div`,{className:`browser-chrome__tabs`,role:`tablist`,children:[t.map(t=>(0,A.jsxs)(`div`,{className:t.id===n?`browser-chrome__tab is-active`:`browser-chrome__tab`,role:`tab`,"aria-selected":t.id===n,children:[(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__tab-label`,onClick:()=>e.onSelect(t.id),title:t.url,children:t.title}),(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__tab-close`,"aria-label":`Close ${t.title}`,onClick:()=>e.onClose(t.id),disabled:i,children:(0,A.jsx)(x,{size:12,strokeWidth:2})})]},t.id)),(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__new`,"aria-label":`New tab`,title:`New tab`,onClick:e.onNew,disabled:i,children:(0,A.jsx)(g,{size:14,strokeWidth:2})}),(e.onToggleFull||e.onClosePane)&&(0,A.jsxs)(`div`,{className:`browser-chrome__window`,children:[e.onToggleFull&&(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":e.isFull?`Exit full screen`:`Full screen`,title:e.isFull?`Exit full screen`:`Full screen`,onClick:e.onToggleFull,children:e.isFull?(0,A.jsx)(be,{size:15,strokeWidth:1.75}):(0,A.jsx)(te,{size:15,strokeWidth:1.75})}),e.onClosePane&&(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":`Close browser`,title:`Close browser`,onClick:e.onClosePane,children:(0,A.jsx)(x,{size:16,strokeWidth:1.75})})]})]}),(0,A.jsxs)(`form`,{className:`browser-chrome__bar`,onSubmit:t=>{t.preventDefault(),e.onNavigate(a)},children:[(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":`Back`,title:`Back`,onClick:e.onBack,children:(0,A.jsx)(m,{size:16,strokeWidth:1.75})}),(0,A.jsx)(`button`,{type:`button`,className:`browser-chrome__nav`,"aria-label":`Forward`,title:`Forward`,onClick:e.onForward,children:(0,A.jsx)(pe,{size:16,strokeWidth:1.75})}),(0,A.jsx)(`input`,{ref:s,className:`browser-chrome__url`,"aria-label":`Address`,placeholder:`Type a URL`,value:a,onChange:e=>o(e.target.value)})]})]})}function L(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}function R({preferTargetId:e=null,cacheKey:n=null,chrome:r=!0,surface:i=`browser`,onToggleFull:a,onClosePane:o,isFull:s=!1}={}){let[c,l]=(0,j.useState)(`probing`),[d,f]=(0,j.useState)([]),[p,m]=(0,j.useState)(null),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(null),[y,b]=(0,j.useState)(!1),[ee,x]=(0,j.useState)(``),S=se(n),C=(0,j.useRef)(null),w=(0,j.useRef)(null),T=(0,j.useRef)(null),te=(0,j.useRef)(``),ne=(0,j.useRef)(e);ne.current=e,te.current||=`sc-${Math.random().toString(36).slice(2,10)}`;let E=(0,j.useCallback)((e,t={})=>{S(`/api/admin/browser/screencast-event`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sid:te.current,op:e,...t})}).catch(()=>{})},[S]),D=(0,j.useCallback)(async()=>{try{let e=await S(`/api/admin/browser/screencast-targets`);if(!e.ok){l(`unavailable`);return}let t=await e.json().catch(()=>({})),n=Array.isArray(t.targets)?t.targets:[];if(f(n),n.length===0){m(null),l(`no-tabs`);return}let r=ne.current;m(e=>r&&n.some(e=>e.id===r)?r:e&&n.some(t=>t.id===e)?e:n[0].id),l(`live`)}catch{l(`unavailable`)}},[S]);(0,j.useEffect)(()=>{E(`request`),D()},[D,E]),(0,j.useEffect)(()=>{r&&E(`chrome-mounted`,{surface:i,chrome:`v1`})},[r,i,E]),(0,j.useEffect)(()=>{x(d.find(e=>e.id===p)?.url??``)},[d,p]);let O=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(e){if(d.some(t=>t.id===e)){m(e);return}O.current!==e&&(O.current=e,D())}},[e,d,D]);let re=(0,j.useCallback)(e=>{let t=C.current;if(!t)return;let n=new Image;n.onload=()=>{t.width=n.naturalWidth,t.height=n.naturalHeight,t.getContext(`2d`)?.drawImage(n,0,0)},n.src=`data:image/jpeg;base64,${e.data}`},[]),ie=(0,j.useCallback)(()=>{let e=w.current;if(!e)return;let t=e.getBoundingClientRect();if(!(t.width<1||t.height<1))return{width:t.width,height:t.height}},[]);(0,j.useEffect)(()=>{let e=w.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let e=ie();e&&T.current?.setPaneSize(e)});return t.observe(e),()=>t.disconnect()},[c,ie]),(0,j.useEffect)(()=>{if(c!==`live`||!p)return;let e=Fe({protocol:window.location.protocol,host:window.location.host},p,te.current),t=new WebSocket(e),n=new Ie(t,{onFrame:re,onLog:E,onUrlChange:x});return T.current=n,t.addEventListener(`open`,()=>n.start(ie())),t.addEventListener(`message`,e=>{typeof e.data==`string`&&n.handleMessage(e.data)}),()=>{n.stop(),t.close(),T.current=null}},[c,p,re,E]);let ae=(0,j.useCallback)(e=>t=>{let n=C.current;if(!n)return;let r=n.getBoundingClientRect();T.current?.dispatchMouse(e,{canvasX:t.clientX-r.left,canvasY:t.clientY-r.top,rendered:{width:r.width,height:r.height},button:e===`mouseMoved`?-1:t.button,buttons:t.buttons,modifiers:L(t)})},[]);(0,j.useEffect)(()=>{let e=C.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect();T.current?.dispatchWheel({canvasX:t.clientX-n.left,canvasY:t.clientY-n.top,rendered:{width:n.width,height:n.height},deltaX:t.deltaX,deltaY:t.deltaY,modifiers:L(t)})};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[c]);let oe=(0,j.useCallback)(e=>t=>{t.preventDefault(),T.current?.dispatchKey(e,{key:t.key,code:t.code,modifiers:L(t)})},[]),ce=(0,j.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text`);t&&T.current?.insertText(t)},[]),k=(0,j.useCallback)(async()=>{g(!0),v(null);try{let e=await S(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}await D()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}},[S,D]),le=(0,j.useCallback)(async()=>{b(!0),v(null);try{c===`no-tabs`&&await S(`/api/admin/browser/launch`,{method:`POST`});let e=await S(`/api/admin/browser/tabs`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`New tab failed (${e.status})`)}let t=await e.json().catch(()=>({}));await D(),t.id&&m(t.id)}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}},[S,D,c]),ue=(0,j.useCallback)(async e=>{b(!0),v(null);try{let t=await S(`/api/admin/browser/tabs/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Close failed (${t.status})`)}await D()}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}},[S,D]),de=(0,j.useCallback)(e=>{T.current?.navigate(e)},[]),M=(0,j.useCallback)(e=>{T.current?.goHistory(e)},[]);return c===`probing`?(0,A.jsx)(`div`,{className:`cdp-screencast`,children:(0,A.jsxs)(`div`,{className:`data-loading`,children:[(0,A.jsx)(t,{size:18,className:`spin`}),` Connecting to the device browser…`]})}):c===`unavailable`?(0,A.jsx)(`div`,{className:`cdp-screencast`,children:(0,A.jsxs)(`div`,{className:`cdp-screencast__unavailable`,children:[(0,A.jsx)(u,{size:28,strokeWidth:1.75}),(0,A.jsx)(`p`,{children:`The device browser is not reachable.`})]})}):(0,A.jsxs)(`div`,{className:`cdp-screencast`,children:[r&&(0,A.jsx)(Le,{targets:d,activeId:p,url:ee,busy:y,onSelect:m,onClose:ue,onNew:le,onBack:()=>M(-1),onForward:()=>M(1),onNavigate:de,onToggleFull:a,onClosePane:o,isFull:s}),_&&(0,A.jsx)(`div`,{className:`cdp-screencast__toolbar`,children:(0,A.jsx)(`span`,{className:`cdp-screencast__error`,children:_})}),c===`no-tabs`?(0,A.jsxs)(`div`,{className:`cdp-screencast__unavailable`,children:[(0,A.jsx)(u,{size:28,strokeWidth:1.75}),(0,A.jsx)(`p`,{children:`No open tabs on the device browser.`}),(0,A.jsxs)(`button`,{type:`button`,className:`cdp-screencast__btn`,onClick:k,disabled:h,children:[h?(0,A.jsx)(t,{size:14,className:`spin`}):(0,A.jsx)(u,{size:14}),` Launch browser`]})]}):(0,A.jsxs)(A.Fragment,{children:[!r&&(0,A.jsx)(`div`,{className:`cdp-screencast__tabs`,children:d.map(e=>(0,A.jsx)(`button`,{type:`button`,className:e.id===p?`cdp-screencast__tab is-active`:`cdp-screencast__tab`,onClick:()=>m(e.id),title:e.url,children:e.title},e.id))}),(0,A.jsx)(`div`,{className:`cdp-screencast__viewport`,ref:w,children:(0,A.jsx)(`canvas`,{ref:C,className:`cdp-screencast__canvas`,tabIndex:0,onMouseDown:ae(`mousePressed`),onMouseUp:ae(`mouseReleased`),onMouseMove:ae(`mouseMoved`),onKeyDown:oe(`keyDown`),onKeyUp:oe(`keyUp`),onPaste:ce})})]})]})}var Re=5e3,ze=1200;function Be(e){return Math.max(ze,Math.round(Re/(e<1?1:e)))}var Ve=500,z=new Set;function He(e,t,n){let r=n??(typeof globalThis.fetch==`function`?globalThis.fetch:void 0);if(z.has(e)||!r)return!1;if(z.size>=Ve){for(let e of z)if(z.delete(e),z.size<Ve)break}z.add(e);try{Promise.resolve(r(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:`wa-notify:rendered`,fields:{msgId:e,senderType:t}})})).catch(()=>{})}catch{}return!0}function Ue({type:e}){return e===`admin`?(0,A.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,A.jsx)(`path`,{d:`M8 1.5 13 3.5v4c0 3-2.1 5.8-5 7-2.9-1.2-5-4-5-7v-4z`})}):e===`manager-active`?(0,A.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,A.jsx)(`path`,{d:`M2 5.5h9l-2.5-2.5 1-1L14 6l-4.5 4-1-1L11 6.5H2zM14 10.5H5l2.5 2.5-1 1L2 10l4.5-4 1 1L5 9.5h9z`})}):e===`manager-passive`?(0,A.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,A.jsx)(`path`,{d:`M8 3C4.5 3 1.7 5.4 1 8c.7 2.6 3.5 5 7 5s6.3-2.4 7-5c-.7-2.6-3.5-5-7-5m0 8a3 3 0 1 1 0-6 3 3 0 0 1 0 6`})}):(0,A.jsx)(`svg`,{className:`wa-notify-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,A.jsx)(`path`,{d:`M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m0 1.5c-3 0-5.5 1.6-5.5 3.5v1h11v-1c0-1.9-2.5-3.5-5.5-3.5`})})}function We({frames:e,onExpire:t}){let n=(0,j.useRef)(new Map),r=(0,j.useRef)(new Map);return(0,j.useEffect)(()=>{let i=Date.now(),a=Be(e.length),o=new Set(e.map(e=>e.waMessageId));for(let e of[...n.current.keys()])o.has(e)||(n.current.delete(e),r.current.delete(e));let s=[];for(let o of e){let e=o.waMessageId;n.current.has(e)||(n.current.set(e,i),He(e,o.senderType));let c=r.current.get(e),l=c===void 0?a:Math.min(c,a);r.current.set(e,l);let u=i-(n.current.get(e)??i);s.push(setTimeout(()=>t(e),Math.max(0,l-u)))}return()=>{for(let e of s)clearTimeout(e)}},[e,t]),e.length===0?null:(0,A.jsx)(`div`,{className:`wa-notify-host`,children:[...e].reverse().map(e=>(0,A.jsxs)(`div`,{className:`wa-notify-card`,role:`status`,children:[(0,A.jsxs)(`div`,{className:`wa-notify-head`,children:[(0,A.jsx)(`span`,{className:`wa-notify-pill wa-notify-pill-${e.senderType}`,children:(0,A.jsx)(Ue,{type:e.senderType})}),(0,A.jsx)(`span`,{className:`wa-notify-account`,children:e.accountName})]}),(0,A.jsx)(`div`,{className:`wa-notify-sender`,children:e.senderDisplay}),(0,A.jsxs)(`div`,{className:`wa-notify-body`,children:[e.body,e.truncated?`…`:``]})]},e.waMessageId))})}var Ge=`wa-notify`;function Ke({connected:e,onConnectClaude:t}){return e?(0,A.jsxs)(`span`,{className:`claude-status-pill`,"data-connected":`true`,title:`Claude is connected`,children:[(0,A.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,A.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connected`}),(0,A.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--live`,"aria-hidden":`true`})]}):(0,A.jsxs)(`button`,{type:`button`,className:`claude-status-pill claude-status-pill--action`,"data-connected":`false`,onClick:t,title:`Connect Claude`,children:[(0,A.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`claude-status-pill__mark`}),(0,A.jsx)(`span`,{className:`claude-status-pill__label`,children:`Connect`}),(0,A.jsx)(`span`,{className:`claude-status-pill__dot claude-status-pill__dot--down`,"aria-hidden":`true`})]})}function qe(e){return e===`/`||e===``?`Dashboard`:e.startsWith(`/chat`)?`Chat`:e.startsWith(`/tasks`)?`Tasks`:e.startsWith(`/data`)?`Data`:e.startsWith(`/calendar`)?`Calendar`:e.startsWith(`/graph`)?`Graph`:e.startsWith(`/activity`)?`Activity`:e.startsWith(`/browser`)?`Browser`:e.startsWith(`/routines`)?`Routines`:e.startsWith(`/skills`)?`Skills`:e.startsWith(`/agents`)?`Agents`:`Dashboard`}function Je({title:e,sidebarOpen:t,onToggleSidebar:n,claudeConnected:r,onConnectClaude:i,onOpenBrowser:a}){let o=e??qe(typeof window<`u`?window.location.pathname:`/`),s=r!==void 0&&i!==void 0,c=a!==void 0;return(0,A.jsxs)(`header`,{className:`admin-page-header`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`admin-page-header__toggle`,"aria-label":t?`Hide sidebar`:`Show sidebar`,title:t?`Hide sidebar`:`Show sidebar`,"aria-expanded":t,onClick:n,children:[(0,A.jsx)(F,{className:`admin-page-header__toggle-desktop`,size:18,strokeWidth:1.75}),(0,A.jsx)(f,{className:`admin-page-header__toggle-mobile`,size:22,strokeWidth:1.75})]}),(0,A.jsx)(`h1`,{className:`admin-page-header__title`,children:o}),(s||c)&&(0,A.jsxs)(`div`,{className:`admin-page-header__right`,children:[s&&(0,A.jsx)(Ke,{connected:r,onConnectClaude:i}),c&&(0,A.jsx)(`button`,{type:`button`,className:`admin-page-header__icon`,"aria-label":`Show browser`,title:`Show browser`,onClick:a,children:(0,A.jsx)(u,{size:18,strokeWidth:1.75})})]})]})}var Ye=[{label:`Home`,href:`/`,Icon:T,match:e=>e===`/`||e===``},{label:`Chat`,href:`/chat`,Icon:r,match:e=>e.startsWith(`/chat`)},{label:`Tasks`,href:`/tasks`,Icon:ve,match:e=>e.startsWith(`/tasks`)},{label:`Data`,href:`/data`,Icon:a,match:e=>e.startsWith(`/data`)},{label:`Calendar`,href:`/calendar`,Icon:l,match:e=>e.startsWith(`/calendar`)}],Xe=[{label:`Chat`,href:`/`,Icon:r,match:e=>e===`/`||e===``||e.startsWith(`/chat`)},{label:`Data`,href:`/data`,Icon:a,match:e=>e.startsWith(`/data`)}];function Ze(e){let t=Ye.find(t=>t.match(e));return t?t.href:`/`}function B({variant:e=`admin`,onOpenConversations:t}={}){let n=typeof window<`u`?window.location.pathname:`/`,i=e===`operator`?Xe:Ye,a=e===`operator`?Xe.find(e=>e.match(n))?.href??`/`:Ze(n),o=e=>{let t=e.href===a,{Icon:n}=e;return(0,A.jsxs)(`a`,{href:e.href,className:`bottom-tab${t?` is-active`:``}`,"aria-current":t?`page`:void 0,children:[(0,A.jsx)(n,{size:19,strokeWidth:1.75}),(0,A.jsx)(`span`,{className:`bottom-tab__label`,children:e.label})]},e.href)};return(0,A.jsxs)(`nav`,{className:`bottom-tab-bar`,"aria-label":`Primary`,children:[i.slice(0,1).map(o),e===`operator`&&t&&(0,A.jsxs)(`button`,{type:`button`,className:`bottom-tab`,onClick:t,children:[(0,A.jsx)(r,{size:19,strokeWidth:1.75}),(0,A.jsx)(`span`,{className:`bottom-tab__label`,children:`Conversations`})]}),i.slice(1).map(o)]})}var Qe=`maxy-shell-side-px`;function $e(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function et(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-$e());return Math.min(Math.max(e,248),n)}function tt(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(Qe);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 et(t)}catch{}return 264}function nt({targetSelector:e=`.platform`}){let t=(0,j.useRef)(null),[n,r]=(0,j.useState)(()=>tt()),i=(0,j.useRef)(n);(0,j.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,j.useCallback)(()=>{r(e=>{let t=et(e);return t===e?e:t})},[]);(0,j.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(et(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(Qe,String(t))}catch{}};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{r(et(264));try{window.localStorage.removeItem(Qe)}catch{}};return(0,A.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var rt=y();function V(e){return Math.max(14,e/2-386)}function it(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var H={position:`fixed`,visibility:`hidden`};function U({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,j.useRef)(null),[c,l]=(0,j.useState)(H),u=(0,j.useCallback)(()=>{let t=s.current;if(!t)return;let r=e.current,i=[n,a].filter(Boolean).join(`:`)||`unknown`,o=t.getBoundingClientRect(),c=window.innerWidth,u=window.innerHeight,d=o.width>0&&o.height>0,f=r?r.getBoundingClientRect():null,p=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${u}`);if(!f){l({position:`fixed`,left:Math.max(4,c-o.width-V(c)),top:Math.max(4,u-o.height-14),visibility:`visible`});return}if(d&&it(f)){l(H),p(f.left,f.top);return}let m=f.right-o.width,h=c-o.width-4;m>h&&(m=h),m<4&&(m=4);let g=u-f.bottom-4,_=f.top-4,v=o.height+8<=g?!1:o.height+8<=_?!0:_>g,y=Math.max(0,v?_:g),b=v?Math.max(4,f.top-Math.min(o.height,y)):f.bottom;l({position:`fixed`,left:m,top:b,maxHeight:y,visibility:`visible`});let ee=Math.min(o.height,y);d&&(m+o.width<=0||m>=c||b+ee<=0||b>=u)&&p(m,b)},[e,a,n]);return(0,j.useLayoutEffect)(()=>{if(u(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>u());return s.current&&e.observe(s.current),()=>e.disconnect()},[u]),(0,j.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||s.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,rt.createPortal)((0,A.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function at({actions:e,disabled:t,label:n=`Session actions`}){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(null),s=(0,j.useRef)(null),c=(0,j.useCallback)(()=>{i(!1),o(null)},[]);return(0,A.jsxs)(`div`,{className:`conv-actions`,children:[(0,A.jsx)(`button`,{ref:s,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>i(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":r,"aria-label":n,title:n,children:(0,A.jsx)(f,{size:12})}),r&&(0,A.jsx)(U,{anchorRef:s,onClose:c,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,A.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,A.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":a===e.key,title:e.title,disabled:t||e.disabled,onClick:()=>o(t=>t===e.key?null:e.key),children:[e.icon,(0,A.jsx)(`span`,{children:e.menuLabel})]}),a===e.key&&(0,A.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,A.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,title:e.title,disabled:t||e.disabled,onClick:t=>{e.onClick?.(t),c()},children:[e.icon,(0,A.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var ot=`claude-opus-5[1m]`,W=`claude-sonnet-5`,G=`claude-haiku-4-5`,st={[ot]:`Opus 5 (1M context)`,[W]:`Sonnet 5`,[G]:`Haiku 4.5`};function ct(e){return st[e]??e}var lt=[ot,W,G];function K(e){return e.replace(/\[1m\]$/,``)}function ut(e){return lt.find(t=>K(t)===K(e))??e}var dt=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],ft=[`low`,`medium`,`high`,`xhigh`];[...dt],[...ft],[...ft];var q=[ot,W,G],pt={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},mt=dt.map(e=>({value:e,label:pt[e]??e})),J={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},ht=ft.map(e=>({value:e,label:J[e]??e}));function gt(e){if(e){let t=q.find(t=>K(t)===K(e));if(t)return t}return ot}function _t({row:e,adminFetch:n,onError:r}){let[i,a]=(0,j.useState)(()=>gt(e.model)),[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),f=(0,j.useRef)(!1);(0,j.useEffect)(()=>{a(gt(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let t=await n(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:i,...o?{permissionMode:o}:{},...c?{effort:c}:{}})});if(!t.ok){r(`Could not reset ${e.title} (status ${t.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${t.status}`),f.current=!1,d(!1);return}let a=await t.json().catch(()=>({}));a.target?window.location.assign(a.target):(r(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){r(`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,d(!1)}}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`label`,{className:`reseat-field`,children:[(0,A.jsx)(`span`,{children:`Model`}),(0,A.jsx)(`select`,{"data-kind":`model`,value:i,disabled:u,onChange:e=>a(e.target.value),children:q.map(e=>(0,A.jsx)(`option`,{value:e,children:ct(e)},e))})]}),(0,A.jsxs)(`label`,{className:`reseat-field`,children:[(0,A.jsx)(`span`,{children:`Mode`}),(0,A.jsxs)(`select`,{"data-kind":`mode`,value:o,disabled:u,onChange:e=>s(e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`Keep current`}),mt.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,A.jsxs)(`label`,{className:`reseat-field`,children:[(0,A.jsx)(`span`,{children:`Effort`}),(0,A.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,A.jsx)(`option`,{value:``,children:`Keep current`}),ht.map(e=>(0,A.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,A.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(t,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function vt(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 yt(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function bt({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,j.useRef)(null);return i.current=t,e?(0,A.jsxs)(U,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`span`,{children:`Delete this conversation?`}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,A.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,A.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,A.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,A.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,A.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,A.jsx)(M,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,A.jsx)(M,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function xt({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,j.useRef)(null);return i.current=t,e?(0,A.jsxs)(U,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete task`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`span`,{children:`Delete this task?`}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,A.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,A.jsx)(`span`,{className:`conv-delete-label`,title:e.name,children:e.name}),(0,A.jsx)(`code`,{className:`conv-delete-id`,children:w(e.secondsLogged)})]}),(0,A.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the task and every time record on it. It cannot be recovered.`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,A.jsx)(M,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,A.jsx)(M,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function St({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,A.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,A.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,A.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,A.jsxs)(M,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,A.jsx)(M,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}function Ct(e){return`New session: ${e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}`}function wt({open:e,pending:t,onConfirm:n,onCancel:r,now:i}){let[a,o]=(0,j.useState)(``),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(!1);if((0,j.useEffect)(()=>{if(!e){c.current=null,l.current=!1;return}if(c.current!==null)return;let t=Ct(i?i():new Date);c.current=t,o(t)},[e,i]),(0,j.useEffect)(()=>{if(!e||l.current||c.current===null||a!==c.current)return;let t=s.current;t&&(l.current=!0,t.focus(),t.setSelectionRange(0,t.value.length))},[e,a]),!e)return null;let u=a.trim(),d=u.length>0&&u.length<=200,f=()=>{d&&!t&&n(u)},p=e=>{t||r(e)};return(0,A.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>p(`backdrop`),children:(0,A.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Name this session`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`span`,{children:`Name this session`}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:()=>p(`cancel`),"aria-label":`Close`,disabled:t,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`},children:[(0,A.jsx)(`input`,{ref:s,className:`new-session-name-input`,"aria-label":`Session name`,value:a,disabled:t,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(e.preventDefault(),p(`escape`))}}),(0,A.jsx)(`div`,{className:`new-session-name-hint`,children:u.length>200?`Too long by ${u.length-200}`:`You can rename it later from the session menu.`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,A.jsx)(M,{variant:`primary`,size:`sm`,style:{flex:1},disabled:!d||t,onClick:f,children:t?`Starting…`:`Start session`}),(0,A.jsx)(M,{variant:`secondary`,size:`sm`,style:{flex:1},disabled:t,onClick:()=>p(`cancel`),children:`Cancel`})]})]})})}var Tt=`auth-refresh-failed`;function Et({error:e,onClose:t}){if(!e)return null;let n=e.reason===Tt,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,A.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,A.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`span`,{children:r}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,A.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,A.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Dt(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,j.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,A.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,A.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,A.jsx)(`span`,{children:`Claude Code`}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,children:[(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,A.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,A.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,A.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,A.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,children:[(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:p>0?yt(p):`—`})]}),(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,A.jsx)(`span`,{className:`claude-info-value`,children:vt(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,A.jsxs)(`div`,{className:`claude-info-row`,children:[(0,A.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,A.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 O(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Ot({open:e,onConnect:t,onClose:n}){return e?(0,A.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,A.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsx)(`span`,{children:`Claude isn’t connected`}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,A.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,A.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,A.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,A.jsx)(M,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,A.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function kt(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function At(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function Y(e){return e.toLocaleString(`en-GB`)}function jt(e){return`£${e.toFixed(2)}`}function Mt(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 5 (GBP)`,`Sonnet 5 (GBP)`],n=(e,t)=>[e,kt(At(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
|
|
2
|
+
`)}function X({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,A.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,A.jsx)(r,{className:`usage-day`,children:e}),(0,A.jsx)(r,{children:kt(At(t))}),(0,A.jsx)(r,{children:Y(t.tokens.output)}),(0,A.jsx)(r,{children:Y(t.tokens.input)}),(0,A.jsx)(r,{children:Y(t.tokens.cacheWrite)}),(0,A.jsx)(r,{children:Y(t.tokens.cacheRead)}),(0,A.jsx)(r,{children:jt(t.costGBP.opus)}),(0,A.jsx)(r,{children:jt(t.costGBP.sonnet)})]})}function Nt({show:e,onClose:t,anchorEl:n,sessionId:r,summary:i,loading:a,error:o}){let s=(0,j.useRef)(null);if(s.current=n,!e)return null;let c=!!i&&i.days.length>0;return(0,A.jsxs)(U,{anchorRef:s,onClose:t,className:`usage-popover`,role:`dialog`,ariaLabel:`Session usage and cost`,anchorId:r??void 0,children:[(0,A.jsxs)(`div`,{className:`claude-info-header`,children:[(0,A.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),c&&(0,A.jsx)(`button`,{className:`usage-download`,onClick:()=>{if(!i)return;let e=new Blob([Mt(i)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usage-${r?r.slice(0,8):`session`}.csv`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)},"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,A.jsx)(p,{size:14})}),(0,A.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,A.jsx)(x,{size:14})})]}),(0,A.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,A.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,A.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&i&&i.days.length===0&&(0,A.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&i&&i.days.length>0&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`usage-table-scroll`,children:(0,A.jsxs)(`table`,{className:`usage-table`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,A.jsx)(`th`,{children:`Active`}),(0,A.jsx)(`th`,{children:`Output tok`}),(0,A.jsx)(`th`,{children:`Input tok`}),(0,A.jsx)(`th`,{children:`Cache write`}),(0,A.jsx)(`th`,{children:`Cache read`}),(0,A.jsx)(`th`,{children:`Opus 5 (£)`}),(0,A.jsx)(`th`,{children:`Sonnet 5 (£)`})]})}),(0,A.jsxs)(`tbody`,{children:[i.days.map(e=>(0,A.jsx)(X,{label:e.date,d:e},e.date)),(0,A.jsx)(X,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,A.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,i.pricing.opusPriceDate,` · £/$ `,i.pricing.usdPerGbp,` · Sonnet tokenizer factor `,i.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost.`]})]})]})]})}var Pt=`https://claude.ai/code`,Ft=200,It=[500,1e3,1500,2e3,2500,3e3,3e3];function Lt(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Pt}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Rt(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Z(e){let{businessName:n,cacheKey:o,onConnectClaude:c,role:u,userName:f,userAvatar:p,onSelectProjects:m,onSelectTasks:y,onCloseMobileDrawer:b,collapsed:ee,onSelectData:x,initialDataSurface:w=!1,onLogout:te,onDisconnect:ne,disconnecting:O,claudeConnected:ie=!0,subAccounts:k,activeAccountId:ue,switchingAccount:de,onSwitchAccount:M,refreshAccounts:pe,onOpenConversations:be}=e,F=se(o),Te=(0,j.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,A.jsx)(xe,{size:12}),panel:()=>(0,A.jsx)(_t,{row:e,adminFetch:F,onError:e=>R({message:e,failed:!0})})}),[F]),Ee=_.productName,I=n||Ee,De=typeof f==`string`?f:f===null?`name unavailable`:I,Oe=(De.trim().charAt(0)||`?`).toUpperCase(),[ke,Ae]=(0,j.useState)(w?`data`:`sessions`),[je,Me]=(0,j.useState)(!1),[Ne,Pe]=(0,j.useState)(!1),Fe=!ee&&(k?.length??0)>1&&!!M,Ie=k?.find(e=>e.isHouse)??null,Le=(0,j.useCallback)(()=>{Ie&&Ie.accountId!==ue&&(Pe(!1),M?.(Ie.accountId,`/`))},[Ie,ue,M]),[L,R]=(0,j.useState)(null),[Re,ze]=(0,j.useState)(null),[Be,Ve]=(0,j.useState)(!1),[z,He]=(0,j.useState)([]),[Ue]=(0,j.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[We,Ge]=(0,j.useState)(!1),[Ke,qe]=(0,j.useState)(null),[Je,Ye]=(0,j.useState)(!1),[Xe,Ze]=(0,j.useState)(!1),[B,Qe]=(0,j.useState)(!1),[$e,et]=(0,j.useState)(null),[tt,nt]=(0,j.useState)(new Set),rt=(0,j.useRef)(new Map),[V,it]=(0,j.useState)(!1),[H,U]=(0,j.useState)(new Set),[ot,W]=(0,j.useState)(!1),[G,st]=(0,j.useState)(null),[ct,lt]=(0,j.useState)(new Set),[K,ut]=(0,j.useState)(new Set),[dt,ft]=(0,j.useState)(new Set),[q,pt]=(0,j.useState)(null),[mt,J]=(0,j.useState)(``),[ht,gt]=(0,j.useState)(!1),[vt,yt]=(0,j.useState)(null),[xt,Ct]=(0,j.useState)(null),[Tt,Dt]=(0,j.useState)(!1),[kt,At]=(0,j.useState)(null),[Y,jt]=(0,j.useState)(!1),[Mt,X]=(0,j.useState)(!1),Pt=(0,j.useRef)(0);(0,j.useEffect)(()=>{if(!L)return;let e=setTimeout(()=>R(null),2500);return()=>clearTimeout(e)},[L]);let Z=(0,j.useCallback)(async()=>{if(!o)return null;let e=++Pt.current;Ye(!0),qe(null);try{let t=await F(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Pt.current?(He(r),et(n.accountId??null),Ge(!0),r):r}catch(t){let n=t instanceof Error?t.message:String(t);return e===Pt.current&&qe(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Pt.current&&Ye(!1)}},[o,F]);(0,j.useEffect)(()=>{!o||We||Z()},[o,We,Z]),(0,j.useEffect)(()=>{if(!o)return;let e=null;function t(){Z()}function n(){e===null&&(e=setInterval(t,Bt))}function r(){e!==null&&(clearInterval(e),e=null)}function i(){document.hidden?r():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,i),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[o,Z]);let zt=()=>{Z()},Ht=()=>{Ae(`data`),x(),b()},Q=typeof window<`u`&&window.location?.pathname||`/`,Ut=ke===`data`,Wt=typeof window<`u`&&window.location?.search||``,Gt=new URLSearchParams(Wt),Kt=Gt.has(`label`)&&!Gt.has(`nodeId`),$=e=>{b(),window.location.href=e},qt=[{key:`dashboard`,label:`Dashboard`,icon:(0,A.jsx)(T,{size:17,strokeWidth:1.75}),active:Q===`/`&&!Ut,onClick:()=>$(`/`)},{key:`chat`,label:`Chat`,icon:(0,A.jsx)(r,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/chat`),onClick:()=>$(`/chat`)},{key:`tasks`,label:`Tasks`,icon:(0,A.jsx)(ve,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/tasks`),onClick:()=>{y(),b()}},{key:`calendar`,label:`Calendar`,icon:(0,A.jsx)(l,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/calendar`),onClick:()=>$(`/calendar`)},{key:`routines`,label:`Routines`,icon:(0,A.jsx)(we,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/routines`),onClick:()=>$(`/routines`)},{key:`skills`,label:`Skills`,icon:(0,A.jsx)(Se,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/skills`),onClick:()=>$(`/skills`)},{key:`agents`,label:`Agents`,icon:(0,A.jsx)(me,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/agents`),onClick:()=>$(`/agents`)},{key:`data`,label:`Data`,icon:(0,A.jsx)(a,{size:17,strokeWidth:1.75}),active:Ut,onClick:Ht},{key:`container`,label:v().term,icon:(0,A.jsx)(d,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&Kt,onClick:()=>{m(),b()}},{key:`graph`,label:`Graph`,icon:(0,A.jsx)(Ce,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/graph`)&&!Kt,onClick:()=>$(`/graph`)},{key:`activity`,label:`Activity`,icon:(0,A.jsx)(ce,{size:17,strokeWidth:1.75}),active:Q.startsWith(`/activity`),onClick:()=>$(`/activity`)}],Jt=(0,j.useCallback)(async e=>{if(ct.has(e.sessionId))return;lt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Lt(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});i.kind===`navigate`?(b(),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}`),ze(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}`),ze({sessionId:e.sessionId,reason:r})}finally{lt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,b,ct]),Yt=(0,j.useCallback)(async e=>{let t=e.slice(0,8);for(let t=1;t<=It.length;t++){await new Promise(e=>setTimeout(e,It[t-1]));let n=await Z();if(n&&n.some(t=>t.sessionId===e))return}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Z]),Xt=(0,j.useCallback)(async e=>{if(!Y){jt(!0);try{let t=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:e})}),n=await t.json().catch(()=>({})),r=Lt(t.ok,t.status,n);r.kind===`navigate`?r.sameOrigin?window.location.assign(r.url):(window.open(r.url,`_blank`),n.sessionId?Yt(n.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):t.status===503||r.reason===`claude-auth-dead`?(X(!1),Ve(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${t.status} reason=${r.reason}`),X(!1),ze(r))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),X(!1),ze({sessionId:null,reason:t})}finally{jt(!1)}}},[F,Y,Yt]),Zt=(0,j.useCallback)((e,t)=>{e.stopPropagation(),st(t)},[]),Qt=(0,j.useCallback)(async(e,t)=>{e.stopPropagation(),yt(t),Ct(null),At(null),Dt(!0);try{let e=await F(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?Ct(n):At(n.error??`status ${e.status}`)}catch(e){At(e instanceof Error?e.message:String(e))}finally{Dt(!1)}},[F]),$t=(0,j.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if(tt.has(e.sessionId))return!1;nt(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await F(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),R({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0}),!1}return await t.json(),He(t=>t.filter(t=>t.sessionId!==e.sessionId)),n&&Z(),!0}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),R({message:`Delete failed: ${n}`,failed:!0}),!1}finally{nt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,tt,Z]),en=(0,j.useCallback)(e=>{U(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),tn=(0,j.useCallback)(()=>{it(!1),U(new Set)},[]),nn=(0,j.useCallback)(async()=>{let e=[...H].map(e=>z.find(t=>t.sessionId===e)).filter(e=>!!e),t=(await Promise.all(e.map(e=>$t(e,{refresh:!1})))).filter(Boolean).length,n=e.length-t;n>0&&console.warn(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${t} failed=${n}`),Z(),tn()},[H,z,$t,Z,tn]),rn=(0,j.useCallback)(async(e,t)=>{if(e.stopPropagation(),!K.has(t.sessionId)){ut(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),R({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}Z()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),R({message:`Stop failed: ${n}`,failed:!0})}finally{ut(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,K,Z]),an=(0,j.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!dt.has(t.sessionId)){ft(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),R({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}Z()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),R({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{ft(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,dt,Z]),on=(0,j.useCallback)(async e=>{let t=mt.trim();if(!t){R({message:`Title can’t be empty`,failed:!0});return}if(t.length>Ft){R({message:`Title too long (max ${Ft})`,failed:!0});return}gt(!0);try{let n=await F(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),R({message:`Rename failed: ${r}`,failed:!0});return}pt(null),J(``),Z()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),R({message:`Rename failed: ${n}`,failed:!0})}finally{gt(!1)}},[F,mt,Z]);return(0,A.jsxs)(`aside`,{className:`side`,children:[(0,A.jsxs)(`div`,{className:`side-brand`,children:[Fe?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,className:`side-brand-icon-btn`,"aria-label":`Switch to house account`,disabled:!Ie,onClick:Le,children:(0,A.jsx)(`img`,{className:`side-brand-icon`,src:s,alt:``,"aria-hidden":`true`})}),(0,A.jsxs)(`button`,{type:`button`,className:`side-brand-trigger`,"aria-haspopup":`menu`,"aria-expanded":Ne,"aria-label":`Switch sub-account`,onClick:()=>{let e=!Ne;Pe(e),e&&pe?.()},children:[(0,A.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,A.jsx)(`span`,{className:`side-brand-business`,children:I}),(0,A.jsx)(`span`,{className:`side-brand-product`,children:_.productName})]}),(0,A.jsx)(he,{size:14,className:`side-brand-caret`,"aria-hidden":`true`})]})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`img`,{className:`side-brand-icon`,src:s,alt:``,"aria-hidden":`true`}),(0,A.jsxs)(`span`,{className:`side-brand-lockup`,children:[(0,A.jsx)(`span`,{className:`side-brand-business`,children:I}),(0,A.jsx)(`span`,{className:`side-brand-product`,children:_.productName})]})]}),Ne&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`side-brand-scrim`,"aria-hidden":`true`,onClick:()=>Pe(!1)}),(0,A.jsx)(S,{open:Ne,accounts:k??[],activeAccountId:ue??null,switching:de??!1,onSelect:e=>M?.(e),onClose:()=>Pe(!1)})]})]}),(0,A.jsx)(`nav`,{className:`side-nav`,children:qt.map(e=>(0,A.jsxs)(`button`,{type:`button`,className:`admin-row nav-row${e.active?` active`:``}`,"aria-current":e.active?`page`:void 0,onClick:e.onClick,children:[e.icon,(0,A.jsx)(`span`,{className:`label`,children:e.label}),(0,A.jsx)(`span`,{className:`kbd`})]},e.key))}),(()=>{let e=z.filter(e=>Xe?!0:!e.isSubagent).filter(e=>B?!0:!e.archived),n=z.some(e=>e.isSubagent),r=z.some(e=>e.archived);return(0,A.jsx)(`div`,{className:`side-sessions`,children:(0,A.jsxs)(`div`,{className:`side-list`,children:[(0,A.jsxs)(`div`,{className:`group-head`,children:[(0,A.jsx)(`span`,{children:`Sessions`}),(0,A.jsxs)(`span`,{className:`group-head-meta`,children:[(0,A.jsx)(`button`,{type:`button`,className:`group-head-select${V?` active`:``}`,"aria-pressed":V,title:V?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{it(e=>!e),U(new Set),pt(null),J(``)},children:`Select`}),(0,A.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:zt,disabled:Je,children:(0,A.jsx)(ae,{size:12,className:Je?`spinning`:void 0})}),(0,A.jsx)(`span`,{children:Je?`…`:String(e.length)}),(0,A.jsxs)(`button`,{type:`button`,className:`admin-btn-cta side-sessions-new`,onClick:()=>{X(!0)},disabled:Y,"aria-busy":Y,"aria-label":Y?`Spawning session`:`New session`,title:Y?`Spawning session`:`New session`,children:[Y?(0,A.jsx)(t,{size:13,className:`spinning`}):(0,A.jsx)(g,{size:13}),(0,A.jsx)(`span`,{children:Y?`Spawning…`:`New session`})]})]})]}),V&&(0,A.jsxs)(`div`,{className:`session-select-bar`,children:[(0,A.jsxs)(`span`,{className:`session-select-count`,children:[H.size,` selected`]}),(0,A.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:H.size===0,onClick:()=>W(!0),children:[`Delete `,H.size]}),(0,A.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:tn,children:`Cancel`})]}),$e&&(0,A.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,A.jsx)(`code`,{children:$e})}),(n||r)&&(0,A.jsxs)(`div`,{className:`artefact-filter-chips`,children:[n&&(0,A.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Xe?` active`:``}`,"aria-pressed":Xe,onClick:()=>Ze(e=>!e),title:Xe?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,A.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${B?` active`:``}`,"aria-pressed":B,onClick:()=>Qe(e=>!e),title:B?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),Ke&&(0,A.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:Ke}),We&&!Ke&&e.length===0&&(0,A.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Rt(e.startedAt),n=ct.has(e.sessionId),r=tt.has(e.sessionId),a=K.has(e.sessionId),o=dt.has(e.sessionId),s=n||r||a||o,c=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},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,A.jsx)(ge,{size:12}),busy:n,onClick:()=>{Jt(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,A.jsx)(ye,{size:12}),onClick:()=>{c()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,A.jsx)(_e,{size:12}),onClick:t=>{Qt(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,A.jsx)(h,{size:12}),busy:a,onClick:t=>{rn(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,A.jsx)(N,{size:12}),busy:o,onClick:t=>{an(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,A.jsx)(fe,{size:12}),busy:o,onClick:t=>{an(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,A.jsx)(i,{size:12}),busy:ht&&q===e.sessionId,onClick:t=>{t.stopPropagation(),pt(e.sessionId),J(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,A.jsx)(oe,{size:12}),danger:!0,busy:r,onClick:t=>{Zt(t,e)}},Te({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})],u=e.channel===`whatsapp`?` conv-channel-whatsapp`:e.channel===`telegram`?` conv-channel-telegram`:``,d=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`,f=re.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?E({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title,channel:e.channel}):e.personName??e.title;return(0,A.jsxs)(`div`,{ref:t=>{let n=rt.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${u}${e.sessionId===Ue?` active`:``}`,children:[(0,A.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${f} in webchat`,onClick:()=>{if(q!==e.sessionId){if(V){en(e.sessionId);return}c()}},onKeyDown:t=>{q!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),V?en(e.sessionId):c())},children:[V&&(0,A.jsx)(`span`,{className:`conv-select-check`,onClick:e=>e.stopPropagation(),children:(0,A.jsx)(le,{checked:H.has(e.sessionId),ariaLabel:`Select ${f}`,onChange:()=>en(e.sessionId)})}),(0,A.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"data-archived":e.archived?`1`:`0`,"aria-label":e.archived?`archived session`:e.live?`live session`:`ended session`}),(0,A.jsxs)(`span`,{className:`conv-stack`,children:[(0,A.jsxs)(`span`,{className:`conv-name-line`,children:[d&&(0,A.jsx)(D,{channel:e.channel,size:13}),q===e.sessionId?(0,A.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:mt,disabled:ht,"aria-label":`New title for session ${e.title}`,onChange:e=>J(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),on(e)):t.key===`Escape`&&(t.preventDefault(),pt(null),J(``))},onBlur:()=>{q===e.sessionId&&!ht&&(pt(null),J(``))}}):(0,A.jsx)(`span`,{className:`conv-name`,title:f,children:f})]}),(0,A.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,A.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,A.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!V&&(0,A.jsx)(at,{actions:l,disabled:s})]},e.sessionId)})]})})})(),(0,A.jsxs)(`div`,{className:`side-foot`,children:[(0,A.jsx)(`div`,{className:`avatar`,children:p?(0,A.jsx)(`img`,{src:p,alt:De}):Oe}),(0,A.jsxs)(`div`,{className:`who`,children:[(0,A.jsx)(`span`,{className:`name`,children:De}),(0,A.jsx)(Vt,{})]}),(0,A.jsx)(`button`,{type:`button`,className:`side-foot-kebab`,"aria-label":`Account menu`,"aria-haspopup":`menu`,"aria-expanded":je,onClick:()=>Me(e=>!e),children:(0,A.jsx)(P,{size:16})}),je&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`side-foot-menu-scrim`,"aria-hidden":`true`,onClick:()=>Me(!1)}),(0,A.jsx)(`div`,{className:`side-foot-menu`,role:`menu`,children:(0,A.jsx)(C,{variant:`admin`,onCloseMenu:()=>Me(!1),onLogout:te??(()=>{}),onDisconnect:ne,disconnecting:O,claudeConnected:ie,onConnectClaude:c,cacheKey:o,onOpenConversations:be})})]})]}),L&&(0,A.jsx)(`div`,{className:`copy-toast${L.failed?` copy-toast-failed`:``}`,role:`status`,children:L.message}),(0,A.jsx)(wt,{open:Mt,pending:Y,onConfirm:e=>{Xt(e)},onCancel:e=>{X(!1)}}),(0,A.jsx)(Et,{error:Re,onClose:()=>ze(null)}),(0,A.jsx)(Ot,{open:Be,onConnect:()=>{Ve(!1),c?.()},onClose:()=>Ve(!1)}),(0,A.jsx)(bt,{target:G,anchorEl:G?rt.current.get(G.sessionId)??null:null,onCancel:()=>st(null),onConfirm:()=>{let e=G;st(null),e&&$t(e)}},G?.sessionId??`none`),(0,A.jsx)(St,{open:ot,count:H.size,liveCount:z.filter(e=>H.has(e.sessionId)&&e.live).length,onConfirm:()=>{W(!1),nn()},onCancel:()=>W(!1)}),(0,A.jsx)(Nt,{show:vt!==null,onClose:()=>{yt(null),Ct(null),At(null)},anchorEl:vt?rt.current.get(vt.sessionId)??null:null,sessionId:vt?.sessionId??null,summary:xt,loading:Tt,error:kt},vt?.sessionId??`none`)]})}var zt=5e3,Bt=3e4;function Vt(){let[e,t]=(0,j.useState)(null);if((0,j.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()},zt))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=[`system-stats`];return c&&d.push(`system-stats--warn`),l&&d.push(`system-stats--crit`),(0,A.jsxs)(`span`,{className:d.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,A.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),` · `,(0,A.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]})]})}var Ht=`maxy-shell-browser-px`;function Q(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .side`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function Ut(){return typeof window>`u`?360:Wt(Math.round((window.innerWidth-Q())/2))}function Wt(e){if(typeof window>`u`)return e;let t=Math.max(360,window.innerWidth-Q()-480);return Math.min(Math.max(e,360),t)}function Gt(){if(typeof window>`u`)return 360;try{let e=window.localStorage.getItem(Ht);if(!e)return Ut();let t=parseInt(e,10);return Number.isFinite(t)?Wt(t):(console.warn(`[admin-ui] browser-width-parse-failed stored=${JSON.stringify(e)}`),Ut())}catch{return Ut()}}function Kt({targetSelector:e=`.platform`}={}){let t=(0,j.useRef)(null),n=(0,j.useRef)(360),[,r]=(0,j.useState)(0),i=(0,j.useCallback)(t=>{n.current=t;let i=document.querySelector(e);i instanceof HTMLElement&&i.style.setProperty(`--artefact-px`,`${t}px`),r(e=>e+1)},[e]);(0,j.useLayoutEffect)(()=>{i(Gt())},[i]),(0,j.useEffect)(()=>{let e=()=>i(Wt(n.current));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[i]);let a=e=>{e.preventDefault();let r=t.current;if(!r)return;r.setPointerCapture(e.pointerId),r.classList.add(`dragging`);let a=!1,o=e=>{a=!0,i(Wt(Math.round(window.innerWidth-e.clientX)))},s=()=>{if(r.releasePointerCapture(e.pointerId),r.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),a)try{window.localStorage.setItem(Ht,String(n.current))}catch{}};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},o=()=>{i(Ut());try{window.localStorage.removeItem(Ht)}catch{}};return(0,A.jsx)(`div`,{ref:t,className:`browser-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize browser`,onPointerDown:a,onDoubleClick:o})}var $=1;function qt(e){let t=e.className,n=(typeof t==`string`?t:t?.baseVal??``).trim().split(/\s+/).filter(Boolean);return[e.tagName.toUpperCase(),...n].join(`.`)}function Jt(e,t){let n=t.extent-t.vw;return n<$?null:{op:`layout-overflow`,route:e,vw:t.vw,extent:Math.round(t.extent),delta:Math.round(n),offender:t.offender??``}}function Yt(e,t){if(!e||!t)return null;let n=e.documentElement?.clientWidth??0;if(n<=0)return null;let r=n,i=null;for(let t of Array.from(e.body?.querySelectorAll(`*`)??[])){let e=t.getBoundingClientRect().right;e>=r&&e>n+.5&&(r=e,i=qt(t))}return{vw:n,extent:r,offender:i}}function Xt(e){return e?`${e.route}|${e.delta}|${e.offender}`:null}function Zt(e,t){if(!t)return;let n=Jt(e,t);if(n)try{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`layout-overflow`,...n}),keepalive:!0}).catch(()=>{})}catch{}}function Qt(e,t,n=400){let r=0,i,a=0,o=null,s=()=>{if(a>=5)return;let n=t.location.pathname,r=Yt(e,t),i=Xt(r&&Jt(n,r));if(!i){o=null;return}i!==o&&(o=i,a+=1,Zt(n,r))},c=()=>{t.cancelAnimationFrame(r),r=t.requestAnimationFrame(s)},l=()=>{i!==void 0&&clearTimeout(i),i=setTimeout(c,n)};c(),t.addEventListener(`resize`,c);let u=new MutationObserver(l);return e.body&&u.observe(e.body,{childList:!0,subtree:!0}),()=>{t.cancelAnimationFrame(r),i!==void 0&&clearTimeout(i),t.removeEventListener(`resize`,c),u.disconnect()}}function $t(e){return e.supported?e.secureContext?e.permission===`denied`?{show:!1,reason:`permission-denied`}:e.permission===`granted`?e.focused?{show:!1,reason:`focused`}:{show:!0}:{show:!1,reason:`permission-default`}:{show:!1,reason:`insecure-context`}:{show:!1,reason:`unsupported`}}function en(){let e=typeof window<`u`&&`Notification`in window;return{supported:e,secureContext:typeof window<`u`&&window.isSecureContext===!0,permission:e?Notification.permission:`default`,focused:typeof document<`u`&&typeof document.hasFocus==`function`?document.hasFocus():!0}}var tn=500,nn=new Set,rn=new Set;function an(e,t){if(e.size>=tn){for(let t of e)if(e.delete(t),e.size<tn)break}e.add(t)}function on(e){return e??(typeof globalThis.fetch==`function`?globalThis.fetch:void 0)}function sn(e,t,n){try{Promise.resolve(e(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:t,fields:n})})).catch(()=>{})}catch{}}function cn(e,t){let n=on(t);return n?(sn(n,`wa-notify:desktop-capability`,{supported:e.supported,secure:e.secureContext,permission:e.permission}),!0):!1}function ln(e,t,n,r){if(nn.has(e))return!1;let i=on(r);return i?(an(nn,e),sn(i,`wa-notify:desktop-outcome`,{msgId:e,senderType:t,reason:n}),!0):!1}function un(e,t,n){try{if(rn.has(e.waMessageId))return;an(rn,e.waMessageId);let r=$t(en());if(!r.show){ln(e.waMessageId,e.senderType,r.reason,n);return}new Notification(`${e.accountName} · ${e.senderDisplay}`,{body:e.body+(e.truncated?`…`:``),icon:t,tag:e.waMessageId}),ln(e.waMessageId,e.senderType,`shown`,n)}catch{ln(e.waMessageId,e.senderType,`construct-failed`,n)}}var dn=`admin-sidebar-collapsed`,fn=`admin-sidebar-drawer-open`,pn=1080;function mn(){if(typeof window>`u`)return!1;let e=null;try{e=window.sessionStorage.getItem(dn)}catch{e=null}return e===null?typeof window.matchMedia==`function`?window.matchMedia(`(min-width: 721px) and (max-width: ${pn}px)`).matches:!1:e===`1`}function hn(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(dn,`1`):window.sessionStorage.removeItem(dn)}catch{}}function gn(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(fn)===`1`}catch{return!1}}function _n(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(fn,`1`):window.sessionStorage.removeItem(fn)}catch{}}function vn(e){let[t,n]=(0,j.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,j.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var yn=720;function bn(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function xn(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function Sn(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function Cn(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function wn(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:e===`activity`?`/activity`:`/browser`}var Tn=`maxy-webchat-browser-pane`;function En(){try{let e=window.localStorage.getItem(Tn);return e===`split`||e===`full`?e:`closed`}catch{return`closed`}}function Dn(){return typeof window<`u`&&window.location.pathname.startsWith(`/chat`)}function On(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:l,onConnectClaude:u,userName:d,userAvatar:f,role:p,onOpenConversations:m,children:h,footer:g}=e,{subAccounts:_,activeAccountId:y,switching:b,switchAccount:x,refreshAccounts:S}=ie(t),[C,w]=(0,j.useState)([]),[T,te]=(0,j.useState)(!1),[E,D]=(0,j.useState)(`closed`);(0,j.useEffect)(()=>{let e=Dn();te(e),e&&D(En())},[]);let O=(0,j.useCallback)(e=>{D(e);try{window.localStorage.setItem(Tn,e)}catch{}},[]),re=(0,j.useCallback)(()=>O(`split`),[O]),ae=(0,j.useCallback)(()=>{O(E===`full`?`split`:`full`)},[E,O]),oe=(0,j.useCallback)(()=>O(`closed`),[O]),se=T?E:`closed`,ce=se!==`closed`,k=(0,j.useCallback)(e=>{w(t=>t.filter(t=>t.waMessageId!==e))},[]);(0,j.useEffect)(()=>{if(!t)return;let e=null;try{e=new EventSource(c(`/api/admin/events`,t)),e.addEventListener(Ge,e=>{try{let t=JSON.parse(e.data);if(!t||typeof t.waMessageId!=`string`)return;w(e=>e.some(e=>e.waMessageId===t.waMessageId)?e:[...e,t]),un(t,s)}catch{}}),e.onerror=()=>{console.error(`[admin-ui] wa-notify stream error`)}}catch(e){console.error(`[admin-ui] wa-notify unavailable reason=${e instanceof Error?e.message:String(e)}`)}return()=>{e?.close()}},[t]),(0,j.useEffect)(()=>{cn(en())},[]);let[le,ue]=(0,j.useState)(!0);(0,j.useEffect)(()=>{if(l!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||ue(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[l,r]);let de=l??le,M=u??(()=>{window.location.assign(`/?connect=claude`)}),[N,fe]=(0,j.useState)(()=>mn()),[pe,me]=(0,j.useState)(!1),he=(0,j.useRef)(!0);(0,j.useEffect)(()=>{if(he.current){he.current=!1;return}me(!0);let e=setTimeout(()=>me(!1),260);return()=>clearTimeout(e)},[N]);let[P,ge]=(0,j.useState)(()=>gn()),_e=vn(`(max-width: ${yn}px)`),[ve,ye]=(0,j.useState)(()=>typeof window>`u`||Cn(window.location.pathname,window.location.search)?null:Sn(window.location.pathname,window.location.search)),[be,F]=(0,j.useState)(()=>typeof window>`u`?!1:Cn(window.location.pathname,window.location.search)),[xe]=(0,j.useState)(()=>be),Se=(0,j.useCallback)(e=>{hn(e),fe(e)},[]),Ce=(0,j.useCallback)(e=>{_n(e),ge(e)},[]);(0,j.useEffect)(()=>{typeof window>`u`||window.location?.pathname},[]),(0,j.useEffect)(()=>{typeof window>`u`||!ve||window.history.replaceState(null,``,`/`)},[]),(0,j.useEffect)(()=>{typeof window>`u`||!be||window.history.replaceState(null,``,`/`)},[]);let we=(0,j.useCallback)(e=>{if(F(!1),e===null){ye(null);return}let t=bn(typeof window<`u`?window.location.pathname:`/`,e);t.via===`in-place`?ye(e):window.location.href=t.href},[]),Te=(0,j.useCallback)(()=>{let e=xn(typeof window<`u`?window.location.pathname:`/`);if(e.via===`navigate`){window.location.href=e.href;return}ye(null),F(!0)},[]),Ee=_e?P:!N,I=(0,j.useCallback)(()=>{typeof window>`u`||(window.matchMedia(`(max-width: ${yn}px)`).matches?Ce(!P):Se(!N))},[N,P,Se,Ce]);(0,j.useEffect)(()=>{if(!(typeof window>`u`))return Qt(document,window)},[]);let De=(0,j.useCallback)(e=>{let t=wn(e,r);window.location.href=t},[r]),Oe={collapsed:N,mobileDrawerOpen:P,sidebarOpen:Ee,onToggleSidebar:I,setMobileDrawerOpen:Ce,selectedWhatsapp:ve,onClearWhatsapp:()=>ye(null),onSelectWhatsappConversation:we,dataOpen:be};return r===`operator`?(0,A.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[b&&(0,A.jsx)(ee,{surface:`switch`}),(0,A.jsx)(ne,{businessName:n,variant:r,onNavigate:De,onOpenConversations:m,onToggleSidebar:I,sidebarOpen:Ee,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:_,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:S}),(0,A.jsx)(`div`,{className:`platform platform-operator`,children:typeof h==`function`?h(Oe):h}),(0,A.jsx)(B,{variant:`operator`,onOpenConversations:m}),g,(0,A.jsx)(We,{frames:C,onExpire:k})]}):(0,A.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[b&&(0,A.jsx)(ee,{surface:`switch`}),(0,A.jsxs)(`div`,{className:`platform${P?` menu-open`:``}${!_e&&N?` sidebar-collapsed`:``}${pe?` sidebar-animating`:``}`,"data-artefact":ce?`browser`:`closed`,"data-browser-pane":se,children:[(0,A.jsx)(Z,{businessName:n,cacheKey:t,onConnectClaude:M,role:p??null,userName:d,userAvatar:f??null,onSelectProjects:()=>{window.location.href=`/graph?label=${v().label}`},onSelectTasks:()=>{window.location.href=`/tasks`},onCloseMobileDrawer:()=>Ce(!1),collapsed:N,mobileDrawerOpen:P,onSelectData:Te,onCloseData:()=>F(!1),initialDataSurface:xe,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:de,subAccounts:_,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:S,onOpenConversations:m}),!_e&&(0,A.jsx)(nt,{}),(0,A.jsx)(Je,{sidebarOpen:Ee,onToggleSidebar:I,claudeConnected:de,onConnectClaude:M,onOpenBrowser:T&&!ce?re:void 0}),typeof h==`function`?h(Oe):h,ce&&(0,A.jsxs)(`div`,{className:`webchat-browser-pane`,children:[se===`split`&&(0,A.jsx)(Kt,{}),(0,A.jsx)(R,{cacheKey:e.cacheKey,surface:`webchat`,onToggleFull:ae,onClosePane:oe,isFull:se===`full`})]})]}),P&&(0,A.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>Ce(!1)}),(0,A.jsx)(B,{}),g,(0,A.jsx)(We,{frames:C,onExpire:k})]})}export{k as A,P as C,N as D,fe as E,M as O,ge as S,me as T,xe as _,Dt as a,ve as b,G as c,ut as d,ct as f,Se as g,we as h,Ot as i,le as k,ot as l,R as m,vn as n,xt as o,at as p,Lt as r,wt as s,On as t,W as u,be as v,he as w,_e as x,ye as y};
|
|
Binary file
|
|
Binary file
|