@rubytech/create-maxy-code 0.1.446 → 0.1.448
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/lib/graph-style/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/graph-style/dist/index.js +6 -0
- package/payload/platform/lib/graph-style/dist/index.js.map +1 -1
- package/payload/platform/lib/graph-style/src/index.ts +7 -0
- package/payload/platform/neo4j/schema.cypher +35 -1
- package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
- package/payload/platform/plugins/admin/hooks/lib/maxy-mcp-plugins.txt +1 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +42 -5
- package/payload/platform/plugins/docs/references/calendar-booking.md +18 -1
- package/payload/platform/plugins/docs/references/claudeai-connectors.md +15 -0
- package/payload/platform/plugins/docs/references/outlook-guide.md +8 -3
- package/payload/platform/plugins/email/skills/email-composition/SKILL.md +4 -4
- package/payload/platform/plugins/memory/references/schema-construction.md +7 -2
- package/payload/platform/plugins/outlook/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/outlook/PLUGIN.md +23 -5
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js +70 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/draft-edit.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.js +22 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/html-to-text.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.js +60 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-delete.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.js +80 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-fetch-body.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.js +90 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-otp-extract.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.js +194 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/mail-reply.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.js +16 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/otp.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.js +103 -0
- package/payload/platform/plugins/outlook/mcp/dist/__tests__/outbound-attachments.test.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/index.js +88 -0
- package/payload/platform/plugins/outlook/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.d.ts +9 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.js +24 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/html-to-text.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.d.ts +2 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.js +49 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/otp.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts +58 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js +127 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/outbound-attachments.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts +28 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js +54 -0
- package/payload/platform/plugins/outlook/mcp/dist/lib/upload-session.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts +21 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js +38 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/draft-edit.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.d.ts +14 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.js +39 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-delete.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.d.ts +23 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.js +44 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-fetch-body.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.d.ts +22 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.js +90 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-otp-extract.js.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.d.ts +27 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.d.ts.map +1 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js +75 -0
- package/payload/platform/plugins/outlook/mcp/dist/tools/mail-reply.js.map +1 -0
- package/payload/platform/plugins/outlook/references/graph-surfaces.md +57 -1
- package/payload/platform/plugins/outlook/skills/outlook/SKILL.md +15 -4
- package/payload/platform/plugins/scheduling/PLUGIN.md +15 -0
- package/payload/platform/plugins/scheduling/mcp/dist/index.js +29 -1
- package/payload/platform/plugins/scheduling/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js +53 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/__tests__/booking-reconcile.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts +21 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js +80 -0
- package/payload/platform/plugins/scheduling/mcp/dist/lib/booking-reconcile.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts +4 -0
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js +68 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/reconcile-bookings.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.d.ts +2 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js +75 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/__tests__/schedule-connector-busy-sync.test.js.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts +31 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.d.ts.map +1 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js +41 -0
- package/payload/platform/plugins/scheduling/mcp/dist/tools/schedule-connector-busy-sync.js.map +1 -0
- package/payload/platform/plugins/voice-mirror/.claude-plugin/plugin.json +21 -0
- package/payload/platform/plugins/voice-mirror/PLUGIN.md +72 -0
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/index.js +10 -10
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/index.js.map +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/neo4j.d.ts +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/neo4j.js +4 -4
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/neo4j.js.map +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-record-feedback.js +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-record-feedback.js.map +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/package-lock.json +2 -2
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/package.json +1 -1
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/scripts/smoke.mjs +9 -9
- package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/skills/voice-mirror/SKILL.md +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +12 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/templates/agents/admin/AGENTS.md +1 -1
- package/payload/platform/templates/specialists/agents/content-producer.md +1 -1
- package/payload/platform/templates/specialists/agents/personal-assistant.md +6 -2
- package/payload/premium-plugins/writer-craft/.claude-plugin/plugin.json +1 -14
- package/payload/premium-plugins/writer-craft/PLUGIN.md +2 -51
- package/payload/server/public/assets/{AdminLoginScreens-D9L-CuWi.js → AdminLoginScreens-Bvf4HKmq.js} +1 -1
- package/payload/server/public/assets/AdminShell-CaGc8ODG.js +2 -0
- package/payload/server/public/assets/{Checkbox-CFdt8ljo.js → Checkbox-2SswiICc.js} +1 -1
- package/payload/server/public/assets/admin-B7GPCzpr.js +1 -0
- package/payload/server/public/assets/browser-CodHC_MO.js +1 -0
- package/payload/server/public/assets/calendar-DH7cyXKF.js +1 -0
- package/payload/server/public/assets/chat-BQyPAEMv.js +1 -0
- package/payload/server/public/assets/chevron-left-Cmev0R9v.js +1 -0
- package/payload/server/public/assets/data-DWxZzMfL.js +1 -0
- package/payload/server/public/assets/{graph-DrE7KupQ.js → graph-BToB78LG.js} +2 -2
- package/payload/server/public/assets/graph-labels-JRGrstzM.js +1 -0
- package/payload/server/public/assets/maximize-2-CEQRv64B.js +1 -0
- package/payload/server/public/assets/operator-Cx8cq2wf.js +1 -0
- package/payload/server/public/assets/page-D6kzsk18.js +32 -0
- package/payload/server/public/assets/page-TCsQy4eP.js +1 -0
- package/payload/server/public/assets/public-B61xcmAr.js +1 -0
- package/payload/server/public/assets/{rotate-ccw-Cqp4oqHV.js → rotate-ccw-7_3ol0Z4.js} +1 -1
- package/payload/server/public/assets/{tasks-bQKOhMga.js → tasks-BY9ajKXf.js} +1 -1
- package/payload/server/public/assets/{time-entry-format-BIL4ZaDK.js → time-entry-format-DmNhIJnM.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-C5-GOl5l.js +1 -0
- package/payload/server/public/assets/useSelectionMode-UOUVnP9B.js +1 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-CVHKTSst.css → useSubAccountSwitcher-DgM1ergs.css} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-BAP3yGxs.js +2 -0
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +6 -6
- package/payload/server/public/chat.html +12 -12
- package/payload/server/public/data.html +10 -10
- package/payload/server/public/graph.html +11 -11
- package/payload/server/public/index.html +13 -13
- package/payload/server/public/operator.html +14 -14
- package/payload/server/public/public.html +12 -12
- package/payload/server/public/tasks.html +5 -5
- package/payload/server/server.js +349 -171
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts +0 -8
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js +0 -71
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/package.json +0 -7
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js +0 -196
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js.map +0 -1
- package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/package.json +0 -7
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts +0 -3
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js +0 -58
- package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js.map +0 -1
- package/payload/premium-plugins/writer-craft/mcp/src/index.ts +0 -457
- package/payload/premium-plugins/writer-craft/mcp/src/lib/neo4j.ts +0 -56
- package/payload/premium-plugins/writer-craft/mcp/src/lib/voice-corpus.ts +0 -154
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +0 -833
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-ingest-session-text.ts +0 -153
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +0 -148
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +0 -270
- package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +0 -181
- package/payload/premium-plugins/writer-craft/mcp/tsconfig.json +0 -8
- package/payload/server/public/assets/AdminShell-DSQrvZXq.js +0 -2
- package/payload/server/public/assets/admin-Ch4n-G0j.js +0 -1
- package/payload/server/public/assets/browser-B2AIxiuk.js +0 -1
- package/payload/server/public/assets/calendar-BvItH3B0.js +0 -1
- package/payload/server/public/assets/chat-eQFMaX9y.js +0 -1
- package/payload/server/public/assets/chevron-left-D2AnCEyE.js +0 -1
- package/payload/server/public/assets/data-BzOmbHoe.js +0 -1
- package/payload/server/public/assets/file-download-CK9j_Jx2.js +0 -1
- package/payload/server/public/assets/graph-labels-CwEtvIRV.js +0 -1
- package/payload/server/public/assets/maximize-2-CuzEom3K.js +0 -1
- package/payload/server/public/assets/operator-DlboYPPu.js +0 -1
- package/payload/server/public/assets/page-BuWH5gNK.js +0 -1
- package/payload/server/public/assets/page-Co9E8U5x.js +0 -32
- package/payload/server/public/assets/public-DtFpPMTG.js +0 -1
- package/payload/server/public/assets/useCopyFeedback-rB8QuqyH.js +0 -1
- package/payload/server/public/assets/useVoiceRecorder-Ctny8qWx.js +0 -2
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/lib/mcp-spawn-tee/index.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/lib/mcp-spawn-tee/package.json +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/index.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/index.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/neo4j.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/voice-corpus.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/voice-corpus.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/voice-corpus.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/lib/voice-corpus.js.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-distil-profile.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-distil-profile.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-distil-profile.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-distil-profile.js.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-ingest-session-text.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-ingest-session-text.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-ingest-session-text.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-ingest-session-text.js.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-record-feedback.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-record-feedback.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-retrieve-conditioning.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-retrieve-conditioning.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-retrieve-conditioning.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-retrieve-conditioning.js.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-tag-content.d.ts +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-tag-content.d.ts.map +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-tag-content.js +0 -0
- /package/payload/{premium-plugins/writer-craft → platform/plugins/voice-mirror}/mcp/dist/tools/voice-tag-content.js.map +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-CHEt_m6q.js → useSubAccountSwitcher-DF6bohQA.js} +0 -0
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* voice-tag-content — set `authorshipMode` and `format` on one or many
|
|
3
|
-
* content nodes.
|
|
4
|
-
*
|
|
5
|
-
* The tool routes through neo4j directly with an account-scoped MERGE so
|
|
6
|
-
* the operator can only mutate their own nodes. We do not go through
|
|
7
|
-
* `memory-update` because that tool re-embeds and re-validates on every
|
|
8
|
-
* call — overkill for a single-property authorship stamp.
|
|
9
|
-
*
|
|
10
|
-
* `format` is an editorial classification only the operator can set; it is
|
|
11
|
-
* therefore required. The sole hard-coded exception lives in
|
|
12
|
-
* `voice-ingest-session-text`, which stamps `format='text'` on auto-ingested
|
|
13
|
-
* `:Message` rows where the operator is not in the loop (Task 471).
|
|
14
|
-
*/
|
|
15
|
-
import { getSession } from "../lib/neo4j.js";
|
|
16
|
-
import {
|
|
17
|
-
TAGGABLE_PRIMARY_LABELS,
|
|
18
|
-
FORMAT_VALUES,
|
|
19
|
-
type VoiceFormat,
|
|
20
|
-
} from "../lib/voice-corpus.js";
|
|
21
|
-
|
|
22
|
-
export type AuthorshipMode =
|
|
23
|
-
| "human-only"
|
|
24
|
-
| "human-led-agent-assisted"
|
|
25
|
-
| "agent-led-human-reviewed"
|
|
26
|
-
| "agent-only"
|
|
27
|
-
| "unknown";
|
|
28
|
-
|
|
29
|
-
export const AUTHORSHIP_MODES: ReadonlySet<AuthorshipMode> = new Set([
|
|
30
|
-
"human-only",
|
|
31
|
-
"human-led-agent-assisted",
|
|
32
|
-
"agent-led-human-reviewed",
|
|
33
|
-
"agent-only",
|
|
34
|
-
"unknown",
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Resolve the corpus author for a tag write (Task 676). An explicit, non-blank
|
|
39
|
-
* `author` wins; otherwise the tagging operator's `userId`. Throws when neither
|
|
40
|
-
* is available (no `author` argument and no `ADMIN_USER_ID` in spawn env), so a
|
|
41
|
-
* tag can never silently land with a null author.
|
|
42
|
-
*
|
|
43
|
-
* This is why single-operator accounts get personal attribution for free: with
|
|
44
|
-
* `author` omitted, the sole operator is the implicit author, so their personal
|
|
45
|
-
* corpus equals the account-wide corpus and prior behaviour is reproduced.
|
|
46
|
-
*/
|
|
47
|
-
export function resolveVoiceAuthor(
|
|
48
|
-
author: string | undefined,
|
|
49
|
-
operatorUserId: string | null,
|
|
50
|
-
): string {
|
|
51
|
-
const explicit = (author ?? "").trim();
|
|
52
|
-
if (explicit) return explicit;
|
|
53
|
-
if (operatorUserId) return operatorUserId;
|
|
54
|
-
throw new Error(
|
|
55
|
-
"voice-tag-content: author required — no ADMIN_USER_ID in spawn env and no author given.",
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface VoiceTagContentParams {
|
|
60
|
-
nodeIds: string[];
|
|
61
|
-
mode: AuthorshipMode;
|
|
62
|
-
accountId: string;
|
|
63
|
-
/** Writing format (required). Editorial classification — operator-supplied. */
|
|
64
|
-
format: VoiceFormat;
|
|
65
|
-
/**
|
|
66
|
-
* The corpus author (a userId) to stamp on each node (Task 676). Resolve via
|
|
67
|
-
* `resolveVoiceAuthor` before calling — explicit author, else the tagging
|
|
68
|
-
* operator. Personal distillation filters on this; org distillation ignores
|
|
69
|
-
* it (account-wide).
|
|
70
|
-
*/
|
|
71
|
-
voiceAuthor: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface VoiceTagContentResult {
|
|
75
|
-
updated: number;
|
|
76
|
-
skipped: number;
|
|
77
|
-
skippedReasons: Record<string, number>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function voiceTagContent(
|
|
81
|
-
params: VoiceTagContentParams,
|
|
82
|
-
): Promise<VoiceTagContentResult> {
|
|
83
|
-
const { nodeIds, mode, accountId, format, voiceAuthor } = params;
|
|
84
|
-
|
|
85
|
-
if (!AUTHORSHIP_MODES.has(mode)) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`voice-tag-content: invalid authorshipMode '${mode}'. Valid values: ${[
|
|
88
|
-
...AUTHORSHIP_MODES,
|
|
89
|
-
].join(", ")}`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
if (!accountId) {
|
|
93
|
-
throw new Error("voice-tag-content: accountId is required");
|
|
94
|
-
}
|
|
95
|
-
if (format === undefined || format === null) {
|
|
96
|
-
throw new Error("voice-tag-content: format is required");
|
|
97
|
-
}
|
|
98
|
-
if (!(FORMAT_VALUES as readonly string[]).includes(format)) {
|
|
99
|
-
throw new Error(
|
|
100
|
-
`voice-tag-content: invalid format '${format}'. Valid values: ${FORMAT_VALUES.join(", ")}`,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
if (!Array.isArray(nodeIds) || nodeIds.length === 0) {
|
|
104
|
-
return { updated: 0, skipped: 0, skippedReasons: {} };
|
|
105
|
-
}
|
|
106
|
-
// voiceAuthor is checked after the empty-nodeIds early return: an empty tag is
|
|
107
|
-
// a no-op, so there is nothing to attribute. With nodes to tag, the author
|
|
108
|
-
// must be resolved (index.ts always supplies it via resolveVoiceAuthor).
|
|
109
|
-
if (!voiceAuthor) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
"voice-tag-content: voiceAuthor is required (resolve via resolveVoiceAuthor before calling).",
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const session = getSession();
|
|
116
|
-
const now = new Date().toISOString();
|
|
117
|
-
const skippedReasons: Record<string, number> = {};
|
|
118
|
-
let updated = 0;
|
|
119
|
-
|
|
120
|
-
try {
|
|
121
|
-
// Bulk update in batches of 50 to keep transaction latency bounded.
|
|
122
|
-
const BATCH = 50;
|
|
123
|
-
for (let i = 0; i < nodeIds.length; i += BATCH) {
|
|
124
|
-
const batch = nodeIds.slice(i, i + BATCH);
|
|
125
|
-
const result = await session.run(
|
|
126
|
-
// Tag any of the three primary content labels, or a conversation-
|
|
127
|
-
// document :Section chunk (parent :KnowledgeDocument carries
|
|
128
|
-
// `conversationIdentity`). The EXISTS sub-pattern guards against
|
|
129
|
-
// accidentally tagging document-path :Section rows AND parent
|
|
130
|
-
// `:Conversation` / `:AdminConversation` nodes (which are not
|
|
131
|
-
// body-bearing content).
|
|
132
|
-
`UNWIND $ids AS id
|
|
133
|
-
MATCH (n) WHERE elementId(n) = id AND n.accountId = $accountId
|
|
134
|
-
WITH n
|
|
135
|
-
WHERE any(lbl IN labels(n) WHERE lbl IN $primaryLabels)
|
|
136
|
-
OR ('Section' IN labels(n) AND EXISTS {
|
|
137
|
-
MATCH (parent:KnowledgeDocument)-[:HAS_SECTION]->(n)
|
|
138
|
-
WHERE parent.conversationIdentity IS NOT NULL
|
|
139
|
-
})
|
|
140
|
-
SET n.authorshipMode = $mode,
|
|
141
|
-
n.authorshipTaggedAt = $now,
|
|
142
|
-
n.format = $format,
|
|
143
|
-
n.voiceAuthor = $voiceAuthor
|
|
144
|
-
RETURN elementId(n) AS id`,
|
|
145
|
-
{
|
|
146
|
-
ids: batch,
|
|
147
|
-
accountId,
|
|
148
|
-
mode,
|
|
149
|
-
now,
|
|
150
|
-
format,
|
|
151
|
-
voiceAuthor,
|
|
152
|
-
primaryLabels: [...TAGGABLE_PRIMARY_LABELS],
|
|
153
|
-
},
|
|
154
|
-
);
|
|
155
|
-
const matched = new Set(result.records.map((r) => r.get("id") as string));
|
|
156
|
-
updated += matched.size;
|
|
157
|
-
for (const id of batch) {
|
|
158
|
-
if (matched.has(id)) continue;
|
|
159
|
-
const reason = "not-found-or-not-content-label";
|
|
160
|
-
skippedReasons[reason] = (skippedReasons[reason] ?? 0) + 1;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
} finally {
|
|
164
|
-
await session.close();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Tagging is always a personal-attribution act: every tagged node carries an
|
|
168
|
-
// author and feeds both that author's personal walk and the account-wide org
|
|
169
|
-
// walk. There is no org-only corpus node, so scope is constant `personal`.
|
|
170
|
-
process.stderr.write(
|
|
171
|
-
`[voice-tag] mode=${mode} format=${format} scope=personal author=${voiceAuthor} accountId=${accountId} updated=${updated} skipped=${
|
|
172
|
-
nodeIds.length - updated
|
|
173
|
-
}\n`,
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
updated,
|
|
178
|
-
skipped: nodeIds.length - updated,
|
|
179
|
-
skippedReasons,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,T as n,_ as r,a as i,b as a,d as o,g as s,i as c,l,m as u,n as d,o as f,p,s as m,t as h,u as g,x as _}from"./useSubAccountSwitcher-CHEt_m6q.js";import{a as ee,d as v,f as te,l as ne,m as re,n as ie,o as y,p as ae,s as oe,u as se}from"./file-download-CK9j_Jx2.js";async function b(){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 x=e(t(),1),S=_(),C={sm:14,md:16,lg:18},w={sm:30,md:38,lg:46};function T({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=C[t],h={...e===`send`?{width:w[t],height:w[t]}:{},...u},g=Object.keys(h).length>0;return(0,S.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,S.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,S.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,S.jsx)(n,{size:m})]}),i&&(0,S.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var ce=s(`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`}]]),E=s(`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`}]]),D=s(`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`}]]),le=s(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),ue=s(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),de=s(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),fe=s(`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`}]]),pe=s(`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`}]]),O=s(`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`}]]),me=s(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),k=`maxy-shell-side-px`;function A(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function j(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-A());return Math.min(Math.max(e,248),n)}function he(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(k);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 j(t)}catch{}return 264}function ge({targetSelector:e=`.platform`}){let t=(0,x.useRef)(null),[n,r]=(0,x.useState)(()=>he()),i=(0,x.useRef)(n);(0,x.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,x.useCallback)(()=>{r(e=>{let t=j(e);return t===e?e:t})},[]);(0,x.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(j(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(k,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=j(264);r(e);try{window.localStorage.removeItem(k)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,S.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var M=n();function _e({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,x.useRef)(null),[s,c]=(0,x.useState)({position:`fixed`,visibility:`hidden`}),l=(0,x.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,x.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,x.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,M.createPortal)((0,S.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function ve({actions:e,disabled:t}){let[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),o=(0,x.useRef)(null),s=(0,x.useCallback)(()=>{r(!1),a(null)},[]);return(0,S.jsxs)(`div`,{className:`conv-actions`,children:[(0,S.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,S.jsx)(g,{size:12})}),n&&(0,S.jsx)(_e,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,S.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,S.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,S.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,S.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,S.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,S.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var N=`claude-opus-4-8[1m]`,P=`claude-sonnet-5`,F=`claude-haiku-4-5`,I={[N]:`Opus 4.8 (1M context)`,[P]:`Sonnet 5`,[F]:`Haiku 4.5`};function L(e){return I[e]??e}var R=[N,P,F];function z(e){return e.replace(/\[1m\]$/,``)}function ye(e){return R.find(t=>z(t)===z(e))??e}var be=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...be],[...B],[...B];var xe=[N,P,F],Se={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Ce=be.map(e=>({value:e,label:Se[e]??e})),we={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},Te=B.map(e=>({value:e,label:we[e]??e}));function V(e){if(e){let t=xe.find(t=>z(t)===z(e));if(t)return t}return N}function Ee({row:e,adminFetch:t,onError:n}){let[r,i]=(0,x.useState)(()=>V(e.model)),[a,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(``),[u,d]=(0,x.useState)(!1),f=(0,x.useRef)(!1);(0,x.useEffect)(()=>{i(V(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...c?{effort:c}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`label`,{className:`reseat-field`,children:[(0,S.jsx)(`span`,{children:`Model`}),(0,S.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:xe.map(e=>(0,S.jsx)(`option`,{value:e,children:L(e)},e))})]}),(0,S.jsxs)(`label`,{className:`reseat-field`,children:[(0,S.jsx)(`span`,{children:`Mode`}),(0,S.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>s(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:`Keep current`}),Ce.map(e=>(0,S.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,S.jsxs)(`label`,{className:`reseat-field`,children:[(0,S.jsx)(`span`,{children:`Effort`}),(0,S.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,S.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,S.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function H(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 De(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function U(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Oe({target:e,onConfirm:t,onCancel:n}){return e?(0,S.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,S.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,S.jsxs)(`div`,{className:`claude-info-header`,children:[(0,S.jsx)(`span`,{children:`Delete this conversation?`}),(0,S.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,S.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,S.jsx)(T,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,S.jsx)(T,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var ke=`auth-refresh-failed`;function Ae({error:e,onClose:t}){if(!e)return null;let n=e.reason===ke,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,S.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,S.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,S.jsxs)(`div`,{className:`claude-info-header`,children:[(0,S.jsx)(`span`,{children:r}),(0,S.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,S.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,S.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function je(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,x.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,S.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,S.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`claude-info-header`,children:[(0,S.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,S.jsx)(`span`,{children:`Claude Code`}),(0,S.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,children:[(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,S.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,S.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,S.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,S.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,children:[(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:p>0?De(p):`—`})]}),(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,S.jsx)(`span`,{className:`claude-info-value`,children:H(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,S.jsxs)(`div`,{className:`claude-info-row`,children:[(0,S.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,S.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 U(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Me({open:e,onConnect:t,onClose:n}){return e?(0,S.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,S.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,S.jsxs)(`div`,{className:`claude-info-header`,children:[(0,S.jsx)(`span`,{children:`Claude isn’t connected`}),(0,S.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,S.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,S.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,S.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,S.jsx)(T,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,S.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function W(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 Ne(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function G(e){return e.toLocaleString(`en-GB`)}function K(e){return`£${e.toFixed(2)}`}function Pe(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 4.8 (GBP)`,`Sonnet 4.6 (GBP)`],n=(e,t)=>[e,W(Ne(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 q({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,S.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,S.jsx)(r,{className:`usage-day`,children:e}),(0,S.jsx)(r,{children:W(Ne(t))}),(0,S.jsx)(r,{children:G(t.tokens.output)}),(0,S.jsx)(r,{children:G(t.tokens.input)}),(0,S.jsx)(r,{children:G(t.tokens.cacheWrite)}),(0,S.jsx)(r,{children:G(t.tokens.cacheRead)}),(0,S.jsx)(r,{children:K(t.costGBP.opus)}),(0,S.jsx)(r,{children:K(t.costGBP.sonnet)})]})}function Fe({show:e,onClose:t,sessionId:n,summary:r,loading:a,error:o}){if(!e)return null;let s=!!r&&r.days.length>0,c=()=>{if(!r)return;let e=new Blob([Pe(r)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),i=document.createElement(`a`);i.href=t,i.download=`usage-${n?n.slice(0,8):`session`}.csv`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(t)};return(0,S.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,S.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,S.jsxs)(`div`,{className:`claude-info-header`,children:[(0,S.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),s&&(0,S.jsx)(`button`,{className:`usage-download`,onClick:c,"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,S.jsx)(re,{size:14})}),(0,S.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,S.jsx)(i,{size:14})})]}),(0,S.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[a&&(0,S.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!a&&o&&(0,S.jsx)(`div`,{className:`usage-note usage-error`,children:o}),!a&&!o&&r&&r.days.length===0&&(0,S.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!a&&!o&&r&&r.days.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`usage-table-scroll`,children:(0,S.jsxs)(`table`,{className:`usage-table`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,S.jsx)(`th`,{children:`Active`}),(0,S.jsx)(`th`,{children:`Output tok`}),(0,S.jsx)(`th`,{children:`Input tok`}),(0,S.jsx)(`th`,{children:`Cache write`}),(0,S.jsx)(`th`,{children:`Cache read`}),(0,S.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,S.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,S.jsxs)(`tbody`,{children:[r.days.map(e=>(0,S.jsx)(q,{label:e.date,d:e},e.date)),(0,S.jsx)(q,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,S.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,r.pricing.opusPriceDate,` · £/$ `,r.pricing.usdPerGbp,` · Sonnet tokenizer factor `,r.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})})}var Ie=`https://claude.ai/code`,Le=200,Re=[500,1e3,1500,2e3,2500,3e3,3e3];function ze(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:`${Ie}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Be(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ve(e){let{businessName:t,cacheKey:n,onConnectClaude:i,role:o,userName:s,userAvatar:d,onSelectProjects:h,onSelectPeople:g,onSelectTasks:_,onSelectAgents:b,onCloseMobileDrawer:C,collapsed:w,selectedWhatsappId:T,onSelectWhatsappConversation:k,initialWhatsappSurface:A=!1,onSelectData:j,onCloseData:he,initialDataSurface:ge=!1}=e,M=c(n),_e=(0,x.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,S.jsx)(O,{size:12}),panel:()=>(0,S.jsx)(Ee,{row:e,adminFetch:M,onError:e=>H({message:e,failed:!0})})}),[M]),N=r.productName,P=typeof s==`string`?s:s===null?`name unavailable`:t||N,F=(P.trim().charAt(0)||`?`).toUpperCase(),[I,L]=(0,x.useState)(ge?`data`:A?`whatsapp`:`sessions`),[R,z]=(0,x.useState)([]),[ye,be]=(0,x.useState)(!1),[B,xe]=(0,x.useState)(null),[Se,Ce]=(0,x.useState)(!1),[we,Te]=(0,x.useState)(`file`),[V,H]=(0,x.useState)(null),[De,U]=(0,x.useState)(null),[ke,je]=(0,x.useState)(!1),[W,Ne]=(0,x.useState)([]),[G]=(0,x.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[K,Pe]=(0,x.useState)(!1),[q,Ie]=(0,x.useState)(null),[Ve,He]=(0,x.useState)(!1),[J,Ke]=(0,x.useState)(!1),[Y,qe]=(0,x.useState)(!1),[Je,Ye]=(0,x.useState)(null),[X,Xe]=(0,x.useState)(new Set),[Ze,Qe]=(0,x.useState)(null),[$e,et]=(0,x.useState)(new Set),[tt,nt]=(0,x.useState)(new Set),[rt,it]=(0,x.useState)(new Set),[at,ot]=(0,x.useState)(null),[st,Z]=(0,x.useState)(``),[ct,lt]=(0,x.useState)(!1),[ut,dt]=(0,x.useState)(null),[ft,pt]=(0,x.useState)(null),[mt,ht]=(0,x.useState)(!1),[gt,_t]=(0,x.useState)(null),[vt,yt]=(0,x.useState)(!1),bt=(0,x.useRef)(0),[xt,St]=(0,x.useState)([]),[Ct,wt]=(0,x.useState)(!1),[Tt,Et]=(0,x.useState)(null),[Dt,Ot]=(0,x.useState)(`whatsapp`),kt=(0,x.useCallback)(e=>{if(C(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),H({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),H({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ie(n,e.downloadPath,e.downloadRoot??`data`),H({message:`Downloading ${e.name}`,failed:!1})},[n,C]);(0,x.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>H(null),2500);return()=>clearTimeout(e)},[V]);let At=G!=null&&W.some(e=>e.sessionId===G);(0,x.useEffect)(()=>{G==null||!K||console.info(`[sidebar-sessions] op=select-highlight session=${G.slice(0,8)} matched=${At}`)},[G,At,K]);let jt=(0,x.useCallback)(async()=>{if(n){Ce(!0),xe(null);try{let e=await M(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);z((await e.json()).artefacts??[]),be(!0)}catch(e){let t=e instanceof Error?e.message:String(e);xe(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Ce(!1)}}},[n,M]),Q=(0,x.useCallback)(async()=>{if(!n)return null;let e=++bt.current;He(!0),Ie(null);try{let t=await M(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===bt.current?(Ne(r),Ye(n.accountId??null),Pe(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===bt.current&&Ie(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===bt.current&&He(!1)}},[n,M]),Mt=(0,x.useCallback)(async()=>{if(n){Et(null);try{let e=await M(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);St((await e.json()).conversations??[]),wt(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Et(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,M]);(0,x.useEffect)(()=>{!n||K||Q()},[n,K,Q]),(0,x.useEffect)(()=>{if(!n)return;let e=null;return Mt(),e=setInterval(()=>{Mt()},Ue),()=>{e!==null&&clearInterval(e)}},[n,Mt]),(0,x.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,We))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let Nt=(0,x.useMemo)(()=>{let e=new Map;for(let t of y)e.set(t,[]);for(let t of xt)e.get(t.channel)?.push(t);for(let t of y)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[xt]),Pt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Ft=()=>{k(null),L(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${ye?R.length:0} collapsed=${w}`),jt()},$=1.5,It=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),jt()},Lt=()=>{k(null),L(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${K?W.length:0} collapsed=${w}`),K||Q()},Rt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},zt=()=>{L(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${w}`),j(),C()},Bt=e=>{he?.(),L(`whatsapp`),Ot(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Nt.get(e)?.length??0} collapsed=${w}`)},Vt=(0,x.useCallback)(async e=>{if($e.has(e.sessionId))return;et(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=ze(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(C(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),U(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),U({sessionId:e.sessionId,reason:r})}finally{et(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,C,$e]),Ht=(0,x.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Re.length;n++){await new Promise(e=>setTimeout(e,Re[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Ut=(0,x.useCallback)(async()=>{if(!vt){yt(!0);try{let e=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=ze(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Ht(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),je(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),U(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),U({sessionId:null,reason:t})}finally{yt(!1)}}},[M,vt,Ht]),Wt=(0,x.useCallback)((e,t)=>{e.stopPropagation(),Qe(t)},[]),Gt=(0,x.useCallback)(async(e,t)=>{e.stopPropagation(),dt(t),pt(null),_t(null),ht(!0);try{let e=await M(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?pt(n):_t(n.error??`status ${e.status}`)}catch(e){_t(e instanceof Error?e.message:String(e))}finally{ht(!1)}},[M]),Kt=(0,x.useCallback)(async e=>{if(!X.has(e.sessionId)){Xe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await M(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),H({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Ne(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),H({message:`Delete failed: ${n}`,failed:!0})}finally{Xe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[M,X,Q]),qt=(0,x.useCallback)(async(e,t)=>{if(e.stopPropagation(),!tt.has(t.sessionId)){nt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),H({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),H({message:`Stop failed: ${n}`,failed:!0})}finally{nt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,tt,Q]),Jt=(0,x.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!rt.has(t.sessionId)){it(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{it(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,rt,Q]),Yt=(0,x.useCallback)(async e=>{let t=st.trim();if(!t){H({message:`Title can’t be empty`,failed:!0});return}if(t.length>Le){H({message:`Title too long (max ${Le})`,failed:!0});return}lt(!0);try{let n=await M(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),H({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),ot(null),Z(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),H({message:`Rename failed: ${n}`,failed:!0})}finally{lt(!1)}},[M,st,Q]);return(0,S.jsxs)(`aside`,{className:`side`,children:[(0,S.jsx)(`div`,{className:`side-new-session-row`,children:(0,S.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Ut,disabled:vt,"aria-busy":vt,children:[(0,S.jsx)(te,{size:14}),(0,S.jsx)(`span`,{children:vt?`Spawning…`:`New session`})]})}),(0,S.jsxs)(`nav`,{className:`side-nav`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),g(),C()},children:[(0,S.jsx)(me,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`People`}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),b(),C()},children:[(0,S.jsx)(D,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`Agents`}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),h(),C()},children:[(0,S.jsx)(le,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:a().term}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),_(),C()},children:[(0,S.jsx)(fe,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row${I===`artefacts`?` active`:``}`,onClick:Ft,children:[(0,S.jsx)(ae,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row${I===`sessions`?` active`:``}`,onClick:Lt,children:[(0,S.jsx)(de,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,S.jsx)(`span`,{className:`kbd`})]}),(0,S.jsxs)(`button`,{type:`button`,className:`nav-row${I===`data`?` active`:``}`,onClick:zt,children:[(0,S.jsx)(u,{size:20,strokeWidth:$}),(0,S.jsx)(`span`,{className:`label`,children:`Data`}),(0,S.jsx)(`span`,{className:`kbd`})]}),Ct&&y.filter(e=>Nt.get(e).length>0).map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`nav-row${I===`whatsapp`&&Dt===e?` active`:``}`,onClick:()=>Bt(e),children:[(0,S.jsx)(ne,{channel:e,size:16}),(0,S.jsx)(`span`,{className:`label`,children:Pt[e]}),(0,S.jsx)(`span`,{className:`kbd`})]},e)),Tt&&(0,S.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,S.jsx)(`span`,{className:`label`,children:Tt})})]}),I===`artefacts`&&(0,S.jsxs)(`div`,{className:`side-list`,children:[(0,S.jsxs)(`div`,{className:`group-head`,children:[(0,S.jsx)(`span`,{children:`Artefacts`}),(0,S.jsxs)(`span`,{className:`group-head-meta`,children:[(0,S.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:It,disabled:Se,children:(0,S.jsx)(v,{size:12,className:Se?`spinning`:void 0})}),(0,S.jsx)(`span`,{children:Se?`…`:String(R.length)})]})]}),B&&(0,S.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:B}),ye&&!B&&R.length>0&&(()=>{let e=R.filter(e=>e.kind===`agent-template`).length,t=R.length-e;return(0,S.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:R.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${we===e.key?` active`:``}`,onClick:()=>Te(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,S.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),ye&&!B&&R.length===0&&(0,S.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),R.filter(e=>we===`all`?!0:we===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?D:ae,r=Be(e.updatedAt),i=e.downloadPath!==null;return(0,S.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>kt(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,S.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,S.jsxs)(`span`,{className:`conv-stack`,children:[(0,S.jsx)(`span`,{className:`conv-name-line`,children:(0,S.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,S.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,S.jsx)(re,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),I===`sessions`&&(()=>{let e=W.filter(e=>J?!0:!e.isSubagent).filter(e=>Y?!0:!e.archived),t=W.some(e=>e.isSubagent),n=W.some(e=>e.archived);return(0,S.jsxs)(`div`,{className:`side-list`,children:[(0,S.jsxs)(`div`,{className:`group-head`,children:[(0,S.jsx)(`span`,{children:`Sessions`}),(0,S.jsxs)(`span`,{className:`group-head-meta`,children:[(0,S.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Rt,disabled:Ve,children:(0,S.jsx)(v,{size:12,className:Ve?`spinning`:void 0})}),(0,S.jsx)(`span`,{children:Ve?`…`:String(e.length)})]})]}),Je&&(0,S.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,S.jsx)(`code`,{children:Je})}),(t||n)&&(0,S.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,S.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${J?` active`:``}`,"aria-pressed":J,onClick:()=>Ke(e=>!e),title:J?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,S.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Y?` active`:``}`,"aria-pressed":Y,onClick:()=>qe(e=>!e),title:Y?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),q&&(0,S.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:q}),K&&!q&&e.length===0&&(0,S.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Be(e.startedAt),n=$e.has(e.sessionId),r=X.has(e.sessionId),i=tt.has(e.sessionId),a=rt.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},c=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,S.jsx)(p,{size:12}),busy:n,onClick:()=>{Vt(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,S.jsx)(pe,{size:12}),onClick:()=>{s()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,S.jsx)(ue,{size:12}),onClick:t=>{Gt(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,S.jsx)(m,{size:12}),busy:i,onClick:t=>{qt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,S.jsx)(ce,{size:12}),busy:a,onClick:t=>{Jt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,S.jsx)(E,{size:12}),busy:a,onClick:t=>{Jt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,S.jsx)(l,{size:12}),busy:ct&&at===e.sessionId,onClick:t=>{t.stopPropagation(),ot(e.sessionId),Z(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,S.jsx)(f,{size:12}),danger:!0,busy:r,onClick:t=>{Wt(t,e)}},_e({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`,h=y.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?ee({operatorName:e.personName??null,whatsappName:null,senderId:e.senderId,title:e.title}):e.personName??e.title;return(0,S.jsxs)(`div`,{className:`conv conv-with-actions${u}${e.sessionId===G?` active`:``}`,children:[(0,S.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${h} in webchat`,onClick:()=>{at!==e.sessionId&&s()},onKeyDown:t=>{at!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s())},children:[(0,S.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,S.jsxs)(`span`,{className:`conv-stack`,children:[(0,S.jsxs)(`span`,{className:`conv-name-line`,children:[d&&(0,S.jsx)(se,{channel:e.channel,size:13}),at===e.sessionId?(0,S.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:st,disabled:ct,"aria-label":`New title for session ${e.title}`,onChange:e=>Z(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Yt(e)):t.key===`Escape`&&(t.preventDefault(),ot(null),Z(``))},onBlur:()=>{at===e.sessionId&&!ct&&(ot(null),Z(``))}}):(0,S.jsx)(`span`,{className:`conv-name`,title:h,children:h})]}),(0,S.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,S.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,S.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,S.jsx)(ve,{actions:c,disabled:o})]},e.sessionId)})]})})(),I===`whatsapp`&&(0,S.jsxs)(`div`,{className:`side-list`,children:[(0,S.jsxs)(`div`,{className:`group-head`,children:[(0,S.jsx)(`span`,{children:Pt[Dt]}),(0,S.jsxs)(`span`,{className:`group-head-meta`,children:[(0,S.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Mt()},children:(0,S.jsx)(v,{size:12})}),(0,S.jsx)(`span`,{children:String(Nt.get(Dt).length)})]})]}),Nt.get(Dt).map(e=>{let t=Be(e.lastMessageAt),n=oe(e);return(0,S.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${T===n?` active`:``}`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{k(e),C()},title:e.title,children:[(0,S.jsx)(ne,{channel:e.channel,size:14}),(0,S.jsxs)(`span`,{className:`conv-stack`,children:[(0,S.jsx)(`span`,{className:`conv-name-line`,children:(0,S.jsx)(`span`,{className:`conv-name`,children:ee(e)})}),t&&(0,S.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,S.jsx)(ve,{actions:[_e({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,S.jsx)(Ge,{}),(0,S.jsxs)(`div`,{className:`side-foot`,children:[(0,S.jsx)(`div`,{className:`avatar`,children:d?(0,S.jsx)(`img`,{src:d,alt:P}):F}),(0,S.jsxs)(`div`,{className:`who`,children:[(0,S.jsx)(`span`,{className:`name`,children:P}),(0,S.jsx)(`span`,{className:`role`,children:o??`operator`})]})]}),V&&(0,S.jsx)(`div`,{className:`copy-toast${V.failed?` copy-toast-failed`:``}`,role:`status`,children:V.message}),(0,S.jsx)(Ae,{error:De,onClose:()=>U(null)}),(0,S.jsx)(Me,{open:ke,onConnect:()=>{je(!1),i?.()},onClose:()=>je(!1)}),(0,S.jsx)(Oe,{target:Ze,onCancel:()=>Qe(null),onConfirm:()=>{let e=Ze;Qe(null),e&&Kt(e)}}),(0,S.jsx)(Fe,{show:ut!==null,onClose:()=>{dt(null),pt(null),_t(null)},sessionId:ut?.sessionId??null,summary:ft,loading:mt,error:gt})]})}var He=5e3,Ue=3e4,We=3e4;function Ge(){let[e,t]=(0,x.useState)(null);if((0,x.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()},He))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,S.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,S.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,S.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,S.jsx)(`div`,{className:`system-stats__bar`,children:(0,S.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,S.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,S.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,S.jsx)(`div`,{className:`system-stats__bar`,children:(0,S.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var J=`admin-sidebar-collapsed`,Ke=`admin-sidebar-drawer-open`;function Y(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(J)===`1`}catch{return!1}}function qe(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(J,`1`):window.sessionStorage.removeItem(J)}catch{}}function Je(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ke)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ke,`1`):window.sessionStorage.removeItem(Ke)}catch{}}function X(e){let[t,n]=(0,x.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,x.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 Xe=720;function Ze(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function Qe(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function $e(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 et(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function tt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function nt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:o,disconnecting:s,claudeConnected:c,onConnectClaude:l,userName:u,userAvatar:f,role:p,onOpenConversations:m,children:g,footer:_}=e,{subAccounts:ee,activeAccountId:v,switching:te,switchAccount:ne,refreshAccounts:re}=h(t),[ie,y]=(0,x.useState)(!0);(0,x.useEffect)(()=>{if(c!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||y(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[c,r]);let ae=c??ie,se=l??(()=>{window.location.assign(`/?connect=claude`)}),[b,C]=(0,x.useState)(()=>Y()),[w,T]=(0,x.useState)(()=>Je()),ce=X(`(max-width: ${Xe}px)`),[E,D]=(0,x.useState)(()=>typeof window>`u`||et(window.location.pathname,window.location.search)?null:$e(window.location.pathname,window.location.search)),[le]=(0,x.useState)(()=>E!==null),[ue,de]=(0,x.useState)(()=>typeof window>`u`?!1:et(window.location.pathname,window.location.search)),[fe]=(0,x.useState)(()=>ue),pe=(0,x.useCallback)(e=>{qe(e),C(e)},[]),O=(0,x.useCallback)(e=>{Ye(e),T(e)},[]);(0,x.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${b} drawer=${w}`)},[]),(0,x.useEffect)(()=>{typeof window>`u`||!E||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${E.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,x.useEffect)(()=>{typeof window>`u`||!ue||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let me=(0,x.useCallback)(e=>{if(de(!1),e===null){D(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Ze(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?D(e):window.location.href=n.href},[]),k=(0,x.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=Qe(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}D(null),de(!0)},[]),A=ce?w:!b,j=(0,x.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${Xe}px)`).matches){let e=w;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),O(!e)}else{let e=b;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),pe(!e)}},[b,w,pe,O]),he=(0,x.useCallback)(e=>{let t=tt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),M={collapsed:b,mobileDrawerOpen:w,sidebarOpen:A,onToggleSidebar:j,setMobileDrawerOpen:O,selectedWhatsapp:E,onClearWhatsapp:()=>D(null),dataOpen:ue};return r===`operator`?(0,S.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,S.jsx)(d,{businessName:n,variant:r,onNavigate:he,onOpenConversations:m,onToggleSidebar:j,sidebarOpen:A,onLogout:i,onDisconnect:o,disconnecting:s,cacheKey:t,subAccounts:ee,activeAccountId:v,switchingAccount:te,onSwitchAccount:ne,refreshAccounts:re}),(0,S.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(M):g}),_]}):(0,S.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,S.jsx)(d,{businessName:n,variant:r,onNavigate:he,onOpenConversations:m,onToggleSidebar:j,sidebarOpen:A,onLogout:i,onDisconnect:o,disconnecting:s,claudeConnected:ae,onConnectClaude:se,cacheKey:t,subAccounts:ee,activeAccountId:v,switchingAccount:te,onSwitchAccount:ne,refreshAccounts:re}),(0,S.jsxs)(`div`,{className:`platform${w?` menu-open`:``}${b?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,S.jsx)(Ve,{businessName:n,cacheKey:t,onConnectClaude:se,role:p??null,userName:u,userAvatar:f??null,onSelectProjects:()=>{window.location.href=`/graph?label=${a().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/tasks`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>O(!1),collapsed:b,mobileDrawerOpen:w,selectedWhatsappId:E?oe(E):null,onSelectWhatsappConversation:me,initialWhatsappSurface:le,onSelectData:k,onCloseData:()=>de(!1),initialDataSurface:fe}),!ce&&(0,S.jsx)(ge,{}),typeof g==`function`?g(M):g]}),w&&(0,S.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>O(!1)}),_]})}export{E as _,je as a,b,N as c,L as d,me as f,D as g,ue as h,Me as i,P as l,fe as m,X as n,U as o,O as p,ze as r,F as s,nt as t,ye as u,ce as v,T as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,r as n,w as r,x as i}from"./useSubAccountSwitcher-CHEt_m6q.js";import{n as a,t as o}from"./AdminLoginScreens-D9L-CuWi.js";import{s}from"./useVoiceRecorder-Ctny8qWx.js";import{a as c,t as l}from"./AdminShell-DSQrvZXq.js";import"./Checkbox-CFdt8ljo.js";import{n as u,r as d}from"./page-BuWH5gNK.js";import{a as f,s as p}from"./file-download-CK9j_Jx2.js";import"./graph-labels-CwEtvIRV.js";var m=r(),h=e(t(),1),g=i();function _({onOpen:e}){return(0,g.jsx)(`footer`,{className:`admin-footer`,children:(0,g.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,g.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function v(){let e=a(),[t,r]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=(0,h.useCallback)(async()=>{let t=e.claudeInfo!=null;if(r(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let n=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-n}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-n} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),m=(0,h.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,g.jsx)(n,{cacheKey:e.cacheKey,onSessionExpired:m,surface:`chat`,children:(0,g.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_,{onOpen:i}),(0,g.jsx)(c,{show:t,onClose:()=>r(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,g.jsx)(g.Fragment,{children:t.dataOpen&&e.cacheKey?(0,g.jsx)(u,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,g.jsx)(d,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:f(t.selectedWhatsapp),sessionKey:e.cacheKey},p(t.selectedWhatsapp)):(0,g.jsx)(s,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,forceDeliveredOnly:!0},p(t.selectedWhatsapp)):(0,g.jsx)(`main`,{})})})}):(0,g.jsx)(o,{auth:e})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(v,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,_ as n,d as r,f as i,g as a,i as o,p as s,r as c,w as l,x as u}from"./useSubAccountSwitcher-CHEt_m6q.js";import{b as d,t as f}from"./AdminShell-DSQrvZXq.js";import"./file-download-CK9j_Jx2.js";var p=a(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=l(),h=e(t(),1),g=u(),_=`maxy-vnc-popout`;function v(){let[e,t]=(0,h.useState)(null),[a,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),d=o(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(n=>{e||(console.info(`[browser-page] op=viewer-probe available=${n.ok}`),t(n.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),t(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(n.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{c(!0),u(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:a,children:[a?(0,g.jsx)(r,{size:14,className:`spin`}):(0,g.jsx)(i,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(s,{size:14}),` Pop out`]}),l&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:l})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,t]=(0,h.useState)(null),[n,a]=(0,h.useState)(!1),[o,s]=(0,h.useState)(void 0),[l,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),a(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&s(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),a(!0)}}).catch(()=>{e||(t(n),a(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(c,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:o,sessionId:l,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(i,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(i,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{C as t,E as n,a as r,d as i,g as a,l as o,o as s,p as c,r as l,w as u,x as d}from"./useSubAccountSwitcher-CHEt_m6q.js";import{b as f,f as p,t as m}from"./AdminShell-DSQrvZXq.js";import{t as h}from"./chevron-left-D2AnCEyE.js";import{m as g}from"./file-download-CK9j_Jx2.js";var _=a(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=a(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=a(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=a(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=a(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),ee=a(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=u(),C=e(n(),1);function w(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function T(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function E(e){let t=w(e),n=t.getDay();return T(t,n===0?-6:1-n)}function D(e){let t=E(e);return Array.from({length:7},(e,n)=>T(t,n))}function O(e){let t=E(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>T(t,n))}function k(){return Array.from({length:24},(e,t)=>t)}function A(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=w(t);return{from:e,to:T(e,1)}}case`week`:{let e=E(t);return{from:e,to:T(e,7)}}case`month`:{let e=E(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:T(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return T(t,n);case`week`:return T(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=d(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function z({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var B=1440,V=1.8;function H(e){return e.getHours()*60+e.getMinutes()}function U(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function W({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=H(n),o=N(i,e)?H(i):B,s=a/B*100,c=Math.max((o-a)/B*100,V);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:U(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var G=44;function K(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function q({anchor:e,meetings:t,onSelect:n}){let r=D(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${G}px`},children:e===0?``:K(e)},e))}),r.map(e=>(0,F.jsx)(W,{day:e,meetings:t,hourHeight:G,onSelect:n},e.toISOString()))]})]})}var J=52;function Y(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function X({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${J}px`},children:e===0?``:Y(e)},e))}),(0,F.jsx)(W,{day:e,meetings:t,hourHeight:J,onSelect:n})]})]})}var Z=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:A(e).map(e=>{let t=O(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:Z.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(te(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:t,onClose:n,onSaved:a,onDeleted:c}){let l=e.kind===`meeting`,[u,d]=(0,C.useState)(!1),[f,m]=(0,C.useState)(!1),[h,v]=(0,C.useState)(!1),[S,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(e),[k,A]=(0,C.useState)(e.title??``),[j,M]=(0,C.useState)(ie(e.startsAt)),[N,P]=(0,C.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,C.useState)(e.location??``),[R,z]=(0,C.useState)(e.privateNote??``),[B,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``);(0,C.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!S&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,n]);let W=(0,C.useCallback)(()=>{let e={},t=k.trim();t!==(D.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(D.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?D.endsAt!==null:D.endsAt===null||Q(r)!==Q(D.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(D.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(D.privateNote??null)&&(e.privateNote=a),e},[k,j,N,I,R,D]),G=(0,C.useCallback)(async()=>{let n=W();if(Object.keys(n).length===0){d(!1);return}w(!0),E(null);try{let r=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();O(i.meeting),a(i.meeting),d(!1)}catch(e){E(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[t,W,e.meetingId,a]),K=(0,C.useCallback)(async()=>{let n=B.trim(),r=H.trim();if(!(!n&&!r)){w(!0),E(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();O(o.meeting),a(o.meeting),V(``),U(``)}catch(e){E(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[t,B,H,e.meetingId,a]),q=(0,C.useCallback)(async n=>{let r=n.email?{email:n.email}:{name:n.name};w(!0),E(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();O(i.meeting),a(i.meeting)}catch(e){E(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[t,e.meetingId,a]),J=(0,C.useCallback)(async()=>{w(!0),E(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!n.ok)throw Error(`HTTP ${n.status}`);c(e.meetingId)}catch(e){E(e instanceof Error?e.message:`Delete failed`),w(!1)}},[t,e.meetingId,c]),Y=(0,C.useCallback)(async n=>{v(!1),w(!0),E(null);try{let r=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${n?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){E(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[t,e.meetingId]),X=re[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{S||n()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:X}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:S,children:(0,F.jsx)(r,{size:16})})]}),!u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:D.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(D)})]}),D.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:D.location})]}),D.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(p,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:D.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),D.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:D.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:X})]})]}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:S})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[D.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),D.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:S,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(r,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:S,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:S,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:S||!Z,"aria-label":`Add attendee`,children:S?(0,F.jsx)(i,{size:13,className:`spin`}):(0,F.jsx)(ee,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>z(e.target.value),disabled:S,rows:3,placeholder:`Only you and your team can see this.`})]})]}),T&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:T}),l&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&!f&&!h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:S,children:[(0,F.jsx)(o,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:S,children:[(0,F.jsx)(s,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{D.attendees.length>0?v(!0):Y(!1)},disabled:S,children:[S?(0,F.jsx)(i,{size:14,className:`spin`}):(0,F.jsx)(g,{size:14}),` Download`]})]}),h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:S,children:[S?(0,F.jsx)(i,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:S,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:S,children:`Cancel`})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:S,children:[S?(0,F.jsx)(i,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),E(null)},disabled:S,children:`Cancel`})]}),f&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:J,disabled:S,children:[S?(0,F.jsx)(i,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:S,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,C.useState)(null),[n,r]=(0,C.useState)(!1),[a,o]=(0,C.useState)(void 0),[s,c]=(0,C.useState)(null),[u,d]=(0,C.useState)(void 0),[p,h]=(0,C.useState)(null),[g,_]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),d(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,C.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,C.useState)(!1),x=(0,C.useCallback)(async()=>{b(!0);try{let e=await f();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(l,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(m,{cacheKey:e,businessName:a,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:u,userAvatar:p,role:g,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(i,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`calendar`}),[a,o]=(0,C.useState)(`month`),[s,l]=(0,C.useState)(()=>new Date),[u,d]=(0,C.useState)([]),[f,p]=(0,C.useState)(!1),[m,g]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,ee]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return n(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&ee(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[n]),(0,C.useEffect)(()=>{let e=!1,{from:t,to:r}=j(a,s);return p(!0),g(null),n(`/api/admin/calendar/meetings?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();d(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),d([]))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[a,s,r,n]);let S=(0,C.useCallback)(()=>l(new Date),[]),w=(0,C.useCallback)(()=>l(e=>M(a,e,-1)),[a]),T=(0,C.useCallback)(()=>l(e=>M(a,e,1)),[a]),E=(0,C.useCallback)(e=>{l(e),o(`month`)},[]);(0,C.useEffect)(()=>{b(null)},[a,s]);let D=(0,C.useCallback)(e=>{d(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),O=(0,C.useCallback)(e=>{d(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:w,"aria-label":`Previous`,children:(0,F.jsx)(h,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(a,s)}),f&&(0,F.jsx)(i,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===a?` cal-view-btn-active`:``}`,onClick:()=>o(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(c,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[m&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,m]}),a===`day`&&(0,F.jsx)(X,{anchor:s,meetings:u,onSelect:b}),a===`week`&&(0,F.jsx)(q,{anchor:s,meetings:u,onSelect:b}),a===`month`&&(0,F.jsx)(z,{anchor:s,meetings:u,onSelect:b}),a===`year`&&(0,F.jsx)(ne,{anchor:s,meetings:u,onPickMonth:E})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:n,onClose:()=>b(null),onSaved:D,onDeleted:O})]})}(0,S.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{w as e,x as t}from"./useSubAccountSwitcher-CHEt_m6q.js";import"./useVoiceRecorder-Ctny8qWx.js";import"./AdminShell-DSQrvZXq.js";import{n}from"./page-Co9E8U5x.js";import"./useCopyFeedback-rB8QuqyH.js";import"./file-download-CK9j_Jx2.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./useSubAccountSwitcher-CHEt_m6q.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{w as e,x as t}from"./useSubAccountSwitcher-CHEt_m6q.js";import"./useVoiceRecorder-Ctny8qWx.js";import{t as n}from"./page-BuWH5gNK.js";import"./file-download-CK9j_Jx2.js";import"./graph-labels-CwEtvIRV.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e,g as t,x as n}from"./useSubAccountSwitcher-CHEt_m6q.js";var r=t(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),i=t(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),a=t(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),o=t(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),s=t(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),c=n(),l={whatsapp:{fill:`#25D366`,label:`WhatsApp`,path:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.71.306 1.263.489 1.694.625.712.227 1.36.195 1.872.118.571-.085 1.758-.719 2.006-1.413.247-.694.247-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.885-9.885 9.885M20.52 3.449C18.24 1.245 15.24.044 12.045.044 5.463.044.103 5.404.1 11.99c0 2.096.546 4.142 1.588 5.945L0 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.585 0 11.946-5.36 11.949-11.946 0-3.193-1.24-6.19-3.495-8.445`},telegram:{fill:`#229ED9`,label:`Telegram`,path:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`}};function u({channel:e,size:t=16}){let n=l[e];return(0,c.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:n.fill,role:`img`,"aria-label":n.label,className:`channel-icon`,children:(0,c.jsx)(`path`,{d:n.path})})}var d={whatsapp:`whatsapp`,telegram:`telegram`};function f({channel:t,size:n=13}){let r=d[t];return r?(0,c.jsx)(u,{channel:r,size:n}):t===`webchat`?(0,c.jsx)(e,{size:n,className:`channel-icon`,role:`img`,"aria-label":`Web chat`,style:{color:`var(--text-tertiary)`}}):(0,c.jsx)(a,{size:n,className:`channel-icon`,role:`img`,"aria-label":t,style:{color:`var(--text-tertiary)`}})}function p(e){let t=m(e);if(!t.toLowerCase().endsWith(`@g.us`))return!1;let n=t.slice(0,t.length-5);return!n||n.includes(`@`)?!1:/^[0-9]+(-[0-9]+)*$/.test(n)}function m(e){let t=e.trim();for(;;){let e=t;if(t=t.replace(/^whatsapp:/i,``).trim(),t===e)return t}}var h=[`whatsapp`,`telegram`];function g(e){return e.source===`store`?`store:${e.remoteJid??``}`:e.sessionId}var _=[`whatsapp`,`telegram`,`webchat`],v={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`};function y(e){return _.map(t=>({channel:t,label:v[t],rows:e.filter(e=>e.channel===t)})).filter(e=>e.rows.length>0)}function b(e){let t=e.operatorName??e.whatsappName;return t?e.senderId?`${t} ${e.senderId}`:t:e.senderId??e.title}function x(e,t,n=`data`){let r=`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}`+(n===`data`?``:`&root=${encodeURIComponent(n)}`),i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()}function S(e,t){let n=new URLSearchParams;n.set(`session_key`,e);for(let e of t)n.append(`path`,e);let r=document.createElement(`a`);r.href=`/api/admin/files/download-zip?${n.toString()}`,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove()}function C(e,t,n=`data`){return`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}&disposition=inline`+(n===`data`?``:`&root=${encodeURIComponent(n)}`)}export{b as a,p as c,s as d,o as f,y as i,u as l,r as m,x as n,h as o,i as p,S as r,g as s,C as t,f as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./chunk-Ck5AOu5v.js";import{g as t}from"./useSubAccountSwitcher-CHEt_m6q.js";var n=t(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),r=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.FALLBACK_LABEL_SHAPE=e.EXTERNAL_LABEL_SHAPES=e.ALL_GRAPH_LABELS=e.FALLBACK_LABEL_COLOUR=e.GRAPH_LABEL_COLOURS=void 0,e.pickDisplayLabel=t,e.colourForLabel=n,e.shapeForLabel=i,e.resolveNodeColour=a,e.formatRunTimestamp=c,e.formatMessageTimestamp=l,e.pickShortLabel=u,e.pickDisplayName=d,e.GRAPH_LABEL_COLOURS={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Listing:`#3F5670`,Property:`#5C7A99`,Viewing:`#D4A574`,Offer:`#B08850`,Job:`#8C3B2E`,Quote:`#A65A4A`,Invoice:`#6E4A1F`,InboundInvoice:`#6B2A20`,WhatsAppGroup:`#D4A096`,Customer:`#B5503C`,Site:`#C56B4A`,Asset:`#9E4A35`,Visit:`#C77A4E`,Part:`#7A3326`,PurchaseOrder:`#B07050`,PpmContract:`#8A4A3A`,Organization:`#8A6B47`,Person:`#B86E4A`,UserProfile:`#D08960`,Preference:`#DFA67A`,AdminUser:`#8C5230`,AccessGrant:`#66381F`,KnowledgeDocument:`#6E8A5A`,ConversationArchive:`#4F6B3E`,Section:`#8AA876`,Chunk:`#A6C194`,DigitalDocument:`#5A7548`,CreativeWork:`#B5C9A2`,Question:`#C7D6B5`,FAQPage:`#95B385`,DefinedTerm:`#76906A`,Review:`#3F5A2E`,ImageObject:`#A0BB8C`,Conversation:`#6B5A85`,AdminConversation:`#4F4070`,PublicConversation:`#8A75A8`,Message:`#6B7280`,UserMessage:`#DFA67A`,AssistantMessage:`#C9A876`,ToolCall:`#B5ABCB`,Task:`#B0617A`,Project:`#8E4A60`,Event:`#C68095`,Workflow:`#3A6F77`,WorkflowStep:`#5A8E96`,WorkflowRun:`#7AAAB2`,StepResult:`#9CC4CB`,Email:`#6F7F4A`,EmailAccount:`#91A063`,Agent:`#B8893D`,Objective:`#3D5A98`,KeyResult:`#5E7BC4`,Decision:`#7E60B0`,Risk:`#C15B57`,Source:`#2F8FA6`,Finding:`#4FA389`,Hypothesis:`#9A8C3E`},e.FALLBACK_LABEL_COLOUR=`#94A3B8`,e.ALL_GRAPH_LABELS=Object.freeze(Object.keys(e.GRAPH_LABEL_COLOURS));function t(t){for(let n=1;n<t.length;n++)if(Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,t[n]))return t[n];return t[0]??null}function n(t){return e.GRAPH_LABEL_COLOURS[t]??e.FALLBACK_LABEL_COLOUR}e.EXTERNAL_LABEL_SHAPES=[`dot`,`triangle`,`square`,`diamond`,`star`,`triangleDown`,`hexagon`],e.FALLBACK_LABEL_SHAPE=`dot`;var r=(()=>{let t={};return e.ALL_GRAPH_LABELS.forEach((n,r)=>{t[n]=e.EXTERNAL_LABEL_SHAPES[r%e.EXTERNAL_LABEL_SHAPES.length]}),t})();function i(t){return r[t]??e.FALLBACK_LABEL_SHAPE}function a(r){let i=t(r),a=i?n(i):e.FALLBACK_LABEL_COLOUR,o=0;for(let t=1;t<r.length;t++)Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,r[t])&&o++;return{displayLabel:i,colour:a,driftCandidates:o}}var o=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/,s=/^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/;function c(e){let t=e.match(o);return t?`${t[1]} ${t[2]}`:null}function l(e){let t=e.match(s);return t?t[1]:null}function u(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=c(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Message`){let e=typeof t.role==`string`?t.role:``,n=e===`user`?`user`:e===`assistant`?`asst`:e===`system`?`sys`:e===`tool`?`tool`:null,r=typeof t.createdAt==`string`?t.createdAt:``;if(n&&r){let e=l(r);if(e)return`${n} ${e}`}}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.length>24?n.slice(0,24)+`…`:n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function d(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=c(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}})),i=r();Object.freeze(new Set([`Chunk`,`GraphPreference`]));var a=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.Listing.Property.Viewing.Offer.Job.Quote.Invoice.InboundInvoice.WhatsAppGroup.Customer.Site.Asset.Visit.Part.PurchaseOrder.PpmContract.Task.Project.Event.Workflow.Email.EmailAccount.Agent.Objective.KeyResult.Decision.Risk.Source.Finding.Hypothesis`.split(`.`)));Object.freeze(new Set([`ToolCall`,`StepResult`,`WorkflowStep`,`WorkflowRun`])),Object.freeze(new Set([`HAS_TOOL_CALL`,`RUN_OF`,`HAS_STEP`,`HAS_RESULT`]));export{n as i,i as n,r,a as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./useSubAccountSwitcher-CHEt_m6q.js";var t=e(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{E as t,w as n,x as r}from"./useSubAccountSwitcher-CHEt_m6q.js";import{n as i,t as a}from"./AdminLoginScreens-D9L-CuWi.js";import"./useVoiceRecorder-Ctny8qWx.js";import"./AdminShell-DSQrvZXq.js";import"./Checkbox-CFdt8ljo.js";import{t as o}from"./page-Co9E8U5x.js";import"./useCopyFeedback-rB8QuqyH.js";import"./file-download-CK9j_Jx2.js";var s=n(),c=e(t(),1),l=r();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState,console.info(`[operator-ui] op=auth-gate state=${e.appState}`))},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-Ck5AOu5v.js";import{C as t,E as n,a as r,c as i,d as a,g as o,l as s,n as c,o as l,r as u,s as d,t as f,x as p}from"./useSubAccountSwitcher-CHEt_m6q.js";import{S as m,T as h,n as ee,r as g,s as _,w as v,x as te}from"./useVoiceRecorder-Ctny8qWx.js";import{t as y}from"./chevron-left-D2AnCEyE.js";import{a as b,c as x,d as ne,f as re,i as S,m as C,n as ie,p as ae,r as oe,s as w,t as se,u as T}from"./file-download-CK9j_Jx2.js";import{i as E,t as D}from"./graph-labels-CwEtvIRV.js";var ce=o(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),le=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ue=o(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),O=o(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),k=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),de=o(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),fe=o(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),pe=o(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),me=o(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),A=o(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),he=o(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ge=o(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),j=o(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),M=e(n(),1);function _e(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useRef)(null),s=(0,M.useCallback)(e=>{a(null);let n=e.find(e=>!g(e.type,h));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>v);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,M.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,M.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,M.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,M.useCallback)(()=>{r(!1)},[]),onDrop:(0,M.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var N=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function ve(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var P=p();function F({onSelect:e}){return(0,P.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:N.map((t,n)=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function ye({sessionKey:e,onPick:t,onClose:n}){let[i,a]=(0,M.useState)(``),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(!1),f=(0,M.useCallback)(t=>{d(!0),l(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{s(e),a(e.path===`.`?``:e.path)}).catch(e=>l(e instanceof Error?e.message:String(e))).finally(()=>d(!1))},[e]);(0,M.useEffect)(()=>{f(``)},[f]);let p=e=>f(i?`${i}/${e}`:e),m=()=>{let e=i.split(`/`).filter(Boolean);e.pop(),f(e.join(`/`))},h=e=>{let n=e.entryPath??e.name;t({path:i?`${i}/${n}`:n,name:e.displayName??e.name})};return(0,P.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,P.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,P.jsxs)(`div`,{className:`wa-picker-head`,children:[i&&(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:m,"aria-label":`Up one folder`,children:(0,P.jsx)(y,{size:18})}),(0,P.jsx)(`span`,{className:`wa-picker-title`,children:i||`Device storage`}),(0,P.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,P.jsx)(r,{size:18})})]}),c&&(0,P.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:c}),u&&(0,P.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),o&&!u&&(0,P.jsxs)(`ul`,{className:`wa-picker-list`,children:[o.entries.length===0&&(0,P.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),o.entries.map(e=>(0,P.jsx)(`li`,{children:e.kind===`directory`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>p(e.name),children:[(0,P.jsx)(O,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,P.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>h(e),children:[(0,P.jsx)(ae,{size:16,"aria-hidden":!0}),(0,P.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}function be(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function xe({accountId:e,remoteJid:t,sessionKey:n,replyTo:i,onClearReply:a}){let[o,s]=(0,M.useState)(``),[c,u]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(!1),[y,b]=(0,M.useState)(!1),[x,ne]=(0,M.useState)([]),S=(0,M.useRef)(null),{pendingFiles:C,attachError:ie,addFiles:oe,removeFile:w,clearFiles:se}=_e(),{state:T,elapsedSeconds:E,errorMessage:D,start:ce,send:le,discard:ue}=ee(),O=T===`recording`||T===`paused`,de=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=start ms=0`),ce()},[ce]),fe=(0,M.useCallback)(async()=>{let e=E*1e3,t=await le();if(console.info(`[operator-ui] op=voice-record state=stop ms=${e}`),t){let e=t.type===`audio/ogg`?`.ogg`:t.type===`audio/mp4`?`.m4a`:`.webm`;oe([new File([t],`voice-note${e}`,{type:t.type})])}},[E,le,oe]),pe=(0,M.useCallback)(()=>{console.info(`[operator-ui] op=voice-record state=cancel ms=${E*1e3}`),ue()},[E,ue]),he=(0,M.useRef)(!1),ge=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[j,N]=(0,M.useState)(null),[xe,I]=(0,M.useState)(null),L=(0,M.useRef)(null),R=(0,M.useRef)(44),z=(0,M.useCallback)(e=>{let t=L.current;if(!t)return;t.moved=!0;let n=Math.min(ge(),Math.max(44,t.startH+(t.startY-e.clientY)));R.current=n,N(n)},[]),B=(0,M.useCallback)(()=>{let e=L.current?.moved??!1;L.current=null,window.removeEventListener(`pointermove`,z),window.removeEventListener(`pointerup`,B),e&&console.info(`[operator-ui] op=wa-composer-resize mode=drag h=${R.current}`)},[z]),Se=(0,M.useCallback)(e=>{L.current={startY:e.clientY,startH:S.current?.offsetHeight??44,moved:!1},window.addEventListener(`pointermove`,z),window.addEventListener(`pointerup`,B),e.preventDefault()},[z,B]),V=(0,M.useCallback)(e=>{let t=j??S.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(ge(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&(N(n),console.info(`[operator-ui] op=wa-composer-resize mode=key h=${n}`))},[j]),Ce=(0,M.useRef)(``);(0,M.useEffect)(()=>{let e=S.current;if(!e)return;let t=Ce.current!==``&&o===``;if(Ce.current=o,j!==null){t&&N(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(ge(),Math.max(44,e.scrollHeight));e.style.height=n,I(r)},[o,j]);let we=(o.trim().length>0||C.length>0||x.length>0)&&!c,Te=(0,M.useCallback)(async()=>{if(!he.current&&!(o.trim().length===0&&C.length===0&&x.length===0)){he.current=!0,u(!0),p(null);try{let r=`/api/whatsapp-reader/reply?session_key=${encodeURIComponent(n)}`,c;if(C.length>0||x.length>0){let n=new FormData;n.append(`accountId`,e),n.append(`remoteJid`,t),o.trim()&&n.append(`text`,o);for(let e of C)n.append(`files`,e);for(let e of x)n.append(`fileRefs`,e.path);i&&n.append(`quotedId`,i.msgKeyId),c=await fetch(r,{method:`POST`,body:n})}else c=await fetch(r,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({accountId:e,remoteJid:t,text:o,...i?{quotedId:i.msgKeyId}:{}})});let l=await c.json().catch(()=>({}));if(!c.ok){p(l.error??`Send failed.`),console.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${l.error??`unknown`}`);return}s(``),se(),ne([]),a?.(),console.info(`[operator-ui] op=reply-sent remoteJid=${t} sent=${l.sent??0}`)}catch(e){p(`Could not reach the server. Try again.`),console.info(`[operator-ui] op=reply-fail remoteJid=${t} error=${String(e)}`)}finally{he.current=!1,u(!1)}}},[o,C,x,i,a,e,t,n,se]),Ee=(0,M.useCallback)(e=>{let t=S.current,{value:n,caret:r}=ve(o,e,t?t.selectionStart:null,t?t.selectionEnd:null);s(n),g(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[o]),De=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),we&&Te())},H=e=>e.dataTransfer.types.includes(`Files`),Oe=(0,M.useCallback)(e=>{H(e)&&(e.preventDefault(),b(!0))},[]),ke=(0,M.useCallback)(()=>b(!1),[]),Ae=(0,M.useCallback)(e=>{if(!H(e))return;e.preventDefault(),b(!1);let t=[...e.dataTransfer.files];if(t.length===0)return;let n=Math.max(0,C.length+t.length-5);console.info(`[operator-ui] op=composer-drop count=${t.length} rejected=${n}`),oe(t)},[C.length,oe]),je=e=>e.startsWith(`image/`)?(0,P.jsx)(k,{size:14}):e===`application/pdf`?(0,P.jsx)(ae,{size:14}):(0,P.jsx)(m,{size:14});return(0,P.jsxs)(`div`,{className:`wa-reply${y?` wa-reply-drag-over`:``}`,onDragOver:Oe,onDragLeave:ke,onDrop:Ae,children:[_&&(0,P.jsx)(ye,{sessionKey:n,onPick:e=>{ne(t=>[...t,e].slice(0,5)),v(!1)},onClose:()=>v(!1)}),h&&(0,P.jsx)(F,{onSelect:Ee}),f&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:f}),ie&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:ie}),T===`error`&&D&&(0,P.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:D}),(C.length>0||x.length>0)&&(0,P.jsxs)(`div`,{className:`wa-reply-attachments`,children:[C.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip`,children:[je(e.type),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(t),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(r,{size:12})})]},`f-${t}`)),x.map((e,t)=>(0,P.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,P.jsx)(ae,{size:14}),(0,P.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>ne(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,P.jsx)(r,{size:12})})]},`r-${t}`))]}),i&&(0,P.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,P.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,P.jsx)(`span`,{className:`wa-reply-quote-who`,children:i.fromMe?`You`:i.senderName??`Contact`}),(0,P.jsx)(`span`,{className:`wa-reply-quote-text`,children:i.body||`Message`})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>a?.(),"aria-label":`Cancel reply`,children:(0,P.jsx)(r,{size:14})})]}),!O&&(0,P.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:Se,onKeyDown:V}),(0,P.jsx)(`div`,{className:`wa-reply-row`,children:O?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:pe,"aria-label":`Cancel recording`,children:(0,P.jsx)(l,{size:20})}),(0,P.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,P.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),be(E)]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void fe(),"aria-label":`Stop recording`,children:(0,P.jsx)(d,{size:20})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>g(e=>!e),disabled:c,"aria-label":`Emoji`,"aria-expanded":h,children:(0,P.jsx)(A,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>v(!0),disabled:c,"aria-label":`Attach files`,children:(0,P.jsx)(re,{size:22})}),(0,P.jsx)(`textarea`,{ref:S,className:`wa-reply-input`,value:o,rows:1,style:{height:`${j??xe??44}px`},placeholder:`Type a message`,disabled:c,onChange:e=>s(e.target.value),onKeyDown:De}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void de(),disabled:c,"aria-label":`Record voice note`,children:(0,P.jsx)(te,{size:22})}),(0,P.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void Te(),disabled:!we,"aria-label":`Send`,children:(0,P.jsx)(me,{size:20})})]})})]})}function I({accountId:e,remoteJid:t,contactName:n,sessionKey:i,onBack:a}){let o=x(t),s=t.split(`@`)[0],c=o?`Group`:n===`+${s}`?void 0:`+${s}`,[l,u]=(0,M.useState)(!1),[d,f]=(0,M.useState)(``),p=()=>{u(!1),f(``)},[m,h]=(0,M.useState)(null);return(0,P.jsxs)(`div`,{className:`wa-web`,children:[(0,P.jsxs)(`header`,{className:`wa-web-header`,children:[a&&(0,P.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:a,"aria-label":`Back`,children:(0,P.jsx)(y,{size:20})}),(0,P.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,P.jsx)(j,{size:20})}),l?(0,P.jsxs)(`div`,{className:`wa-web-search`,children:[(0,P.jsx)(E,{size:18,"aria-hidden":!0}),(0,P.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p()}}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:p,"aria-label":`Close search`,children:(0,P.jsx)(r,{size:18})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,P.jsx)(`span`,{className:`wa-web-name`,children:n}),c&&(0,P.jsx)(`span`,{className:`wa-web-subtitle`,children:c})]}),(0,P.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>u(!0),"aria-label":`Search messages`,children:(0,P.jsx)(E,{size:20})})]})]}),(0,P.jsx)(`div`,{className:`wa-web-body`,children:(0,P.jsx)(_,{sessionId:``,projectDir:``,sessionKey:i,forceDeliveredOnly:!0,suppressDirectives:!0,store:{accountId:e,remoteJid:t},search:l?d:void 0,onReplyTo:o?void 0:h})}),o?(0,P.jsx)(`p`,{className:`wa-reply wa-reply-readonly`,children:`Group messages are read-only.`}):(0,P.jsx)(xe,{accountId:e,remoteJid:t,sessionKey:i,replyTo:m,onClearReply:()=>h(null)})]})}function L(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||D.has(e)&&(t.add(e),n.push(e)));return n}function R(e){if(!e)return``;let t=new Date(e).getTime();return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function z({conversations:e,sessionKey:t,onBack:n}){let[r,i]=(0,M.useState)(null),a=S(e);return r?r.source===`store`&&r.accountId&&r.remoteJid?(0,P.jsx)(I,{accountId:r.accountId,remoteJid:r.remoteJid,contactName:b(r),sessionKey:t,onBack:()=>i(null)},w(r)):(0,P.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>i(null),"aria-label":`Back to conversations`,children:[(0,P.jsx)(y,{size:16}),` Back`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:b(r)})]}),(0,P.jsx)(_,{sessionId:r.sessionId,projectDir:r.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:r.source===`store`,store:r.source===`store`?{accountId:r.accountId,remoteJid:r.remoteJid}:void 0},w(r))]}):(0,P.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,P.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,P.jsx)(y,{size:16}),` Chat`]}),(0,P.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),a.map(e=>(0,P.jsxs)(`div`,{className:`op-conv-group`,children:[(0,P.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,P.jsx)(T,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{console.info(`[operator-ui] op=reader-open channel=${e.channel} key=${w(e)} readonly=true source=${e.source}`),i(e)},children:[(0,P.jsx)(`span`,{className:`op-conv-name`,children:b(e)}),e.modelGated&&(0,P.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,P.jsx)(he,{size:13})}),(0,P.jsx)(`span`,{className:`op-conv-when`,children:R(e.lastMessageAt)})]},w(e)))]},e.channel))]})}var B=/\.(png|jpe?g|gif|webp|svg)$/i;function Se(e){return B.test(e)}function V(e){return e.entryPath??e.name}var Ce=`maxy-data-view`,we=95*1024*1024,Te=48*1024*1024;function Ee(){return typeof window>`u`?`list`:window.localStorage.getItem(Ce)===`grid`?`grid`:`list`}function De(){let[e,t]=(0,M.useState)(null),[n,r]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,P.jsx)(u,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,P.jsx)(`div`,{className:`data-page data-page-full`,children:(0,P.jsx)(H,{cacheKey:e})})}):(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsxs)(`div`,{className:`data-empty`,children:[(0,P.jsx)(`p`,{children:`You are not signed in.`}),(0,P.jsxs)(`p`,{children:[`Open the `,(0,P.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsxs)(`div`,{className:`data-loading`,children:[(0,P.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function H({cacheKey:e}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i}=t({initialCacheKey:e,surface:`data`});return(0,P.jsx)(Fe,{adminFetch:n,cacheKey:r,sessionRefetchNonce:i})}function Oe(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function ke(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Ae(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function je(e){return new Promise((t,n)=>e.file(t,n))}async function Me(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await je(r),relpath:e});else if(r.isDirectory){let t=await Ae(r.createReader());n.push(...await Me(t,e))}}return n}function Ne(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function Pe({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let[o,c]=(0,M.useState)(``),u=(0,M.useRef)(null),[d,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(null),[h,ee]=(0,M.useState)(`hybrid`),[g,_]=(0,M.useState)(!1),[v,te]=(0,M.useState)(null),[y,b]=(0,M.useState)(null),[x,re]=(0,M.useState)(0),[S,w]=(0,M.useState)(!1),[T,D]=(0,M.useState)(()=>Oe()),[k,me]=(0,M.useState)(null),[A,he]=(0,M.useState)(()=>Ee()),[j,_e]=(0,M.useState)(null),[N,ve]=(0,M.useState)([]),[F,ye]=(0,M.useState)(!1),[be,xe]=(0,M.useState)(null),[I,R]=(0,M.useState)(!1),[z,B]=(0,M.useState)(null),[De,H]=(0,M.useState)(null),[Ae,je]=(0,M.useState)(null),[Pe,Fe]=(0,M.useState)(!1),[Ie,ze]=(0,M.useState)(null),Be=(0,M.useRef)(null),[Ve,U]=(0,M.useState)(0),[We,Ge]=(0,M.useState)(!1),[Ke,qe]=(0,M.useState)(``),[Je,Ye]=(0,M.useState)(null),[Xe,Ze]=(0,M.useState)(``),[Qe,$e]=(0,M.useState)(null),W=(()=>{let e=T===`.`?[]:T.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})(),[et,tt]=(0,M.useState)(!1),nt=(0,M.useRef)(null),[rt,G]=(0,M.useState)(!1),it=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=o.trim();if(!e){f(``),m(null),te(null);return}w(!1);let t=setTimeout(()=>f(e),300);return()=>clearTimeout(t)},[o]),(0,M.useEffect)(()=>{if(!d){_(!1);return}let t=!1;return _(!0),te(null),e(`/api/admin/graph-search?q=${encodeURIComponent(d)}&labels=FileArtifact&limit=20${S?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(m(e.results),ee(e.mode??`hybrid`),re(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||te(e instanceof Error?e.message:String(e))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[d,e,n,S]);let at=(0,M.useMemo)(()=>p?L(p):[],[p]),K=y&&at.includes(y)?y:null,ot=(0,M.useMemo)(()=>p?K?p.filter(e=>e.labels.includes(K)):p:null,[p,K]),st=(0,M.useCallback)(e=>{let n=e.properties.relativePath;if(typeof n!=`string`||n.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[t]);(0,M.useEffect)(()=>{if(!p)return;let e=p.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[p]),(0,M.useEffect)(()=>{let t=!1;return ye(!0),xe(null),e(`/api/admin/files?path=${encodeURIComponent(T===`.`?``:T)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(me(e.entries),ve(e.displayPath??[]))}).catch(e=>{t||(me([]),ve([]),xe(e instanceof Error?e.message:String(e)))}).finally(()=>{t||ye(!1)}),()=>{t=!0}},[e,T,Ve,n]),(0,M.useEffect)(()=>{ke(T)},[T]);let ct=(0,M.useCallback)(()=>{U(e=>e+1)},[]),q=(0,M.useCallback)(e=>{tt(!1),D(e)},[]),lt=(0,M.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),c(``),te(null),b(null),q(r)},[q]),ut=(0,M.useCallback)(()=>{if(T===`.`||T===``)return;let e=T.split(`/`).filter(Boolean);e.pop(),D(e.length===0?`.`:e.join(`/`))},[T]),dt=(0,M.useCallback)(e=>{ie(t,T===`.`?V(e):`${T}/${V(e)}`)},[T,t]),[J,ft]=(0,M.useState)(!1),[Y,pt]=(0,M.useState)(new Set),mt=(0,M.useRef)(null),X=(0,M.useRef)(!1),ht=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,gt=(0,M.useCallback)(e=>{ft(!0),pt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),Z=(0,M.useCallback)(e=>{ft(!1),pt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Q=(0,M.useCallback)(e=>{pt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_t=(0,M.useCallback)(e=>{X.current=!1,mt.current=setTimeout(()=>{X.current=!0,gt(e)},500)},[gt]),$=(0,M.useCallback)(()=>{mt.current&&=(clearTimeout(mt.current),null)},[]),vt=(0,M.useCallback)(e=>{if(X.current){X.current=!1;return}if(J){Q(e.name);return}dt(e)},[J,Q,dt]),yt=(0,M.useCallback)(e=>{he(e),typeof window<`u`&&window.localStorage.setItem(Ce,e),console.info(`[data] op=view-mode mode=${e}`)},[]),bt=(0,M.useCallback)(e=>{if(X.current){X.current=!1;return}if(J){Q(e.name);return}_e({src:se(t,T===`.`?V(e):`${T}/${V(e)}`),alt:e.displayName??e.name})},[J,Q,T,t]),xt=(0,M.useCallback)(()=>(k??[]).filter(e=>e.kind===`file`&&Y.has(e.name)),[k,Y]),St=(0,M.useCallback)(()=>{if(Y.size!==1)return null;let e=(k??[]).find(e=>Y.has(e.name));return e&&!e.entryPath?e:null},[k,Y]),Ct=(0,M.useCallback)(()=>(k??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&Y.has(e.name)),[k,Y]),wt=(0,M.useCallback)(()=>{let e=Ct(),n=e.some(e=>e.kind===`directory`);e.length===1&&!n?dt(e[0]):e.length>=1&&oe(t,e.map(e=>T===`.`?V(e):`${T}/${V(e)}`)),Z(`action`)},[Ct,dt,T,t,Z]),Tt=(0,M.useCallback)(async()=>{let t=xt(),n=t.filter(e=>!e.protected),r=t.length-n.length;ze(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=T===`.`?V(t):`${T}/${V(t)}`;try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`)}catch(e){ze(e instanceof Error?e.message:String(e))}}U(e=>e+1),Z(`action`)},[xt,T,e,Z]),Et=(0,M.useCallback)(async()=>{let e=xt();if(console.info(`[data-ui] op=share supported=${ht} count=${e.length}`),ht)try{let n=await Promise.all(e.map(async e=>{let n=T===`.`?V(e):`${T}/${V(e)}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=await(await fetch(r)).blob();return new File([i],e.displayName??e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:n})&&await navigator.share({files:n})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[xt,ht,T,t]),Dt=(0,M.useCallback)(()=>{Be.current?.click()},[]),Ot=(0,M.useCallback)((e,n={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:t,path:T===`.`?``:T,filename:e.name});n.relpath&&o.set(`relpath`,n.relpath),n.token&&o.set(`token`,n.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let n=new XMLHttpRequest;n.open(`POST`,`/api/admin/files/upload?${o.toString()}`),n.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(n.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),n.onload=()=>{let e={};try{e=JSON.parse(n.responseText)}catch{}t({status:n.status,data:e})},n.onerror=()=>t({status:0,data:{}}),n.onabort=()=>t({status:0,data:{error:`aborted`}}),n.send(r)})};if(e.size<=we)return r(e,{},t=>n.onProgress?.(t,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/Te);return(async()=>{let t={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Te;if(t=await r(e.slice(s,Math.min(s+Te,e.size)),{uploadId:i,seq:String(o),total:String(a)},t=>n.onProgress?.(s+t,e.size)),!(t.status>=200&&t.status<300))return t}return t})()},[t,T]),kt=(0,M.useCallback)(async e=>{H(null),R(!0),B({loaded:0,total:e.size});try{let{status:t,data:n}=await Ot(e,{onProgress:(e,t)=>B({loaded:e,total:t})});t>=200&&t<300&&n.path?(D(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),U(e=>e+1)):H(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{R(!1),B(null),Be.current&&(Be.current.value=``)}},[Ot]),At=(0,M.useCallback)(e=>{W&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Fe(!0))},[W]),jt=(0,M.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Fe(!1)},[]),Mt=(0,M.useCallback)(async e=>{e.preventDefault(),Fe(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!W){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),H(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);R(!0),H(null),je(null);let i=performance.now();try{let e=await Me(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),B({loaded:0,total:r.size});let{status:a,data:c}=await Ot(r,{relpath:i,token:t,onProgress:(e,t)=>B({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ne(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),je(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),U(e=>e+1)}catch(e){H(e instanceof Error?e.message:String(e))}finally{R(!1),B(null)}},[W,Ot]),Nt=(0,M.useCallback)(async()=>{let t=Ke.trim();if(t){$e(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:T===`.`?``:T,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);Ge(!1),qe(``),U(e=>e+1)}catch(e){$e(e instanceof Error?e.message:String(e))}}},[e,Ke,T]),Pt=(0,M.useCallback)(async()=>{if(!Je)return;let t=Xe.trim();if(!t)return;$e(null);let n=T===`.`?Je:`${T}/${Je}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);Ye(null),Ze(``),Z(`action`),U(e=>e+1)}catch(e){$e(e instanceof Error?e.message:String(e))}},[e,Xe,Je,T,Z]);(0,M.useEffect)(()=>{if(!et)return;let e=e=>{nt.current&&!nt.current.contains(e.target)&&tt(!1)},t=e=>{e.key===`Escape`&&tt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[et]),(0,M.useEffect)(()=>{if(!rt)return;let e=e=>{it.current&&!it.current.contains(e.target)&&G(!1)},t=e=>{e.key===`Escape`&&G(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[rt]);let Ft=(0,M.useCallback)(e=>N.slice(0,e+1).map(e=>e.name).join(`/`),[N]),It=N.length>=2,Lt=It?[{name:`.`,label:`data`},...N.slice(0,N.length-2).map((e,t)=>({name:Ft(t),label:e.displayName??e.name}))]:[];return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-toolbar`,children:[J?(0,P.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Z(`cancel`),"aria-label":`Cancel selection`,children:[(0,P.jsx)(r,{size:14}),` Cancel`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`data-search-input`,children:[o===``&&(0,P.jsx)(E,{size:14}),(0,P.jsx)(`input`,{ref:u,type:`text`,value:o,onChange:e=>c(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),g&&(0,P.jsx)(a,{size:14,className:`spin`}),o!==``&&(0,P.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{c(``),u.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,P.jsx)(r,{size:14})})]}),(0,P.jsxs)(`div`,{className:`data-toolbar-actions`,ref:it,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>G(e=>!e),"aria-haspopup":`menu`,"aria-expanded":rt,"aria-label":`File actions`,title:`File actions`,children:(0,P.jsx)(le,{size:16})}),(0,P.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":rt?`true`:void 0,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{ct(),G(!1)},disabled:F,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[F?(0,P.jsx)(a,{size:16,className:`spin`}):(0,P.jsx)(ne,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Dt(),G(!1)},disabled:I||!W,title:W?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[I?z&&z.total>0?(0,P.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(z.loaded/z.total*100),`%`]}):(0,P.jsx)(a,{size:16,className:`spin`}):(0,P.jsx)(ge,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Ge(e=>!e),qe(``),$e(null),G(!1)},disabled:I||!W,title:W?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,P.jsx)(ue,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{yt(A===`grid`?`list`:`grid`),G(!1)},title:A===`grid`?`List view`:`Grid view`,"aria-label":A===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":A===`grid`,children:[A===`grid`?(0,P.jsx)(fe,{size:16}):(0,P.jsx)(de,{size:16}),(0,P.jsx)(`span`,{className:`data-action-label`,children:A===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,P.jsxs)(`div`,{className:`data-breadcrumbs`,children:[T!==`.`&&(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:ut,title:`Up one level`,"aria-label":`Up one level`,children:(0,P.jsx)(ce,{size:14})}),It?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,ref:nt,children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>tt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":et,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),et&&(0,P.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Lt.map(e=>(0,P.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>q(e.name),title:e.label,children:e.label},e.name))})]}),[N.length-2,N.length-1].map(e=>{let t=N[e];return(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>q(Ft(e)),title:t.name,children:t.displayName??t.name})]},Ft(e))})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>q(`.`),children:`data`}),N.map((e,t)=>(0,P.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,P.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,P.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>q(Ft(t)),title:e.name,children:e.displayName??e.name})]},Ft(t)))]})]}),We&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:Ke,autoFocus:!0,onChange:e=>qe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Nt(),e.key===`Escape`&&Ge(!1)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Nt,children:`Create`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>Ge(!1),children:`Cancel`})]}),Je&&(0,P.jsxs)(`div`,{className:`data-inline-form`,children:[(0,P.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:Xe,autoFocus:!0,onChange:e=>Ze(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Pt(),e.key===`Escape`&&Ye(null)}}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Pt,children:`Rename`}),(0,P.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>Ye(null),children:`Cancel`})]}),Qe&&(0,P.jsx)(`div`,{className:`data-error`,children:Qe}),(0,P.jsx)(`input`,{type:`file`,ref:Be,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&kt(t)}})]}),(0,P.jsxs)(`div`,{className:`data-body`,"data-drag-active":Pe?`true`:void 0,onDragEnter:At,onDragOver:At,onDragLeave:jt,onDrop:Mt,children:[(v!==null||p!==null)&&(0,P.jsxs)(`section`,{className:`data-panel`,children:[v&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,v]}),at.length>0&&(0,P.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:at.map(e=>{let t=e===K;return(0,P.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>b(t?null:e),children:Re([e])??e},e)})}),p&&!g&&(0,P.jsxs)(`div`,{className:`data-results-meta`,children:[ot.length,` of `,p.length,` result`,p.length===1?``:`s`]}),p&&!g&&!K&&x>0&&!S&&(0,P.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>w(!0),children:[x,` low-confidence result`,x===1?``:`s`,` hidden — show all`]}),p&&!g&&!K&&S&&(0,P.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>w(!1),children:`Showing all results — hide low-confidence`}),p&&p.length===0&&!g&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),ot&&ot.length>0&&(0,P.jsx)(`ul`,{className:`data-results`,children:ot.map(e=>(0,P.jsx)(Le,{hit:e,mode:h,onDownload:st,onLocate:lt},e.nodeId))})]}),(0,P.jsxs)(`section`,{className:`data-panel`,children:[z&&(0,P.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":z.total>0?Math.round(z.loaded/z.total*100):void 0,children:[(0,P.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,P.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${z.total>0?Math.round(z.loaded/z.total*100):0}%`}})}),(0,P.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,z.total>0?`${Math.round(z.loaded/z.total*100)}%`:``]})]}),De&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,De]}),Ae&&(0,P.jsx)(`div`,{className:`data-status`,children:Ae}),Ie&&(0,P.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Ie]}),be&&(0,P.jsx)(`div`,{className:`data-error`,children:be}),F&&(0,P.jsxs)(`div`,{className:`data-loading`,children:[(0,P.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!J&&!F&&k&&k.length>0&&(0,P.jsxs)(`div`,{className:`data-select-hint`,children:[(0,P.jsx)(pe,{size:13}),(0,P.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!F&&k&&k.length===0&&!be&&(0,P.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!F&&k&&k.length>0&&A===`grid`&&(0,P.jsx)(`ul`,{className:`data-grid`,children:k.map(e=>{let n=e.displayName??e.name,r=J&&Y.has(e.name);if(e.kind===`directory`)return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>_t(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(X.current){X.current=!1;return}if(J){Q(e.name);return}q(T===`.`?e.name:`${T}/${e.name}`)},children:[J&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(O,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let i=Se(V(e)),a=T===`.`?V(e):`${T}/${V(e)}`;return(0,P.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>_t(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?bt(e):vt(e),title:J?void 0:i?`Preview ${n}`:`Download ${n}`,children:[J&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,P.jsx)(`img`,{className:`data-grid-thumb`,src:se(t,a),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,P.jsx)(ae,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!i&&(0,P.jsx)(`span`,{className:`data-grid-sub`,children:He(e.sizeBytes)})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-grid-cell`,children:(0,P.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,P.jsx)(ae,{size:28,className:`data-grid-glyph`}),(0,P.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,P.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!F&&k&&k.length>0&&A===`list`&&(0,P.jsx)(`ul`,{className:`data-entries`,children:k.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=J&&Y.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>_t(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(X.current){X.current=!1;return}if(J){Q(e.name);return}q(T===`.`?e.name:`${T}/${e.name}`)},children:[J&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsx)(O,{size:14}),(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=J&&Y.has(e.name);return(0,P.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,P.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>_t(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>vt(e),title:J?void 0:`Download ${t}`,children:[J&&(0,P.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,P.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Ue(e.modifiedAt)}`,children:[He(e.sizeBytes),` · `,Ue(e.modifiedAt)]})]})]})},e.name)}return(0,P.jsx)(`li`,{className:`data-entry`,children:(0,P.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,P.jsxs)(`span`,{className:`data-entry-text`,children:[(0,P.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,P.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),J&&(0,P.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,P.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Et,disabled:!ht||Y.size===0,title:ht?`Share selected files`:`Sharing is not supported on this device`,children:[(0,P.jsx)(i,{size:16}),` Share`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:wt,disabled:Y.size===0,children:[(0,P.jsx)(C,{size:16}),` Download`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=St();e&&(Ye(e.name),Ze(e.name))},disabled:!St(),children:[(0,P.jsx)(s,{size:16}),` Rename`]}),(0,P.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Tt,disabled:Y.size===0,children:[(0,P.jsx)(l,{size:16}),` Delete`]})]})}),j&&(0,P.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":j.alt,onClick:()=>_e(null),children:(0,P.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:j.src,alt:j.alt})})]})}function Fe({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){(0,M.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let r=(0,M.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),i=(0,M.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[a,o]=(0,M.useState)([]),[s,l]=(0,M.useState)(`files`),{subAccounts:u,activeAccountId:d,switching:p,switchAccount:m}=f(t);return(0,M.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||o(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,P.jsxs)(`main`,{className:`data-main`,children:[(0,P.jsx)(c,{variant:`operator`,onNavigate:i,onOpenConversations:a.length>0?()=>l(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:u,activeAccountId:d,switchingAccount:p,onSwitchAccount:m}),s===`conversations`?(0,P.jsx)(z,{conversations:a,sessionKey:t,onBack:()=>l(`files`)}):(0,P.jsx)(Pe,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function Ie({cacheKey:e}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i}=t({initialCacheKey:e,surface:`data`});return(0,P.jsx)(`div`,{className:`data-page`,children:(0,P.jsx)(`main`,{className:`data-main`,children:(0,P.jsx)(Pe,{adminFetch:n,cacheKey:r,sessionRefetchNonce:i})})})}function Le({hit:e,mode:t,onDownload:n,onLocate:r}){let i=ze(e.properties),a=Be(e.properties),o=Re(e.labels),s=Ve(e.properties),[c,l]=(0,M.useState)(!1),u=a&&a.length>280,d=c||!u?a:a?.slice(0,280)+`…`,f=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,p=e.properties.relativePath,m=typeof p==`string`&&p.length>0,h=m?p.lastIndexOf(`/`):-1,ee=m?h===-1?`data`:p.slice(0,h):null;return(0,P.jsxs)(`li`,{className:`data-result`,children:[(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Download ${i??o??`file`}`,children:[o&&(0,P.jsx)(`div`,{className:`data-result-header`,children:(0,P.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,P.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,P.jsx)(`pre`,{className:`data-result-body`,children:d}),(0,P.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,P.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Ue(s),` · `]}),f]})]}),m&&(0,P.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${ee}`,"aria-label":`Locate in ${ee}`,children:[(0,P.jsx)(O,{size:12}),ee]}),u&&(0,P.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>l(e=>!e),children:c?`Show less`:`Show more`})]})}function Re(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function ze(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function Be(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function Ve(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function He(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function Ue(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{Ie as n,I as r,De as t};
|