@rubytech/create-sitedesk-code 0.1.528 → 0.1.529
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/account-ingest-token/dist/index.d.ts +21 -0
- package/payload/platform/lib/account-ingest-token/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/account-ingest-token/dist/index.js +128 -0
- package/payload/platform/lib/account-ingest-token/dist/index.js.map +1 -0
- package/payload/platform/lib/account-ingest-token/src/index.ts +137 -0
- package/payload/platform/lib/account-ingest-token/tsconfig.json +8 -0
- package/payload/platform/lib/agent-dispatch-rule/dist/index.d.ts +5 -0
- package/payload/platform/lib/agent-dispatch-rule/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/agent-dispatch-rule/dist/index.js.map +1 -1
- package/payload/platform/lib/agent-dispatch-rule/src/index.ts +5 -0
- package/payload/platform/package.json +2 -2
- package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +5 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js +37 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/linkedin-ingest-token.d.ts +10 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/linkedin-ingest-token.d.ts.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/linkedin-ingest-token.js +22 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/linkedin-ingest-token.js.map +1 -0
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +25 -4
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +6 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +22 -1
- package/payload/platform/plugins/docs/references/linkedin-extension.md +2 -2
- package/payload/platform/plugins/linkedin-extension/extension/README.md +3 -3
- package/payload/platform/plugins/linkedin-extension/extension/background/sw.js +12 -7
- package/payload/platform/plugins/linkedin-extension/extension/content/profile.js +4 -1
- package/payload/platform/plugins/linkedin-extension/extension/content/thread.js +4 -1
- package/payload/platform/plugins/linkedin-extension/extension/options/options.html +3 -3
- package/payload/platform/plugins/linkedin-extension/extension/options/options.js +24 -16
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/suspension-census.test.js +45 -2
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/__tests__/suspension-census.test.js.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.d.ts.map +1 -1
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js +15 -2
- package/payload/platform/plugins/scheduling/mcp/dist/scripts/agent-turn-dispatch.js.map +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 +1 -0
- package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-Bx9vPuUg.js → AdminLoginScreens-zfexKfbT.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-zfexKfbT.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-zfexKfbT.js.gz +0 -0
- package/payload/server/public/assets/{AdminShell-BxJPbC3p.js → AdminShell-Cbk0TL1B.js} +1 -1
- package/payload/server/public/assets/AdminShell-Cbk0TL1B.js.br +0 -0
- package/payload/server/public/assets/AdminShell-Cbk0TL1B.js.gz +0 -0
- package/payload/server/public/assets/{CdpScreencastSurface-5HLhTQTV.js → CdpScreencastSurface-CLSQHh4e.js} +1 -1
- package/payload/server/public/assets/CdpScreencastSurface-CLSQHh4e.js.br +0 -0
- package/payload/server/public/assets/CdpScreencastSurface-CLSQHh4e.js.gz +0 -0
- package/payload/server/public/assets/{activity-BaSYn62l.js → activity-u275Oc-u.js} +1 -1
- package/payload/server/public/assets/activity-u275Oc-u.js.br +0 -0
- package/payload/server/public/assets/activity-u275Oc-u.js.gz +0 -0
- package/payload/server/public/assets/{admin-CYCKrV_x.js → admin-Du1nR_hP.js} +1 -1
- package/payload/server/public/assets/admin-Du1nR_hP.js.br +0 -0
- package/payload/server/public/assets/admin-Du1nR_hP.js.gz +0 -0
- package/payload/server/public/assets/{agents-D8EJG-ta.js → agents-DJTxRLLU.js} +1 -1
- package/payload/server/public/assets/agents-DJTxRLLU.js.br +0 -0
- package/payload/server/public/assets/agents-DJTxRLLU.js.gz +0 -0
- package/payload/server/public/assets/{browser-D6Y_Zu8C.js → browser-Bft6zVkX.js} +1 -1
- package/payload/server/public/assets/browser-Bft6zVkX.js.br +0 -0
- package/payload/server/public/assets/browser-Bft6zVkX.js.gz +0 -0
- package/payload/server/public/assets/{calendar-DD4oVa-r.js → calendar-Ct-DCCqY.js} +1 -1
- package/payload/server/public/assets/calendar-Ct-DCCqY.js.br +0 -0
- package/payload/server/public/assets/calendar-Ct-DCCqY.js.gz +0 -0
- package/payload/server/public/assets/chat-pqasbAg8.js +1 -0
- package/payload/server/public/assets/chat-pqasbAg8.js.br +0 -0
- package/payload/server/public/assets/chat-pqasbAg8.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-C8LTc7lb.js +1 -0
- package/payload/server/public/assets/chevron-right-Lz9t7Hed.js +1 -0
- package/payload/server/public/assets/chevron-right-Lz9t7Hed.js.br +0 -0
- package/payload/server/public/assets/clock-D6QQFHwJ.js +1 -0
- package/payload/server/public/assets/clock-D6QQFHwJ.js.br +0 -0
- package/payload/server/public/assets/clock-D6QQFHwJ.js.gz +0 -0
- package/payload/server/public/assets/data-B1JJ3Y1T.js +1 -0
- package/payload/server/public/assets/data-B1JJ3Y1T.js.br +0 -0
- package/payload/server/public/assets/data-B1JJ3Y1T.js.gz +0 -0
- package/payload/server/public/assets/{file-download-sXU3_umF.js → file-download-C_fSe4dm.js} +1 -1
- package/payload/server/public/assets/file-download-C_fSe4dm.js.br +0 -0
- package/payload/server/public/assets/file-download-C_fSe4dm.js.gz +0 -0
- package/payload/server/public/assets/{file-text-CeXBviDH.js → file-text-D7GbEcqj.js} +1 -1
- package/payload/server/public/assets/file-text-D7GbEcqj.js.br +0 -0
- package/payload/server/public/assets/file-text-D7GbEcqj.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-D2pQkgYW.js → graph-labels-Dlcb6cW7.js} +1 -1
- package/payload/server/public/assets/graph-labels-Dlcb6cW7.js.br +0 -0
- package/payload/server/public/assets/graph-labels-Dlcb6cW7.js.gz +0 -0
- package/payload/server/public/assets/{graph-BSuDP6k7.js → graph-yl5qU1kO.js} +1 -1
- package/payload/server/public/assets/graph-yl5qU1kO.js.br +0 -0
- package/payload/server/public/assets/graph-yl5qU1kO.js.gz +0 -0
- package/payload/server/public/assets/{maximize-2-DlzSNygU.js → maximize-2-BS689r4W.js} +1 -1
- package/payload/server/public/assets/maximize-2-BS689r4W.js.br +0 -0
- package/payload/server/public/assets/maximize-2-BS689r4W.js.gz +0 -0
- package/payload/server/public/assets/{operator-BP61-xjz.js → operator-CvapnpIW.js} +1 -1
- package/payload/server/public/assets/operator-CvapnpIW.js.br +0 -0
- package/payload/server/public/assets/operator-CvapnpIW.js.gz +0 -0
- package/payload/server/public/assets/{page-eQ4OVros.js → page-987y4JbQ.js} +1 -1
- package/payload/server/public/assets/page-987y4JbQ.js.br +0 -0
- package/payload/server/public/assets/page-987y4JbQ.js.gz +0 -0
- package/payload/server/public/assets/{page-DX7ArY_s.js → page-DWkUH4Z_.js} +1 -1
- package/payload/server/public/assets/page-DWkUH4Z_.js.br +0 -0
- package/payload/server/public/assets/page-DWkUH4Z_.js.gz +0 -0
- package/payload/server/public/assets/{public-DPDKFKM2.js → public-D5pi-VFn.js} +1 -1
- package/payload/server/public/assets/public-D5pi-VFn.js.br +0 -0
- package/payload/server/public/assets/public-D5pi-VFn.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-BR0JbPFV.js → rotate-ccw-zNxnK36R.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-zNxnK36R.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-zNxnK36R.js.gz +0 -0
- package/payload/server/public/assets/routines-mZzrGA5y.js +2 -0
- package/payload/server/public/assets/routines-mZzrGA5y.js.br +0 -0
- package/payload/server/public/assets/routines-mZzrGA5y.js.gz +0 -0
- package/payload/server/public/assets/{skills-fH0uA7cj.js → skills-5A8PockT.js} +1 -1
- package/payload/server/public/assets/skills-5A8PockT.js.br +0 -0
- package/payload/server/public/assets/skills-5A8PockT.js.gz +0 -0
- package/payload/server/public/assets/{tasks-CrVzFrTR.js → tasks-B1_2wc6L.js} +1 -1
- package/payload/server/public/assets/tasks-B1_2wc6L.js.br +0 -0
- package/payload/server/public/assets/tasks-B1_2wc6L.js.gz +0 -0
- package/payload/server/public/assets/{time-entry-format-C_0jiMpQ.js → time-entry-format-CJ2FSSQt.js} +1 -1
- package/payload/server/public/assets/time-entry-format-CJ2FSSQt.js.br +0 -0
- package/payload/server/public/assets/time-entry-format-CJ2FSSQt.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-eLJHC_QJ.js → triangle-alert-CedsrgME.js} +1 -1
- package/payload/server/public/assets/triangle-alert-CedsrgME.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-CedsrgME.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-vPCmdOmY.js → useCopyFeedback-zjZZUC2-.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-zjZZUC2-.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-zjZZUC2-.js.gz +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-DxuUS_C7.css → useSubAccountSwitcher-72THldvm.css} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-72THldvm.css.br +0 -0
- package/payload/server/public/assets/{useSubAccountSwitcher-DxuUS_C7.css.gz → useSubAccountSwitcher-72THldvm.css.gz} +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-D5bFDRqL.js → useVoiceRecorder-CJecnefX.js} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-CJecnefX.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-CJecnefX.js.gz +0 -0
- package/payload/server/public/assets/{wrench-sXisQXkf.js → wrench-D8BH20W8.js} +1 -1
- package/payload/server/public/assets/wrench-D8BH20W8.js.br +0 -0
- package/payload/server/public/assets/wrench-D8BH20W8.js.gz +0 -0
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +7 -7
- package/payload/server/public/chat.html +13 -13
- package/payload/server/public/data.html +12 -12
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +16 -16
- package/payload/server/public/operator.html +15 -15
- package/payload/server/public/public.html +13 -13
- package/payload/server/public/routines.html +7 -7
- package/payload/server/public/skills.html +5 -5
- package/payload/server/public/tasks.html +6 -6
- package/payload/server/server.js +343 -205
- package/payload/server/public/assets/AdminLoginScreens-Bx9vPuUg.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-Bx9vPuUg.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-BxJPbC3p.js.br +0 -0
- package/payload/server/public/assets/AdminShell-BxJPbC3p.js.gz +0 -0
- package/payload/server/public/assets/CdpScreencastSurface-5HLhTQTV.js.br +0 -0
- package/payload/server/public/assets/CdpScreencastSurface-5HLhTQTV.js.gz +0 -0
- package/payload/server/public/assets/activity-BaSYn62l.js.br +0 -0
- package/payload/server/public/assets/activity-BaSYn62l.js.gz +0 -0
- package/payload/server/public/assets/admin-CYCKrV_x.js.br +0 -0
- package/payload/server/public/assets/admin-CYCKrV_x.js.gz +0 -0
- package/payload/server/public/assets/agents-D8EJG-ta.js.br +0 -0
- package/payload/server/public/assets/agents-D8EJG-ta.js.gz +0 -0
- package/payload/server/public/assets/browser-D6Y_Zu8C.js.br +0 -0
- package/payload/server/public/assets/browser-D6Y_Zu8C.js.gz +0 -0
- package/payload/server/public/assets/calendar-DD4oVa-r.js.br +0 -0
- package/payload/server/public/assets/calendar-DD4oVa-r.js.gz +0 -0
- package/payload/server/public/assets/chat-CwWs69PO.js +0 -1
- package/payload/server/public/assets/chat-CwWs69PO.js.br +0 -0
- package/payload/server/public/assets/chat-CwWs69PO.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-ClfIy5Fx.js +0 -1
- package/payload/server/public/assets/chevron-right-B0QvXpxl.js +0 -1
- package/payload/server/public/assets/chevron-right-B0QvXpxl.js.br +0 -0
- package/payload/server/public/assets/clock-BIaRnIP_.js +0 -1
- package/payload/server/public/assets/clock-BIaRnIP_.js.br +0 -0
- package/payload/server/public/assets/clock-BIaRnIP_.js.gz +0 -0
- package/payload/server/public/assets/data-O_9Kiicl.js +0 -1
- package/payload/server/public/assets/data-O_9Kiicl.js.br +0 -2
- package/payload/server/public/assets/data-O_9Kiicl.js.gz +0 -0
- package/payload/server/public/assets/file-download-sXU3_umF.js.br +0 -0
- package/payload/server/public/assets/file-download-sXU3_umF.js.gz +0 -0
- package/payload/server/public/assets/file-text-CeXBviDH.js.br +0 -0
- package/payload/server/public/assets/file-text-CeXBviDH.js.gz +0 -0
- package/payload/server/public/assets/graph-BSuDP6k7.js.br +0 -0
- package/payload/server/public/assets/graph-BSuDP6k7.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-D2pQkgYW.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D2pQkgYW.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-DlzSNygU.js.br +0 -0
- package/payload/server/public/assets/maximize-2-DlzSNygU.js.gz +0 -0
- package/payload/server/public/assets/operator-BP61-xjz.js.br +0 -0
- package/payload/server/public/assets/operator-BP61-xjz.js.gz +0 -0
- package/payload/server/public/assets/page-DX7ArY_s.js.br +0 -0
- package/payload/server/public/assets/page-DX7ArY_s.js.gz +0 -0
- package/payload/server/public/assets/page-eQ4OVros.js.br +0 -0
- package/payload/server/public/assets/page-eQ4OVros.js.gz +0 -0
- package/payload/server/public/assets/public-DPDKFKM2.js.br +0 -0
- package/payload/server/public/assets/public-DPDKFKM2.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-BR0JbPFV.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-BR0JbPFV.js.gz +0 -0
- package/payload/server/public/assets/routines-y413YZa-.js +0 -1
- package/payload/server/public/assets/routines-y413YZa-.js.br +0 -0
- package/payload/server/public/assets/routines-y413YZa-.js.gz +0 -0
- package/payload/server/public/assets/skills-fH0uA7cj.js.br +0 -0
- package/payload/server/public/assets/skills-fH0uA7cj.js.gz +0 -0
- package/payload/server/public/assets/tasks-CrVzFrTR.js.br +0 -0
- package/payload/server/public/assets/tasks-CrVzFrTR.js.gz +0 -0
- package/payload/server/public/assets/time-entry-format-C_0jiMpQ.js.br +0 -1
- package/payload/server/public/assets/time-entry-format-C_0jiMpQ.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-eLJHC_QJ.js.br +0 -1
- package/payload/server/public/assets/triangle-alert-eLJHC_QJ.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-vPCmdOmY.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-vPCmdOmY.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-DxuUS_C7.css.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-D5bFDRqL.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-D5bFDRqL.js.gz +0 -0
- package/payload/server/public/assets/wrench-sXisQXkf.js.br +0 -0
- package/payload/server/public/assets/wrench-sXisQXkf.js.gz +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-DMr3DR5N.js → useSubAccountSwitcher-HjQZjJBr.js} +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-DMr3DR5N.js.br → useSubAccountSwitcher-HjQZjJBr.js.br} +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-DMr3DR5N.js.gz → useSubAccountSwitcher-HjQZjJBr.js.gz} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,I as r,J as i,K as a,_ as o,g as s,n as c}from"./useSubAccountSwitcher-DMr3DR5N.js";import{D as l,E as u,O as d,t as f}from"./AdminShell-BxJPbC3p.js";import{t as p}from"./triangle-alert-eLJHC_QJ.js";var m=a(),h=e(i(),1),g=n(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[n,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(null),[d,f]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await c(t,e)&&(console.info(`[admin-ui] activity-card-open account=${e.slice(0,8)} session=${n.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(n)}`))},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){o(`This view is available to the house account only.`),f(!0);return}if(!n.ok){o(`The session manager did not answer (status ${n.status}).`),f(!0);return}i(await n.json()),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{f(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>n?[...n.rows].sort((e,t)=>H(e,t,m,v)):[],[n,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!d)return(0,g.jsx)(s,{surface:`gate`});if(a)return(0,g.jsx)(`div`,{className:`activity-empty`,children:a});if(!n)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=n,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=n.range===void 0?b:n.range;return(0,g.jsxs)(`div`,{className:`ui-page ui-page--full activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(r,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(l,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(l,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,n.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:n?.loops})]})}function X({cacheKey:e}){let{adminFetch:n}=t({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:n,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,a]=(0,h.useState)(void 0),[c,l]=(0,h.useState)(null),[u,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(o,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:i,sessionId:c,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:u,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-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:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(s,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,I as r,J as i,K as a,_ as o,g as s,n as c}from"./useSubAccountSwitcher-HjQZjJBr.js";import{D as l,E as u,O as d,t as f}from"./AdminShell-Cbk0TL1B.js";import{t as p}from"./triangle-alert-CedsrgME.js";var m=a(),h=e(i(),1),g=n(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[n,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(null),[d,f]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await c(t,e)&&(console.info(`[admin-ui] activity-card-open account=${e.slice(0,8)} session=${n.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(n)}`))},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){o(`This view is available to the house account only.`),f(!0);return}if(!n.ok){o(`The session manager did not answer (status ${n.status}).`),f(!0);return}i(await n.json()),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{f(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>n?[...n.rows].sort((e,t)=>H(e,t,m,v)):[],[n,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!d)return(0,g.jsx)(s,{surface:`gate`});if(a)return(0,g.jsx)(`div`,{className:`activity-empty`,children:a});if(!n)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=n,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=n.range===void 0?b:n.range;return(0,g.jsxs)(`div`,{className:`ui-page ui-page--full activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(r,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(l,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(l,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,n.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(u,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:n?.loops})]})}function X({cacheKey:e}){let{adminFetch:n}=t({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:n,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,a]=(0,h.useState)(void 0),[c,l]=(0,h.useState)(null),[u,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(o,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:i,sessionId:c,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:u,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-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:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(s,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,H as n,J as r,K as i,U as a,_ as o,a as s,d as c,s as l,u,v as ee,x as te}from"./useSubAccountSwitcher-DMr3DR5N.js";import{n as d,t as f}from"./AdminLoginScreens-Bx9vPuUg.js";import{f as ne,s as p,x as m}from"./useVoiceRecorder-D5bFDRqL.js";import{C as h,S as re,a as g,b as _,h as ie,t as v}from"./AdminShell-BxJPbC3p.js";import{n as ae}from"./file-download-sXU3_umF.js";import{t as y}from"./chevron-left-ClfIy5Fx.js";import{t as oe}from"./chevron-right-B0QvXpxl.js";import{n as b,r as x}from"./page-DX7ArY_s.js";import{t as se}from"./file-text-CeXBviDH.js";import"./graph-labels-D2pQkgYW.js";import"./CdpScreencastSurface-5HLhTQTV.js";var S=i(),C=e(r(),1),w=n();function T({onOpen:e}){return(0,w.jsx)(`footer`,{className:`admin-footer`,children:(0,w.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,w.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,w.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function E({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,w.jsxs)(`div`,{className:`wa-web`,children:[(0,w.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,w.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,w.jsx)(y,{size:20})}),(0,w.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,w.jsx)(m,{size:20})}),(0,w.jsx)(`div`,{className:`wa-web-titles`,children:(0,w.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,w.jsx)(`div`,{className:`wa-web-body`,children:(0,w.jsx)(p,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var D=6e4,O=60*D,k=24*O,A=D,j=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],M=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function N(e){return e<10?`0${e}`:String(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function F(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-A)return`—`;let r=n<0?0:n;if(r<D)return`just now`;if(r<O)return`${Math.floor(r/D)}m`;if(r<k)return`${Math.floor(r/O)}h`;let i=new Date(t),a=new Date(e),o=Math.round((P(i)-P(a))/k);if(o===1)return`yesterday`;if(o>=2&&o<=6)return M[a.getDay()];let s=N(a.getDate()),c=j[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function I({variant:e=`row`,count:t=1}){return(0,w.jsx)(w.Fragment,{children:Array.from({length:t},(t,n)=>(0,w.jsx)(`span`,{className:`dashboard-skeleton dashboard-skeleton--${e}`,"data-testid":`dashboard-skeleton`,"aria-hidden":`true`},n))})}var ce=6e4;function le(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function L(e){return e&&e.trim().split(/\s+/)[0]||`there`}function ue(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function R(e){return e==null?`—`:`${Math.round(e*100)}%`}function de(e){return e.isGroup===!0?e.chatName??e.title:e.operatorName??e.chatName??e.whatsappName??e.senderId??e.title}function z(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function fe(e){return e?e.replace(/^claude-/,``):null}var B=new Set([`sessions`,`conversations`,`tasks`,`artefacts`,`skills`,`stats`]),V=!1;function pe(e,t,n,r){let i=e=>t.get(e)??null,a=r?r.getEntriesByType(`navigation`)[0]:void 0,o=r?r.getEntriesByType(`resource`).filter(e=>new URL(e.name,`http://x`).pathname.startsWith(`/assets/`)):[],s=e=>e===void 0||!Number.isFinite(e)?null:Math.round(e),c=e=>e?s(e):null;return{batchMs:e,sessionsMs:i(`sessions`),conversationsMs:i(`conversations`),tasksMs:i(`tasks`),artefactsMs:i(`artefacts`),skillsMs:i(`skills`),statsMs:i(`stats`),failed:[...B].filter(e=>n.has(e)).join(`,`)||`none`,ttfbMs:s(a?.responseStart),domContentLoadedMs:c(a?.domContentLoadedEventEnd),loadMs:c(a?.loadEventEnd),assetCount:o.length,assetBytes:o.reduce((e,t)=>e+(t.transferSize||0),0),assetMs:o.length?s(Math.max(...o.map(e=>e.responseEnd))):null}}function H({cacheKey:e,userName:n,onSelectWhatsappConversation:r}){let i=ee(e),[o,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,g]=(0,C.useState)(null),v=(0,C.useRef)(!1),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(new Set),[B,H]=(0,C.useState)(()=>new Set),U=(0,C.useCallback)(e=>{H(t=>t.has(e)?t:new Set(t).add(e))},[]),W=Date.now(),G=(0,C.useRef)(!1),K=(0,C.useRef)(new Map),q=(0,C.useRef)(new Set),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let t=!1;async function n(e,n,r,a){let o=Date.now(),s=typeof n==`string`?n:`unresolved`;try{typeof n!=`string`&&(s=await n());let c=await i(s);if(!c.ok)throw Error(`status ${c.status}`);let l=await c.json();t||a(r(l)),console.info(`[admin-ui] op=dashboard-fetch slice=${e} url=${s} outcome=ok ms=${Date.now()-o}`)}catch(t){q.current.add(e),console.error(`[admin-ui] dashboard-fetch-failed slice=${e} url=${s} ms=${Date.now()-o} reason=${t instanceof Error?t.message:String(t)}`)}finally{K.current.set(e,Date.now()-o),U(e)}}async function r(){if(!J.current){let e=await i(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,a=n.find(e=>e.accountId===r);if(!a)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let o=a.isHouse||n.length===1;J.current={accountId:a.accountId,isHouse:o}}let{accountId:e,isHouse:t}=J.current;return console.info(`[admin-ui] op=dashboard-channels-source source=${t?`all`:`scoped`} account=${e.slice(0,8)}`),t?`/api/operator-conversations/conversations-all`:`/api/operator-conversations/conversations`}let o={"sidebar-sessions":()=>n(`sessions`,`/api/admin/sidebar-sessions`,e=>e.sessions??[],d),"conversations-all":()=>n(`conversations`,r,e=>e.conversations??[],p),"tasks-list":()=>n(`tasks`,`/api/admin/tasks-list`,e=>e,S),"sidebar-artefacts":()=>n(`artefacts`,`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],E),skills:()=>n(`skills`,`/api/admin/skills`,e=>e.skills??[],O)};async function s(){if(G.current)return;G.current=!0;let e=Date.now();try{await Promise.all([...Object.values(o).map(e=>e()),n(`stats`,`/api/admin/system-stats`,e=>e,b),n(`bookingLink`,`/api/admin/calendar/booking-link`,e=>e.bookingDomain??null,A),n(`portalLink`,`/api/admin/data-portal/portal-link`,e=>e.portalDomain??null,M)])}finally{G.current=!1;let t=Date.now()-e;if(console.info(`[admin-ui] op=dashboard-refresh-settled ms=${t}`),!V){V=!0;try{let e=pe(t,K.current,q.current,typeof performance>`u`?null:performance);fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`dashboard-load`,...e}),keepalive:!0}).catch(()=>{})}catch{}}}}s();let c=null;try{c=new EventSource(a(`/api/admin/events`,e)),c.onmessage=e=>{if(document.visibilityState===`visible`)try{let{resource:t}=JSON.parse(e.data),n=t?o[t]:void 0;n&&n()}catch{}},c.onerror=()=>{console.error(`[admin-ui] dashboard-events stream error`)}}catch(e){console.error(`[admin-ui] dashboard-events unavailable reason=${e instanceof Error?e.message:String(e)}`)}let l=setInterval(()=>{document.visibilityState===`visible`&&s()},ce),u=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,u),()=>{t=!0,G.current=!1,clearInterval(l),c?.close(),document.removeEventListener(`visibilitychange`,u)}},[e,i]);let Y=(0,C.useMemo)(()=>(o??[]).filter(e=>!e.isSubagent),[o]),X=(0,C.useMemo)(()=>Y.filter(e=>e.live),[Y]),me=(0,C.useMemo)(()=>(f??[]).filter(e=>z(e.lastMessageAt,W)).length,[f,W]),he=x?.open.length??0,Z=(0,C.useMemo)(()=>{let e=new Map;for(let t of f??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?de(n):``,rows:t}})},[f]);(0,C.useEffect)(()=>{v.current||Z.length!==0&&(v.current=!0,g(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0,console.info(`[admin-ui] dashboard-public-pages booking=${k!=null} filedrop=${j!=null}`))},[B,k,j]);let ge=(0,C.useCallback)(async e=>{if(!N.has(e)){P(t=>new Set(t).add(e));try{let t=await i(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}console.info(`[admin-ui] dashboard-session-stop sessionId=${e}`),d(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{P(t=>{let n=new Set(t);return n.delete(e),n})}}},[i,N]),_e=(0,C.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}ae(e,t.downloadPath,t.downloadRoot??`data`)},[e]),$=le(new Date(W).getHours());return(0,w.jsxs)(`div`,{className:`ui-page ui-page--full dashboard-home`,children:[(0,w.jsx)(`p`,{className:`dashboard-greeting`,children:B.has(`stats`)?`Good ${$}, ${L(n)} — ${ue(y)}`:`Good ${$}, ${L(n)}`}),(0,w.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),B.has(`sessions`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:X.length}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,Y.length,` total`]})]}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),B.has(`conversations`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:me}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),B.has(`tasks`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:he}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),B.has(`stats`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:R(y?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,R(y?.memUsedPct??null)]})]}):(0,w.jsx)(I,{variant:`value`})]})]}),(0,w.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(k||j)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Public pages`}),(0,w.jsxs)(`div`,{className:`admin-card dashboard-public-pages`,children:[k&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${k}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`Booking page`})]}),j&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${j}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`File drop`})]})]})]}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),B.has(`sessions`)?X.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):X.map(e=>{let t=[e.sessionId.slice(0,8),fe(e.model),F(Date.parse(e.startedAt),W)].filter(Boolean).join(` · `);return(0,w.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,w.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,w.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,w.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,w.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,w.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,w.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:N.has(e.sessionId),onClick:()=>void ge(e.sessionId),children:(0,w.jsx)(te,{size:12})})]},e.sessionId)}):(0,w.jsx)(I,{variant:`card`,count:2}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:B.has(`artefacts`)?(T??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(T??[]).slice(0,6).map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>_e(e),children:[(0,w.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,w.jsx)(h,{size:16}):(0,w.jsx)(se,{size:16})}),(0,w.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,w.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,w.jsx)(`span`,{className:`dashboard-artefact-time`,children:F(Date.parse(e.updatedAt),W)})]},e.id)):(0,w.jsx)(I,{count:3})}),(0,w.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-skills`,children:B.has(`skills`)?(D??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(D??[]).map(e=>(0,w.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,w.jsx)(ie,{size:16})}),(0,w.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,w.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`)):(0,w.jsx)(I,{count:2})})]}),(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),B.has(`conversations`)?Z.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):Z.map(n=>{let i=m===n.channel;return(0,w.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":i,onClick:()=>g(e=>e===n.channel?null:n.channel),children:[(0,w.jsx)(`span`,{className:`dashboard-channel-glyph`,children:n.channel===`whatsapp`||n.channel===`telegram`?(0,w.jsx)(c,{channel:n.channel,size:16}):(0,w.jsx)(t,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-channel-name`,children:u[n.channel]??n.channel}),(0,w.jsx)(`span`,{className:`dashboard-channel-badge`,children:n.count}),(0,w.jsx)(`span`,{className:`dashboard-channel-chevron`,children:i?(0,w.jsx)(re,{size:14}):(0,w.jsx)(oe,{size:14})})]}),i?(0,w.jsx)(`div`,{className:`dashboard-channel-convs`,children:n.rows.map(t=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>r(t),title:t.title,children:[(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-line`,children:[(0,w.jsx)(ne,{accountId:t.accountId??``,jid:t.remoteJid,sessionKey:e??``,className:`dashboard-channel-conv-avatar`,size:16}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:s(t)}),t.isGroup===!0&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-group`,children:`Group`}),t.role===`public`&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-public`,children:`Public`}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:t.isHouse?`House`:`Client`}),!t.preview&&t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}),t.preview?(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-sub`,children:[(0,w.jsx)(`span`,{className:`dashboard-channel-conv-preview`,children:t.preview}),t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}):null]},l(t)))}):n.preview&&(0,w.jsx)(`span`,{className:`dashboard-channel-preview`,children:n.preview})]},n.channel)}):(0,w.jsx)(I,{variant:`card`,count:2})]})]})]})}function U(){let e=d(),[t,n]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,C.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();if(!e.cacheKey){console.error(`[admin-ui] claude-info-fetch-skipped reason=no-session-key`);return}try{let t=await fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(e.cacheKey)}`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,C.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,w.jsx)(o,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(v,{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,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{onOpen:r}),(0,w.jsx)(g,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,w.jsx)(w.Fragment,{children:t.dataOpen&&e.cacheKey?(0,w.jsx)(b,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,w.jsx)(x,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:s(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(E,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:s(t.selectedWhatsapp),onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(H,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,w.jsx)(f,{auth:e})}(0,S.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(U,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,H as n,J as r,K as i,U as a,_ as o,a as s,d as c,s as l,u,v as ee,x as te}from"./useSubAccountSwitcher-HjQZjJBr.js";import{n as d,t as f}from"./AdminLoginScreens-zfexKfbT.js";import{f as ne,s as p,x as m}from"./useVoiceRecorder-CJecnefX.js";import{C as h,S as re,a as g,b as _,h as ie,t as v}from"./AdminShell-Cbk0TL1B.js";import{n as ae}from"./file-download-C_fSe4dm.js";import{t as y}from"./chevron-left-C8LTc7lb.js";import{t as oe}from"./chevron-right-Lz9t7Hed.js";import{n as b,r as x}from"./page-DWkUH4Z_.js";import{t as se}from"./file-text-D7GbEcqj.js";import"./graph-labels-Dlcb6cW7.js";import"./CdpScreencastSurface-CLSQHh4e.js";var S=i(),C=e(r(),1),w=n();function T({onOpen:e}){return(0,w.jsx)(`footer`,{className:`admin-footer`,children:(0,w.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,w.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,w.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function E({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,w.jsxs)(`div`,{className:`wa-web`,children:[(0,w.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,w.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,w.jsx)(y,{size:20})}),(0,w.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,w.jsx)(m,{size:20})}),(0,w.jsx)(`div`,{className:`wa-web-titles`,children:(0,w.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,w.jsx)(`div`,{className:`wa-web-body`,children:(0,w.jsx)(p,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var D=6e4,O=60*D,k=24*O,A=D,j=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],M=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function N(e){return e<10?`0${e}`:String(e)}function P(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function F(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-A)return`—`;let r=n<0?0:n;if(r<D)return`just now`;if(r<O)return`${Math.floor(r/D)}m`;if(r<k)return`${Math.floor(r/O)}h`;let i=new Date(t),a=new Date(e),o=Math.round((P(i)-P(a))/k);if(o===1)return`yesterday`;if(o>=2&&o<=6)return M[a.getDay()];let s=N(a.getDate()),c=j[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function I({variant:e=`row`,count:t=1}){return(0,w.jsx)(w.Fragment,{children:Array.from({length:t},(t,n)=>(0,w.jsx)(`span`,{className:`dashboard-skeleton dashboard-skeleton--${e}`,"data-testid":`dashboard-skeleton`,"aria-hidden":`true`},n))})}var ce=6e4;function le(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function L(e){return e&&e.trim().split(/\s+/)[0]||`there`}function ue(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function R(e){return e==null?`—`:`${Math.round(e*100)}%`}function de(e){return e.isGroup===!0?e.chatName??e.title:e.operatorName??e.chatName??e.whatsappName??e.senderId??e.title}function z(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function fe(e){return e?e.replace(/^claude-/,``):null}var B=new Set([`sessions`,`conversations`,`tasks`,`artefacts`,`skills`,`stats`]),V=!1;function pe(e,t,n,r){let i=e=>t.get(e)??null,a=r?r.getEntriesByType(`navigation`)[0]:void 0,o=r?r.getEntriesByType(`resource`).filter(e=>new URL(e.name,`http://x`).pathname.startsWith(`/assets/`)):[],s=e=>e===void 0||!Number.isFinite(e)?null:Math.round(e),c=e=>e?s(e):null;return{batchMs:e,sessionsMs:i(`sessions`),conversationsMs:i(`conversations`),tasksMs:i(`tasks`),artefactsMs:i(`artefacts`),skillsMs:i(`skills`),statsMs:i(`stats`),failed:[...B].filter(e=>n.has(e)).join(`,`)||`none`,ttfbMs:s(a?.responseStart),domContentLoadedMs:c(a?.domContentLoadedEventEnd),loadMs:c(a?.loadEventEnd),assetCount:o.length,assetBytes:o.reduce((e,t)=>e+(t.transferSize||0),0),assetMs:o.length?s(Math.max(...o.map(e=>e.responseEnd))):null}}function H({cacheKey:e,userName:n,onSelectWhatsappConversation:r}){let i=ee(e),[o,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(null),[m,g]=(0,C.useState)(null),v=(0,C.useRef)(!1),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(null),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(null),[k,A]=(0,C.useState)(null),[j,M]=(0,C.useState)(null),[N,P]=(0,C.useState)(new Set),[B,H]=(0,C.useState)(()=>new Set),U=(0,C.useCallback)(e=>{H(t=>t.has(e)?t:new Set(t).add(e))},[]),W=Date.now(),G=(0,C.useRef)(!1),K=(0,C.useRef)(new Map),q=(0,C.useRef)(new Set),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{if(!e)return;let t=!1;async function n(e,n,r,a){let o=Date.now(),s=typeof n==`string`?n:`unresolved`;try{typeof n!=`string`&&(s=await n());let c=await i(s);if(!c.ok)throw Error(`status ${c.status}`);let l=await c.json();t||a(r(l)),console.info(`[admin-ui] op=dashboard-fetch slice=${e} url=${s} outcome=ok ms=${Date.now()-o}`)}catch(t){q.current.add(e),console.error(`[admin-ui] dashboard-fetch-failed slice=${e} url=${s} ms=${Date.now()-o} reason=${t instanceof Error?t.message:String(t)}`)}finally{K.current.set(e,Date.now()-o),U(e)}}async function r(){if(!J.current){let e=await i(`/api/admin/accounts`);if(!e.ok)throw Error(`accounts status ${e.status}`);let t=await e.json(),n=t.accounts??[],r=t.activeAccountId??null,a=n.find(e=>e.accountId===r);if(!a)throw Error(`accounts: active ${r??`none`} absent from list of ${n.length}`);let o=a.isHouse||n.length===1;J.current={accountId:a.accountId,isHouse:o}}let{accountId:e,isHouse:t}=J.current;return console.info(`[admin-ui] op=dashboard-channels-source source=${t?`all`:`scoped`} account=${e.slice(0,8)}`),t?`/api/operator-conversations/conversations-all`:`/api/operator-conversations/conversations`}let o={"sidebar-sessions":()=>n(`sessions`,`/api/admin/sidebar-sessions`,e=>e.sessions??[],d),"conversations-all":()=>n(`conversations`,r,e=>e.conversations??[],p),"tasks-list":()=>n(`tasks`,`/api/admin/tasks-list`,e=>e,S),"sidebar-artefacts":()=>n(`artefacts`,`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],E),skills:()=>n(`skills`,`/api/admin/skills`,e=>e.skills??[],O)};async function s(){if(G.current)return;G.current=!0;let e=Date.now();try{await Promise.all([...Object.values(o).map(e=>e()),n(`stats`,`/api/admin/system-stats`,e=>e,b),n(`bookingLink`,`/api/admin/calendar/booking-link`,e=>e.bookingDomain??null,A),n(`portalLink`,`/api/admin/data-portal/portal-link`,e=>e.portalDomain??null,M)])}finally{G.current=!1;let t=Date.now()-e;if(console.info(`[admin-ui] op=dashboard-refresh-settled ms=${t}`),!V){V=!0;try{let e=pe(t,K.current,q.current,typeof performance>`u`?null:performance);fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`dashboard-load`,...e}),keepalive:!0}).catch(()=>{})}catch{}}}}s();let c=null;try{c=new EventSource(a(`/api/admin/events`,e)),c.onmessage=e=>{if(document.visibilityState===`visible`)try{let{resource:t}=JSON.parse(e.data),n=t?o[t]:void 0;n&&n()}catch{}},c.onerror=()=>{console.error(`[admin-ui] dashboard-events stream error`)}}catch(e){console.error(`[admin-ui] dashboard-events unavailable reason=${e instanceof Error?e.message:String(e)}`)}let l=setInterval(()=>{document.visibilityState===`visible`&&s()},ce),u=()=>{document.visibilityState===`visible`&&s()};return document.addEventListener(`visibilitychange`,u),()=>{t=!0,G.current=!1,clearInterval(l),c?.close(),document.removeEventListener(`visibilitychange`,u)}},[e,i]);let Y=(0,C.useMemo)(()=>(o??[]).filter(e=>!e.isSubagent),[o]),X=(0,C.useMemo)(()=>Y.filter(e=>e.live),[Y]),me=(0,C.useMemo)(()=>(f??[]).filter(e=>z(e.lastMessageAt,W)).length,[f,W]),he=x?.open.length??0,Z=(0,C.useMemo)(()=>{let e=new Map;for(let t of f??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?de(n):``,rows:t}})},[f]);(0,C.useEffect)(()=>{v.current||Z.length!==0&&(v.current=!0,g(Z[0].channel))},[Z]);let Q=(0,C.useRef)(!1);(0,C.useEffect)(()=>{Q.current||!B.has(`bookingLink`)||!B.has(`portalLink`)||(Q.current=!0,console.info(`[admin-ui] dashboard-public-pages booking=${k!=null} filedrop=${j!=null}`))},[B,k,j]);let ge=(0,C.useCallback)(async e=>{if(!N.has(e)){P(t=>new Set(t).add(e));try{let t=await i(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}console.info(`[admin-ui] dashboard-session-stop sessionId=${e}`),d(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{P(t=>{let n=new Set(t);return n.delete(e),n})}}},[i,N]),_e=(0,C.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}ae(e,t.downloadPath,t.downloadRoot??`data`)},[e]),$=le(new Date(W).getHours());return(0,w.jsxs)(`div`,{className:`ui-page ui-page--full dashboard-home`,children:[(0,w.jsx)(`p`,{className:`dashboard-greeting`,children:B.has(`stats`)?`Good ${$}, ${L(n)} — ${ue(y)}`:`Good ${$}, ${L(n)}`}),(0,w.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),B.has(`sessions`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:X.length}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,Y.length,` total`]})]}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),B.has(`conversations`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:me}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),B.has(`tasks`)?(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:he}):(0,w.jsx)(I,{variant:`value`})]}),(0,w.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,w.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),B.has(`stats`)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`dashboard-stat-value`,children:R(y?.cpuPct??null)}),(0,w.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,R(y?.memUsedPct??null)]})]}):(0,w.jsx)(I,{variant:`value`})]})]}),(0,w.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(k||j)&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Public pages`}),(0,w.jsxs)(`div`,{className:`admin-card dashboard-public-pages`,children:[k&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${k}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`Booking page`})]}),j&&(0,w.jsxs)(`a`,{className:`admin-row dashboard-public-row`,href:`https://${j}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,w.jsx)(`span`,{className:`dashboard-public-icon`,children:(0,w.jsx)(_,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-public-name`,children:`File drop`})]})]})]}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),B.has(`sessions`)?X.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):X.map(e=>{let t=[e.sessionId.slice(0,8),fe(e.model),F(Date.parse(e.startedAt),W)].filter(Boolean).join(` · `);return(0,w.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,w.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,w.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,w.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,w.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,w.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,w.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:N.has(e.sessionId),onClick:()=>void ge(e.sessionId),children:(0,w.jsx)(te,{size:12})})]},e.sessionId)}):(0,w.jsx)(I,{variant:`card`,count:2}),(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:B.has(`artefacts`)?(T??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(T??[]).slice(0,6).map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>_e(e),children:[(0,w.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,w.jsx)(h,{size:16}):(0,w.jsx)(se,{size:16})}),(0,w.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,w.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,w.jsx)(`span`,{className:`dashboard-artefact-time`,children:F(Date.parse(e.updatedAt),W)})]},e.id)):(0,w.jsx)(I,{count:3})}),(0,w.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,w.jsx)(`div`,{className:`admin-card dashboard-skills`,children:B.has(`skills`)?(D??[]).length===0?(0,w.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(D??[]).map(e=>(0,w.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,w.jsx)(ie,{size:16})}),(0,w.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,w.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,w.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`)):(0,w.jsx)(I,{count:2})})]}),(0,w.jsxs)(`div`,{className:`dashboard-col`,children:[(0,w.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),B.has(`conversations`)?Z.length===0?(0,w.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):Z.map(n=>{let i=m===n.channel;return(0,w.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":i,onClick:()=>g(e=>e===n.channel?null:n.channel),children:[(0,w.jsx)(`span`,{className:`dashboard-channel-glyph`,children:n.channel===`whatsapp`||n.channel===`telegram`?(0,w.jsx)(c,{channel:n.channel,size:16}):(0,w.jsx)(t,{size:16})}),(0,w.jsx)(`span`,{className:`dashboard-channel-name`,children:u[n.channel]??n.channel}),(0,w.jsx)(`span`,{className:`dashboard-channel-badge`,children:n.count}),(0,w.jsx)(`span`,{className:`dashboard-channel-chevron`,children:i?(0,w.jsx)(re,{size:14}):(0,w.jsx)(oe,{size:14})})]}),i?(0,w.jsx)(`div`,{className:`dashboard-channel-convs`,children:n.rows.map(t=>(0,w.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>r(t),title:t.title,children:[(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-line`,children:[(0,w.jsx)(ne,{accountId:t.accountId??``,jid:t.remoteJid,sessionKey:e??``,className:`dashboard-channel-conv-avatar`,size:16}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:s(t)}),t.isGroup===!0&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-group`,children:`Group`}),t.role===`public`&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag is-public`,children:`Public`}),(0,w.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:t.isHouse?`House`:`Client`}),!t.preview&&t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}),t.preview?(0,w.jsxs)(`span`,{className:`dashboard-channel-conv-sub`,children:[(0,w.jsx)(`span`,{className:`dashboard-channel-conv-preview`,children:t.preview}),t.lastMessageAt&&(0,w.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:F(Date.parse(t.lastMessageAt),W)})]}):null]},l(t)))}):n.preview&&(0,w.jsx)(`span`,{className:`dashboard-channel-preview`,children:n.preview})]},n.channel)}):(0,w.jsx)(I,{variant:`card`,count:2})]})]})]})}function U(){let e=d(),[t,n]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,C.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();if(!e.cacheKey){console.error(`[admin-ui] claude-info-fetch-skipped reason=no-session-key`);return}try{let t=await fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(e.cacheKey)}`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,C.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,w.jsx)(o,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,w.jsx)(v,{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,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(T,{onOpen:r}),(0,w.jsx)(g,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,w.jsx)(w.Fragment,{children:t.dataOpen&&e.cacheKey?(0,w.jsx)(b,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,w.jsx)(x,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:s(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(E,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:s(t.selectedWhatsapp),onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,w.jsx)(H,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,w.jsx)(f,{auth:e})}(0,S.createRoot)(document.getElementById(`root`)).render((0,w.jsx)(U,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,J as r,K as i,L as a,O as o,_ as s,b as c,g as l,y as u}from"./useSubAccountSwitcher-DMr3DR5N.js";import{C as d,O as f,b as p,t as m}from"./AdminShell-BxJPbC3p.js";var h=a(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),g=a(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),_=i(),v=e(r(),1),y={green:`success`,amber:`warning`,red:`error`};function b(e){if(!e.startsWith(`mcp__`))return e;let t=e.slice(5),n=t.indexOf(`__`);if(n<0)return e;let r=t.slice(n+2);return r.length>0?r:e}function x(e){let t=` Nothing will be able to hand work to it until it is switched back on.`;if(e.length===0)return t;let n=e.length===1?`skill runs`:`skills run`;return` ${e.length} ${n} through it: ${e.join(`, `)}.${t}`}var S=n(),C={read:`read`,write_local:`writes`,exec:`runs`,external:`sends`},w={read:`tool-chip-read`,write_local:`tool-chip-write_local`,exec:`tool-chip-exec`,external:`tool-chip-external`,unresolved:`tool-chip-unresolved`};function T({label:e,body:t}){return(0,S.jsxs)(`div`,{className:`agent-doc`,children:[(0,S.jsx)(`span`,{className:`agent-doc-label`,children:e}),(0,S.jsx)(`pre`,{className:`skill-body`,children:t.trim()||`Empty.`})]})}function E({summary:e,publicBaseUrl:t,accountId:n,adminFetch:r,onClose:i,onDeleted:a,onToggled:s}){let l=e.kind===`specialist`,f=e.origin===`specialist`,m=e.origin===`shipped`&&e.disabled,_=f||m,[E]=(0,v.useState)(n),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!0),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!1;A(!0),M(null);let n=e.origin===`shipped`?`?origin=shipped`:e.kind===`specialist`&&e.plugin?`?plugin=${encodeURIComponent(e.plugin)}`:``;return r(`/api/admin/agents/${encodeURIComponent(e.slug)}${n}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);O((await e.json()).agent)}}).catch(e=>{t||M(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||A(!1)}),()=>{t=!0}},[r,e.slug]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!F&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[F,i]);let V=(0,v.useCallback)(async()=>{I(!0),M(null);try{let t=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}?accountId=${encodeURIComponent(E??``)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e)}catch(e){M(e instanceof Error?e.message:`Delete failed`),I(!1),P(!1)}},[r,e,E,a]),H=(0,v.useCallback)(async()=>{let t=e.disabled?`enable`:`disable`;B(!0),M(null);try{let n=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}/${t}?accountId=${encodeURIComponent(E??``)}`,{method:`POST`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}s(),i()}catch(e){M(e instanceof Error?e.message:`${t} failed`),B(!1),R(!1)}},[r,e,E,s,i]),U=l?null:D,W=l?D:null;return(0,S.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{F||i()},children:(0,S.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Agent detail`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,S.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,S.jsx)(d,{size:13}),` `,l?`Specialist`:`Agent`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:F,children:(0,S.jsx)(u,{size:16})})]}),(0,S.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,S.jsx)(`div`,{className:`cal-modal-title`,children:e.displayName}),(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[!l&&(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,S.jsxs)(`span`,{children:[`/`,e.slug]}),e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,children:e.risk===`green`?`Read only`:e.risk===`amber`?`Writes`:`Runs`}),e.disabled&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--tint-error`,children:`Disabled`})]}),e.risk&&e.riskReason&&(0,S.jsx)(`div`,{className:`cal-modal-row agent-risk-reason`,children:(0,S.jsx)(`span`,{children:e.riskReason})}),e.unresolved.length>0&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[`Forced to Runs: no declared risk class for `,e.unresolved.join(`, `),`.`]})}),k&&(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,S.jsx)(o,{size:14,className:`spin`}),(0,S.jsx)(`span`,{children:`Loading…`})]}),U&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[U.status,U.model?` · ${U.model}`:``]})}),(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`a`,{href:`${t}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`cal-link`,children:[(0,S.jsx)(p,{size:13}),` Open agent`]})}),U.present.identity&&(0,S.jsx)(T,{label:`Identity`,body:U.identity}),U.present.soul&&(0,S.jsx)(T,{label:`Soul`,body:U.soul}),U.present.knowledge&&(0,S.jsx)(T,{label:`Knowledge`,body:U.knowledge}),U.present.knowledgeSummary&&(0,S.jsx)(T,{label:`Knowledge summary`,body:U.knowledgeSummary}),U.knowledgeKeywords.length>0&&(0,S.jsxs)(`div`,{className:`skill-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Knowledge keywords`}),U.knowledgeKeywords.map(e=>(0,S.jsx)(`span`,{className:`skill-ref`,children:e},e))]})]}),W&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[e.plugin,W.model?` · ${W.model}`:``]})}),W.description&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsx)(`span`,{children:W.description})}),W.byTool.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsxs)(`span`,{className:`skill-refs-label`,children:[`Tools (`,W.byTool.length,`)`]}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.byTool.map(({tool:e,risk:t})=>(0,S.jsx)(`span`,{"data-testid":`tool-chip-${e}`,className:`tool-chip ${w[t??`unresolved`]}`,title:t?`${e} — ${C[t]}`:`${e} — no declared risk class`,children:b(e)},e))})]}),W.skills.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Skills`}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.skills.map(e=>(0,S.jsx)(`span`,{className:`tool-chip tool-chip-skill`,children:e},e))})]}),(0,S.jsx)(T,{label:`System prompt`,body:W.systemPrompt})]})]}),j&&(0,S.jsx)(`div`,{className:`cal-modal-error`,children:j}),(0,S.jsx)(`div`,{className:`cal-modal-actions`,children:_?L?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:e.disabled?`Put this agent back in the dispatchable set?`:`Stop this agent being dispatched?${x(W?.skills??[])}`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:H,disabled:z,children:[z?(0,S.jsx)(o,{size:14,className:`spin`}):e.disabled?(0,S.jsx)(g,{size:14}):(0,S.jsx)(h,{size:14}),e.disabled?` Enable`:` Disable`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>R(!1),disabled:z,children:`Cancel`})]}):(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>R(!0),disabled:z||k||!E,children:e.disabled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{size:14}),` Enable`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(h,{size:14}),` Disable`]})}):l?(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`This agent is part of the product. To stop it running on its own, suspend the routines that dispatch it.`}):(0,S.jsxs)(S.Fragment,{children:[!N&&(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>P(!0),disabled:F||k||!E,children:[(0,S.jsx)(c,{size:14}),` Delete`]}),N&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this agent?`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:V,disabled:F,children:[F?(0,S.jsx)(o,{size:14,className:`spin`}):(0,S.jsx)(c,{size:14}),` Delete`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>P(!1),disabled:F,children:`Cancel`})]})]})})]})})}var D=`maxy-admin-session-key`,O={green:`Read only`,amber:`Writes`,red:`Runs`},k={shipped:`Shipped`,specialist:`Specialist`,public:`Public`};function A(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(void 0),[o,c]=(0,v.useState)(null),[u,d]=(0,v.useState)(void 0),[p,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}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(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),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 y=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[b,x]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{x(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return n?e?(0,S.jsx)(s,{cacheKey:e,surface:`agents`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=agents`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,S.jsx)(m,{cacheKey:e,businessName:i,sessionId:o,onLogout:y,onDisconnect:C,disconnecting:b,userName:u,userAvatar:p,role:g,children:(0,S.jsx)(j,{cacheKey:e})})}):(0,S.jsx)(`div`,{className:`cal-page`,children:(0,S.jsxs)(`div`,{className:`cal-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,S.jsx)(l,{surface:`gate`})}function j({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`agents`}),[i,a]=(0,v.useState)([]),[s,c]=(0,v.useState)(0),[u,f]=(0,v.useState)(0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(!1),[x,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),[D,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(``);(0,v.useEffect)(()=>{M(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]);let N=(0,v.useCallback)(()=>{let e=!1;return b(!0),T(null),n(`/api/admin/agents`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();a(Array.isArray(n.agents)?n.agents:[]),c(typeof n.skipped==`number`?n.skipped:0),f(typeof n.specialistsSkipped==`number`?n.specialistsSkipped:0),g(typeof n.accountId==`string`?n.accountId:null),m(n.riskSurfaceFailed===!0)}).catch(t=>{e||(T(t instanceof Error?t.message:`Failed to load`),a([]))}).finally(()=>{e||(b(!1),C(!0))}),()=>{e=!0}},[n]);(0,v.useEffect)(()=>N(),[N,r]);let P=(0,v.useCallback)(e=>{a(t=>t.filter(t=>t.slug!==e.slug)),A(null),N()},[N]);if(!x)return(0,S.jsx)(l,{surface:`gate`});let F=i.filter(e=>e.disabled).length;return(0,S.jsxs)(`div`,{className:`cal-page`,children:[(0,S.jsx)(`header`,{className:`cal-header`,children:(0,S.jsxs)(`div`,{className:`cal-nav`,children:[(0,S.jsxs)(`span`,{className:`cal-range-label`,children:[(0,S.jsx)(d,{size:16}),` `,i.length,` agent`,i.length===1?``:`s`,` · `,F,` stood down`]}),_&&(0,S.jsx)(o,{size:16,className:`spin`})]})}),(0,S.jsxs)(`div`,{className:`cal-body`,children:[w&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[`Could not load agents: `,w]}),p&&(0,S.jsx)(`div`,{className:`cal-error`,children:`The plugin registry could not be read, so every agent below is shown at the highest risk regardless of the tools it declares. These badges are not derived.`}),s+u>0&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[s+u,` agent`,s+u===1?``:`s`,` could not be read (malformed config or frontmatter).`]}),!w&&!_&&i.length===0&&(0,S.jsx)(`div`,{className:`cal-empty`,children:(0,S.jsx)(`p`,{children:`No agents yet. Ask in chat to create one.`})}),i.length>0&&(0,S.jsx)(`div`,{className:`routine-list`,children:i.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>A(e),children:[(0,S.jsxs)(`span`,{className:`admin-card-title routine-card-title`,children:[e.displayName,e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,"data-testid":`agent-risk-badge`,children:O[e.risk]}),(0,S.jsx)(`span`,{className:`ui-pill agent-origin-${e.origin}`,children:k[e.origin]}),e.kind===`specialist`&&(0,S.jsx)(`span`,{className:`ui-pill ${e.disabled?`ui-pill--tint-error`:`ui-pill--tint-success`}`,children:e.disabled?`Stood down`:`Live`})]}),e.kind===`specialist`?(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[`/`,e.slug]}):(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),` /`,e.slug]}),(0,S.jsx)(`span`,{className:`routine-card-meta`,children:e.origin===`public`?e.status:e.plugin})]},`${e.origin}:${e.slug}`))})]}),D&&(0,S.jsx)(E,{summary:D,publicBaseUrl:j,accountId:h,adminFetch:n,onClose:()=>A(null),onDeleted:P,onToggled:N})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(A,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,J as r,K as i,L as a,O as o,_ as s,b as c,g as l,y as u}from"./useSubAccountSwitcher-HjQZjJBr.js";import{C as d,O as f,b as p,t as m}from"./AdminShell-Cbk0TL1B.js";var h=a(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),g=a(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),_=i(),v=e(r(),1),y={green:`success`,amber:`warning`,red:`error`};function b(e){if(!e.startsWith(`mcp__`))return e;let t=e.slice(5),n=t.indexOf(`__`);if(n<0)return e;let r=t.slice(n+2);return r.length>0?r:e}function x(e){let t=` Nothing will be able to hand work to it until it is switched back on.`;if(e.length===0)return t;let n=e.length===1?`skill runs`:`skills run`;return` ${e.length} ${n} through it: ${e.join(`, `)}.${t}`}var S=n(),C={read:`read`,write_local:`writes`,exec:`runs`,external:`sends`},w={read:`tool-chip-read`,write_local:`tool-chip-write_local`,exec:`tool-chip-exec`,external:`tool-chip-external`,unresolved:`tool-chip-unresolved`};function T({label:e,body:t}){return(0,S.jsxs)(`div`,{className:`agent-doc`,children:[(0,S.jsx)(`span`,{className:`agent-doc-label`,children:e}),(0,S.jsx)(`pre`,{className:`skill-body`,children:t.trim()||`Empty.`})]})}function E({summary:e,publicBaseUrl:t,accountId:n,adminFetch:r,onClose:i,onDeleted:a,onToggled:s}){let l=e.kind===`specialist`,f=e.origin===`specialist`,m=e.origin===`shipped`&&e.disabled,_=f||m,[E]=(0,v.useState)(n),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!0),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!1;A(!0),M(null);let n=e.origin===`shipped`?`?origin=shipped`:e.kind===`specialist`&&e.plugin?`?plugin=${encodeURIComponent(e.plugin)}`:``;return r(`/api/admin/agents/${encodeURIComponent(e.slug)}${n}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);O((await e.json()).agent)}}).catch(e=>{t||M(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||A(!1)}),()=>{t=!0}},[r,e.slug]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!F&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[F,i]);let V=(0,v.useCallback)(async()=>{I(!0),M(null);try{let t=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}?accountId=${encodeURIComponent(E??``)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e)}catch(e){M(e instanceof Error?e.message:`Delete failed`),I(!1),P(!1)}},[r,e,E,a]),H=(0,v.useCallback)(async()=>{let t=e.disabled?`enable`:`disable`;B(!0),M(null);try{let n=await r(`/api/admin/agents/${encodeURIComponent(e.slug)}/${t}?accountId=${encodeURIComponent(E??``)}`,{method:`POST`,headers:{"content-type":`application/json`}});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}s(),i()}catch(e){M(e instanceof Error?e.message:`${t} failed`),B(!1),R(!1)}},[r,e,E,s,i]),U=l?null:D,W=l?D:null;return(0,S.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{F||i()},children:(0,S.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Agent detail`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,S.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,S.jsx)(d,{size:13}),` `,l?`Specialist`:`Agent`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:F,children:(0,S.jsx)(u,{size:16})})]}),(0,S.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,S.jsx)(`div`,{className:`cal-modal-title`,children:e.displayName}),(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[!l&&(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,S.jsxs)(`span`,{children:[`/`,e.slug]}),e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,children:e.risk===`green`?`Read only`:e.risk===`amber`?`Writes`:`Runs`}),e.disabled&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--tint-error`,children:`Disabled`})]}),e.risk&&e.riskReason&&(0,S.jsx)(`div`,{className:`cal-modal-row agent-risk-reason`,children:(0,S.jsx)(`span`,{children:e.riskReason})}),e.unresolved.length>0&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[`Forced to Runs: no declared risk class for `,e.unresolved.join(`, `),`.`]})}),k&&(0,S.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,S.jsx)(o,{size:14,className:`spin`}),(0,S.jsx)(`span`,{children:`Loading…`})]}),U&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[U.status,U.model?` · ${U.model}`:``]})}),(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`a`,{href:`${t}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`cal-link`,children:[(0,S.jsx)(p,{size:13}),` Open agent`]})}),U.present.identity&&(0,S.jsx)(T,{label:`Identity`,body:U.identity}),U.present.soul&&(0,S.jsx)(T,{label:`Soul`,body:U.soul}),U.present.knowledge&&(0,S.jsx)(T,{label:`Knowledge`,body:U.knowledge}),U.present.knowledgeSummary&&(0,S.jsx)(T,{label:`Knowledge summary`,body:U.knowledgeSummary}),U.knowledgeKeywords.length>0&&(0,S.jsxs)(`div`,{className:`skill-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Knowledge keywords`}),U.knowledgeKeywords.map(e=>(0,S.jsx)(`span`,{className:`skill-ref`,children:e},e))]})]}),W&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsxs)(`span`,{children:[e.plugin,W.model?` · ${W.model}`:``]})}),W.description&&(0,S.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,S.jsx)(`span`,{children:W.description})}),W.byTool.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsxs)(`span`,{className:`skill-refs-label`,children:[`Tools (`,W.byTool.length,`)`]}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.byTool.map(({tool:e,risk:t})=>(0,S.jsx)(`span`,{"data-testid":`tool-chip-${e}`,className:`tool-chip ${w[t??`unresolved`]}`,title:t?`${e} — ${C[t]}`:`${e} — no declared risk class`,children:b(e)},e))})]}),W.skills.length>0&&(0,S.jsxs)(`div`,{className:`chip-refs`,children:[(0,S.jsx)(`span`,{className:`skill-refs-label`,children:`Skills`}),(0,S.jsx)(`div`,{className:`chip-row`,children:W.skills.map(e=>(0,S.jsx)(`span`,{className:`tool-chip tool-chip-skill`,children:e},e))})]}),(0,S.jsx)(T,{label:`System prompt`,body:W.systemPrompt})]})]}),j&&(0,S.jsx)(`div`,{className:`cal-modal-error`,children:j}),(0,S.jsx)(`div`,{className:`cal-modal-actions`,children:_?L?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:e.disabled?`Put this agent back in the dispatchable set?`:`Stop this agent being dispatched?${x(W?.skills??[])}`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:H,disabled:z,children:[z?(0,S.jsx)(o,{size:14,className:`spin`}):e.disabled?(0,S.jsx)(g,{size:14}):(0,S.jsx)(h,{size:14}),e.disabled?` Enable`:` Disable`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>R(!1),disabled:z,children:`Cancel`})]}):(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>R(!0),disabled:z||k||!E,children:e.disabled?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(g,{size:14}),` Enable`]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(h,{size:14}),` Disable`]})}):l?(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`This agent is part of the product. To stop it running on its own, suspend the routines that dispatch it.`}):(0,S.jsxs)(S.Fragment,{children:[!N&&(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>P(!0),disabled:F||k||!E,children:[(0,S.jsx)(c,{size:14}),` Delete`]}),N&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this agent?`}),(0,S.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:V,disabled:F,children:[F?(0,S.jsx)(o,{size:14,className:`spin`}):(0,S.jsx)(c,{size:14}),` Delete`]}),(0,S.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>P(!1),disabled:F,children:`Cancel`})]})]})})]})})}var D=`maxy-admin-session-key`,O={green:`Read only`,amber:`Writes`,red:`Runs`},k={shipped:`Shipped`,specialist:`Specialist`,public:`Public`};function A(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(void 0),[o,c]=(0,v.useState)(null),[u,d]=(0,v.useState)(void 0),[p,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}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(D)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),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 y=(0,v.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[b,x]=(0,v.useState)(!1),C=(0,v.useCallback)(async()=>{x(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return n?e?(0,S.jsx)(s,{cacheKey:e,surface:`agents`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=agents`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,S.jsx)(m,{cacheKey:e,businessName:i,sessionId:o,onLogout:y,onDisconnect:C,disconnecting:b,userName:u,userAvatar:p,role:g,children:(0,S.jsx)(j,{cacheKey:e})})}):(0,S.jsx)(`div`,{className:`cal-page`,children:(0,S.jsxs)(`div`,{className:`cal-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,S.jsx)(l,{surface:`gate`})}function j({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`agents`}),[i,a]=(0,v.useState)([]),[s,c]=(0,v.useState)(0),[u,f]=(0,v.useState)(0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,b]=(0,v.useState)(!1),[x,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(null),[D,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(``);(0,v.useEffect)(()=>{M(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]);let N=(0,v.useCallback)(()=>{let e=!1;return b(!0),T(null),n(`/api/admin/agents`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();a(Array.isArray(n.agents)?n.agents:[]),c(typeof n.skipped==`number`?n.skipped:0),f(typeof n.specialistsSkipped==`number`?n.specialistsSkipped:0),g(typeof n.accountId==`string`?n.accountId:null),m(n.riskSurfaceFailed===!0)}).catch(t=>{e||(T(t instanceof Error?t.message:`Failed to load`),a([]))}).finally(()=>{e||(b(!1),C(!0))}),()=>{e=!0}},[n]);(0,v.useEffect)(()=>N(),[N,r]);let P=(0,v.useCallback)(e=>{a(t=>t.filter(t=>t.slug!==e.slug)),A(null),N()},[N]);if(!x)return(0,S.jsx)(l,{surface:`gate`});let F=i.filter(e=>e.disabled).length;return(0,S.jsxs)(`div`,{className:`cal-page`,children:[(0,S.jsx)(`header`,{className:`cal-header`,children:(0,S.jsxs)(`div`,{className:`cal-nav`,children:[(0,S.jsxs)(`span`,{className:`cal-range-label`,children:[(0,S.jsx)(d,{size:16}),` `,i.length,` agent`,i.length===1?``:`s`,` · `,F,` stood down`]}),_&&(0,S.jsx)(o,{size:16,className:`spin`})]})}),(0,S.jsxs)(`div`,{className:`cal-body`,children:[w&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[`Could not load agents: `,w]}),p&&(0,S.jsx)(`div`,{className:`cal-error`,children:`The plugin registry could not be read, so every agent below is shown at the highest risk regardless of the tools it declares. These badges are not derived.`}),s+u>0&&(0,S.jsxs)(`div`,{className:`cal-error`,children:[s+u,` agent`,s+u===1?``:`s`,` could not be read (malformed config or frontmatter).`]}),!w&&!_&&i.length===0&&(0,S.jsx)(`div`,{className:`cal-empty`,children:(0,S.jsx)(`p`,{children:`No agents yet. Ask in chat to create one.`})}),i.length>0&&(0,S.jsx)(`div`,{className:`routine-list`,children:i.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>A(e),children:[(0,S.jsxs)(`span`,{className:`admin-card-title routine-card-title`,children:[e.displayName,e.risk&&(0,S.jsx)(`span`,{className:`ui-pill ui-pill--solid-${y[e.risk]}`,"data-testid":`agent-risk-badge`,children:O[e.risk]}),(0,S.jsx)(`span`,{className:`ui-pill agent-origin-${e.origin}`,children:k[e.origin]}),e.kind===`specialist`&&(0,S.jsx)(`span`,{className:`ui-pill ${e.disabled?`ui-pill--tint-error`:`ui-pill--tint-success`}`,children:e.disabled?`Stood down`:`Live`})]}),e.kind===`specialist`?(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[`/`,e.slug]}):(0,S.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,S.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),` /`,e.slug]}),(0,S.jsx)(`span`,{className:`routine-card-meta`,children:e.origin===`public`?e.status:e.plugin})]},`${e.origin}:${e.slug}`))})]}),D&&(0,S.jsx)(E,{summary:D,publicBaseUrl:j,accountId:h,adminFetch:n,onClose:()=>A(null),onDeleted:P,onToggled:N})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(A,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,H as n,J as r,K as i,O as a,_ as o}from"./useSubAccountSwitcher-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{A as t,H as n,J as r,K as i,O as a,_ as o}from"./useSubAccountSwitcher-HjQZjJBr.js";import{O as s,t as c}from"./AdminShell-Cbk0TL1B.js";import{t as l}from"./CdpScreencastSurface-CLSQHh4e.js";var u=i(),d=e(r(),1),f=n();function p(){let[e,n]=(0,d.useState)(null),[r,i]=(0,d.useState)(!1),[u,p]=(0,d.useState)(void 0),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(void 0),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).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`&&p(e.businessName),e.sessionId!==void 0&&h(e.sessionId??null),x(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let S=(0,d.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,d.useState)(!1),T=(0,d.useCallback)(async()=>{w(!0);try{let e=await s();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,f.jsx)(o,{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,f.jsx)(c,{cacheKey:e,businessName:u,sessionId:m,onLogout:S,onDisconnect:T,disconnecting:C,userName:g,userAvatar:v,role:b,children:(0,f.jsxs)(`div`,{className:`data-page`,children:[(0,f.jsx)(`header`,{className:`data-header`,children:(0,f.jsxs)(`h1`,{className:`data-title`,children:[(0,f.jsx)(t,{size:18}),` Browser`]})}),(0,f.jsx)(l,{})]})})}):(0,f.jsxs)(`div`,{className:`data-page`,children:[(0,f.jsx)(`header`,{className:`data-header`,children:(0,f.jsxs)(`h1`,{className:`data-title`,children:[(0,f.jsx)(t,{size:18}),` Browser`]})}),(0,f.jsxs)(`div`,{className:`data-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:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,f.jsx)(`div`,{className:`data-page`,children:(0,f.jsxs)(`div`,{className:`data-loading`,children:[(0,f.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(p,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,J as r,K as i,L as a,M as o,O as s,T as c,_ as l,b as u,g as d,y as f}from"./useSubAccountSwitcher-DMr3DR5N.js";import{O as p,b as m,t as h}from"./AdminShell-BxJPbC3p.js";import{t as g}from"./chevron-left-ClfIy5Fx.js";import{t as _}from"./chevron-right-B0QvXpxl.js";import{t as v}from"./clock-BIaRnIP_.js";var y=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`}]]),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`}]]),S=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`}]]),C=a(`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`}]]),w=i(),T=e(r(),1);function E(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function D(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function O(e){let t=E(e),n=t.getDay();return D(t,n===0?-6:1-n)}function k(e){let t=O(e);return Array.from({length:7},(e,n)=>D(t,n))}function A(e){let t=O(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>D(t,n))}function j(){return Array.from({length:24},(e,t)=>t)}function M(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function N(e,t){switch(e){case`day`:{let e=E(t);return{from:e,to:D(e,1)}}case`week`:{let e=O(t);return{from:e,to:D(e,7)}}case`month`:{let e=O(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:D(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function P(e,t,n){switch(e){case`day`:return D(t,n);case`week`:return D(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 F(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function I(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var L=n(),R=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],z=3;function ee(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=A(e),i=e.getMonth(),a=new Date;return(0,L.jsxs)(`div`,{className:`cal-month`,children:[(0,L.jsx)(`div`,{className:`cal-weekday-row`,children:R.map(e=>(0,L.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,L.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>F(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=F(e,a);return(0,L.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,L.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,z).map(e=>(0,L.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...I(e,n),children:[!e.isAllDay&&(0,L.jsx)(`span`,{className:`cal-chip-time`,children:ee(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>z&&(0,L.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-z,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsx)(`div`,{className:`cal-day-col`,children:(0,L.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,L.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=U(n),o=F(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,L.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...I(t,r),children:[(0,L.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,L.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=new Date;return(0,L.jsxs)(`div`,{className:`cal-timed`,children:[(0,L.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,L.jsxs)(`div`,{className:`cal-day-head${F(e,i)?` cal-day-head-today`:``}`,children:[(0,L.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,L.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e)).map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,L.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,L.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var te=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function ne(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function re({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>ne(new Date(e.startsAt))));return(0,L.jsx)(`div`,{className:`cal-year`,children:(0,L.jsx)(`div`,{className:`cal-year-grid`,children:M(e).map(e=>{let t=A(e),a=e.getMonth();return(0,L.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,L.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,L.jsx)(`div`,{className:`cal-mini-weekrow`,children:te.map((e,t)=>(0,L.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,L.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=F(e,r),o=!t&&i.has(ne(e));return(0,L.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,L.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var ie={meeting:`Meeting`,event:`Event`,task:`Task`};function ae(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 oe(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function se(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 ce(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function le(e,t){return e.email??`${e.name??`unknown`}-${t}`}function ue({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,L.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,L.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,L.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function de({meeting:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let a=e.kind===`meeting`,[l,d]=(0,T.useState)(!1),[p,m]=(0,T.useState)(!1),[h,g]=(0,T.useState)(!1),[_,w]=(0,T.useState)(!1),[E,D]=(0,T.useState)(null),[O,k]=(0,T.useState)(e),[A,j]=(0,T.useState)(e.title??``),[M,N]=(0,T.useState)(ae(e.startsAt)),[P,F]=(0,T.useState)(e.endsAt?ae(e.endsAt):``),[I,R]=(0,T.useState)(e.location??``),[z,ee]=(0,T.useState)(e.privateNote??``),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(``);(0,T.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!_&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,n]);let W=(0,T.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=oe(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?oe(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,I,z,O]),G=(0,T.useCallback)(async()=>{let n=W();if(Object.keys(n).length===0){d(!1);return}w(!0),D(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),r(a.meeting),d(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[t,W,e.meetingId,r]),K=(0,T.useCallback)(async()=>{let n=B.trim(),i=H.trim();if(!(!n&&!i)){w(!0),D(null);try{let a=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:i||void 0})});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();k(o.meeting),r(o.meeting),V(``),U(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[t,B,H,e.meetingId,r]),q=(0,T.useCallback)(async n=>{let i=n.email?{email:n.email}:{name:n.name};w(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(i)});if(!n.ok)throw Error(`HTTP ${n.status}`);let a=await n.json();k(a.meeting),r(a.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[t,e.meetingId,r]),J=(0,T.useCallback)(async()=>{w(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!n.ok)throw Error(`HTTP ${n.status}`);i(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),w(!1)}},[t,e.meetingId,i]),Y=(0,T.useCallback)(async n=>{g(!1),w(!0),D(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=ce(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[t,e.meetingId]),X=ie[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{_||n()},children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":l?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsx)(`span`,{className:`cal-modal-kind`,children:X}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:_,children:(0,L.jsx)(f,{size:16})})]}),!l&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(v,{size:14}),(0,L.jsx)(`span`,{children:se(O)})]}),O.location&&(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(b,{size:14}),(0,L.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(C,{size:14}),(0,L.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,L.jsx)(`div`,{className:`cal-attendee-row`,children:(0,L.jsx)(ue,{a:e})},le(e,t)))})]}),O.privateNote&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(x,{size:14}),(0,L.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(y,{size:14}),(0,L.jsx)(`span`,{children:X})]})]}),l&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Title`}),(0,L.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Start`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`End`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Location`}),(0,L.jsx)(`input`,{type:`text`,value:I,onChange:e=>R(e.target.value),disabled:_})]}),(0,L.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Attendees`}),(0,L.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,L.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,L.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,L.jsx)(ue,{a:e}),(0,L.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:_,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,L.jsx)(f,{size:13})})]},le(e,t)))]}),(0,L.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:_,"aria-label":`Attendee name`}),(0,L.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:_,"aria-label":`Attendee email`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:_||!Z,"aria-label":`Add attendee`,children:_?(0,L.jsx)(s,{size:13,className:`spin`}):(0,L.jsx)(S,{size:13})})]})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Private note`}),(0,L.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>ee(e.target.value),disabled:_,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:E}),a&&(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[!l&&!p&&!h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:_,children:[(0,L.jsx)(c,{size:14}),` Edit`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:_,children:[(0,L.jsx)(u,{size:14}),` Delete`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):Y(!1)},disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):(0,L.jsx)(o,{size:14}),` Download`]})]}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Yes`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:_,children:`No`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:_,children:`Cancel`})]}),l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Save`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),D(null)},disabled:_,children:`Cancel`})]}),p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:J,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Delete`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:_,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,fe=[`day`,`week`,`month`,`year`];function pe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=N(`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 me(){let[e,t]=(0,T.useState)(null),[n,r]=(0,T.useState)(!1),[i,a]=(0,T.useState)(void 0),[o,s]=(0,T.useState)(null),[c,u]=(0,T.useState)(void 0),[f,m]=(0,T.useState)(null),[g,_]=(0,T.useState)(null);(0,T.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),m(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,T.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,T.useState)(!1),x=(0,T.useCallback)(async()=>{b(!0);try{let e=await p();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,L.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,L.jsx)(h,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:c,userAvatar:f,role:g,children:(0,L.jsx)(he,{cacheKey:e})})}):(0,L.jsx)(`div`,{className:`cal-page`,children:(0,L.jsxs)(`div`,{className:`cal-empty`,children:[(0,L.jsx)(`p`,{children:`You are not signed in.`}),(0,L.jsxs)(`p`,{children:[`Open the `,(0,L.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,L.jsx)(d,{surface:`gate`})}function he({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`calendar`}),[i,a]=(0,T.useState)(`month`),[o,c]=(0,T.useState)(()=>new Date),[l,u]=(0,T.useState)([]),[f,p]=(0,T.useState)(!1),[h,v]=(0,T.useState)(!1),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(null),[C,w]=(0,T.useState)(null);(0,T.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&&w(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[n]),(0,T.useEffect)(()=>{let e=!1,{from:t,to:r}=N(i,o);return p(!0),b(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();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(b(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||(p(!1),v(!0))}),()=>{e=!0}},[i,o,r,n]);let E=(0,T.useCallback)(()=>c(new Date),[]),D=(0,T.useCallback)(()=>c(e=>P(i,e,-1)),[i]),O=(0,T.useCallback)(()=>c(e=>P(i,e,1)),[i]),k=(0,T.useCallback)(e=>{c(e),a(`month`)},[]);(0,T.useEffect)(()=>{S(null)},[i,o]);let A=(0,T.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),S(e)},[]),j=(0,T.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),S(null)},[]);return h?(0,L.jsxs)(`div`,{className:`cal-page`,children:[(0,L.jsxs)(`header`,{className:`cal-header`,children:[(0,L.jsxs)(`div`,{className:`cal-nav`,children:[(0,L.jsx)(`span`,{className:`cal-range-label`,children:pe(i,o)}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:D,"aria-label":`Previous`,children:(0,L.jsx)(g,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:O,"aria-label":`Next`,children:(0,L.jsx)(_,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:E,children:`Today`}),f&&(0,L.jsx)(s,{size:16,className:`spin`})]}),(0,L.jsx)(`div`,{className:`cal-views`,children:fe.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===i?` cal-view-btn-active`:``}`,onClick:()=>a(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),C&&(0,L.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${C}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,L.jsx)(m,{size:14}),` Booking page`]})]}),(0,L.jsxs)(`div`,{className:`cal-body`,children:[y&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,y]}),i===`day`&&(0,L.jsx)(Z,{anchor:o,meetings:l,onSelect:S}),i===`week`&&(0,L.jsx)(J,{anchor:o,meetings:l,onSelect:S}),i===`month`&&(0,L.jsx)(B,{anchor:o,meetings:l,onSelect:S}),i===`year`&&(0,L.jsx)(re,{anchor:o,meetings:l,onPickMonth:k})]}),x&&(0,L.jsx)(de,{meeting:x,adminFetch:n,onClose:()=>S(null),onSaved:A,onDeleted:j})]}):(0,L.jsx)(d,{surface:`gate`})}(0,w.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(me,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{G as t,H as n,J as r,K as i,L as a,M as o,O as s,T as c,_ as l,b as u,g as d,y as f}from"./useSubAccountSwitcher-HjQZjJBr.js";import{O as p,b as m,t as h}from"./AdminShell-Cbk0TL1B.js";import{t as g}from"./chevron-left-C8LTc7lb.js";import{t as _}from"./chevron-right-Lz9t7Hed.js";import{t as v}from"./clock-D6QQFHwJ.js";var y=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`}]]),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`}]]),S=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`}]]),C=a(`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`}]]),w=i(),T=e(r(),1);function E(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function D(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function O(e){let t=E(e),n=t.getDay();return D(t,n===0?-6:1-n)}function k(e){let t=O(e);return Array.from({length:7},(e,n)=>D(t,n))}function A(e){let t=O(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>D(t,n))}function j(){return Array.from({length:24},(e,t)=>t)}function M(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function N(e,t){switch(e){case`day`:{let e=E(t);return{from:e,to:D(e,1)}}case`week`:{let e=O(t);return{from:e,to:D(e,7)}}case`month`:{let e=O(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:D(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function P(e,t,n){switch(e){case`day`:return D(t,n);case`week`:return D(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 F(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function I(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var L=n(),R=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],z=3;function ee(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=A(e),i=e.getMonth(),a=new Date;return(0,L.jsxs)(`div`,{className:`cal-month`,children:[(0,L.jsx)(`div`,{className:`cal-weekday-row`,children:R.map(e=>(0,L.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,L.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>F(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=F(e,a);return(0,L.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,L.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,z).map(e=>(0,L.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...I(e,n),children:[!e.isAllDay&&(0,L.jsx)(`span`,{className:`cal-chip-time`,children:ee(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>z&&(0,L.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-z,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsx)(`div`,{className:`cal-day-col`,children:(0,L.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,L.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=U(n),o=F(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,L.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...I(t,r),children:[(0,L.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,L.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=new Date;return(0,L.jsxs)(`div`,{className:`cal-timed`,children:[(0,L.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,L.jsxs)(`div`,{className:`cal-day-head${F(e,i)?` cal-day-head-today`:``}`,children:[(0,L.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,L.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e)).map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,L.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&F(new Date(t.startsAt),e));return(0,L.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,L.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,L.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,L.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...I(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,L.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,L.jsx)(`div`,{className:`cal-timed-gutter`,children:j().map(e=>(0,L.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,L.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var te=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function ne(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function re({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>ne(new Date(e.startsAt))));return(0,L.jsx)(`div`,{className:`cal-year`,children:(0,L.jsx)(`div`,{className:`cal-year-grid`,children:M(e).map(e=>{let t=A(e),a=e.getMonth();return(0,L.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,L.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,L.jsx)(`div`,{className:`cal-mini-weekrow`,children:te.map((e,t)=>(0,L.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,L.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=F(e,r),o=!t&&i.has(ne(e));return(0,L.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,L.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var ie={meeting:`Meeting`,event:`Event`,task:`Task`};function ae(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 oe(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function se(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 ce(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function le(e,t){return e.email??`${e.name??`unknown`}-${t}`}function ue({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,L.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,L.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,L.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function de({meeting:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let a=e.kind===`meeting`,[l,d]=(0,T.useState)(!1),[p,m]=(0,T.useState)(!1),[h,g]=(0,T.useState)(!1),[_,w]=(0,T.useState)(!1),[E,D]=(0,T.useState)(null),[O,k]=(0,T.useState)(e),[A,j]=(0,T.useState)(e.title??``),[M,N]=(0,T.useState)(ae(e.startsAt)),[P,F]=(0,T.useState)(e.endsAt?ae(e.endsAt):``),[I,R]=(0,T.useState)(e.location??``),[z,ee]=(0,T.useState)(e.privateNote??``),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(``);(0,T.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!_&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,n]);let W=(0,T.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=oe(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?oe(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,I,z,O]),G=(0,T.useCallback)(async()=>{let n=W();if(Object.keys(n).length===0){d(!1);return}w(!0),D(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),r(a.meeting),d(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[t,W,e.meetingId,r]),K=(0,T.useCallback)(async()=>{let n=B.trim(),i=H.trim();if(!(!n&&!i)){w(!0),D(null);try{let a=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:i||void 0})});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();k(o.meeting),r(o.meeting),V(``),U(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[t,B,H,e.meetingId,r]),q=(0,T.useCallback)(async n=>{let i=n.email?{email:n.email}:{name:n.name};w(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(i)});if(!n.ok)throw Error(`HTTP ${n.status}`);let a=await n.json();k(a.meeting),r(a.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[t,e.meetingId,r]),J=(0,T.useCallback)(async()=>{w(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!n.ok)throw Error(`HTTP ${n.status}`);i(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),w(!1)}},[t,e.meetingId,i]),Y=(0,T.useCallback)(async n=>{g(!1),w(!0),D(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=ce(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[t,e.meetingId]),X=ie[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,L.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{_||n()},children:(0,L.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":l?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,L.jsx)(`span`,{className:`cal-modal-kind`,children:X}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:_,children:(0,L.jsx)(f,{size:16})})]}),!l&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(v,{size:14}),(0,L.jsx)(`span`,{children:se(O)})]}),O.location&&(0,L.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,L.jsx)(b,{size:14}),(0,L.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(C,{size:14}),(0,L.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,L.jsx)(`div`,{className:`cal-attendee-row`,children:(0,L.jsx)(ue,{a:e})},le(e,t)))})]}),O.privateNote&&(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,L.jsx)(x,{size:14}),(0,L.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,L.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,L.jsx)(y,{size:14}),(0,L.jsx)(`span`,{children:X})]})]}),l&&(0,L.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Title`}),(0,L.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Start`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`End`}),(0,L.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:_})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Location`}),(0,L.jsx)(`input`,{type:`text`,value:I,onChange:e=>R(e.target.value),disabled:_})]}),(0,L.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Attendees`}),(0,L.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,L.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,L.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,L.jsx)(ue,{a:e}),(0,L.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:_,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,L.jsx)(f,{size:13})})]},le(e,t)))]}),(0,L.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:_,"aria-label":`Attendee name`}),(0,L.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:_,"aria-label":`Attendee email`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:_||!Z,"aria-label":`Add attendee`,children:_?(0,L.jsx)(s,{size:13,className:`spin`}):(0,L.jsx)(S,{size:13})})]})]}),(0,L.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,L.jsx)(`span`,{children:`Private note`}),(0,L.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>ee(e.target.value),disabled:_,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,L.jsx)(`div`,{className:`cal-modal-error`,children:E}),a&&(0,L.jsxs)(`div`,{className:`cal-modal-actions`,children:[!l&&!p&&!h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:_,children:[(0,L.jsx)(c,{size:14}),` Edit`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:_,children:[(0,L.jsx)(u,{size:14}),` Delete`]}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):Y(!1)},disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):(0,L.jsx)(o,{size:14}),` Download`]})]}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Yes`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:_,children:`No`}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:_,children:`Cancel`})]}),l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Save`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),D(null)},disabled:_,children:`Cancel`})]}),p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,L.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:J,disabled:_,children:[_?(0,L.jsx)(s,{size:14,className:`spin`}):null,` Delete`]}),(0,L.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:_,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,fe=[`day`,`week`,`month`,`year`];function pe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=N(`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 me(){let[e,t]=(0,T.useState)(null),[n,r]=(0,T.useState)(!1),[i,a]=(0,T.useState)(void 0),[o,s]=(0,T.useState)(null),[c,u]=(0,T.useState)(void 0),[f,m]=(0,T.useState)(null),[g,_]=(0,T.useState)(null);(0,T.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),m(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,T.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,T.useState)(!1),x=(0,T.useCallback)(async()=>{b(!0);try{let e=await p();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,L.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,L.jsx)(h,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:c,userAvatar:f,role:g,children:(0,L.jsx)(he,{cacheKey:e})})}):(0,L.jsx)(`div`,{className:`cal-page`,children:(0,L.jsxs)(`div`,{className:`cal-empty`,children:[(0,L.jsx)(`p`,{children:`You are not signed in.`}),(0,L.jsxs)(`p`,{children:[`Open the `,(0,L.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,L.jsx)(d,{surface:`gate`})}function he({cacheKey:e}){let{adminFetch:n,sessionRefetchNonce:r}=t({initialCacheKey:e,surface:`calendar`}),[i,a]=(0,T.useState)(`month`),[o,c]=(0,T.useState)(()=>new Date),[l,u]=(0,T.useState)([]),[f,p]=(0,T.useState)(!1),[h,v]=(0,T.useState)(!1),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(null),[C,w]=(0,T.useState)(null);(0,T.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&&w(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[n]),(0,T.useEffect)(()=>{let e=!1,{from:t,to:r}=N(i,o);return p(!0),b(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();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(b(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||(p(!1),v(!0))}),()=>{e=!0}},[i,o,r,n]);let E=(0,T.useCallback)(()=>c(new Date),[]),D=(0,T.useCallback)(()=>c(e=>P(i,e,-1)),[i]),O=(0,T.useCallback)(()=>c(e=>P(i,e,1)),[i]),k=(0,T.useCallback)(e=>{c(e),a(`month`)},[]);(0,T.useEffect)(()=>{S(null)},[i,o]);let A=(0,T.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),S(e)},[]),j=(0,T.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),S(null)},[]);return h?(0,L.jsxs)(`div`,{className:`cal-page`,children:[(0,L.jsxs)(`header`,{className:`cal-header`,children:[(0,L.jsxs)(`div`,{className:`cal-nav`,children:[(0,L.jsx)(`span`,{className:`cal-range-label`,children:pe(i,o)}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:D,"aria-label":`Previous`,children:(0,L.jsx)(g,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:O,"aria-label":`Next`,children:(0,L.jsx)(_,{size:18})}),(0,L.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:E,children:`Today`}),f&&(0,L.jsx)(s,{size:16,className:`spin`})]}),(0,L.jsx)(`div`,{className:`cal-views`,children:fe.map(e=>(0,L.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===i?` cal-view-btn-active`:``}`,onClick:()=>a(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),C&&(0,L.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${C}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,L.jsx)(m,{size:14}),` Booking page`]})]}),(0,L.jsxs)(`div`,{className:`cal-body`,children:[y&&(0,L.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,y]}),i===`day`&&(0,L.jsx)(Z,{anchor:o,meetings:l,onSelect:S}),i===`week`&&(0,L.jsx)(J,{anchor:o,meetings:l,onSelect:S}),i===`month`&&(0,L.jsx)(B,{anchor:o,meetings:l,onSelect:S}),i===`year`&&(0,L.jsx)(re,{anchor:o,meetings:l,onPickMonth:k})]}),x&&(0,L.jsx)(de,{meeting:x,adminFetch:n,onClose:()=>S(null),onSaved:A,onDeleted:j})]}):(0,L.jsx)(d,{surface:`gate`})}(0,w.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(me,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e,K as t}from"./useSubAccountSwitcher-HjQZjJBr.js";import"./useVoiceRecorder-CJecnefX.js";import"./AdminShell-Cbk0TL1B.js";import{n}from"./page-987y4JbQ.js";import"./useCopyFeedback-zjZZUC2-.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./useSubAccountSwitcher-HjQZjJBr.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./useSubAccountSwitcher-HjQZjJBr.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{L as e}from"./useSubAccountSwitcher-HjQZjJBr.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as e,K as t}from"./useSubAccountSwitcher-HjQZjJBr.js";import"./useVoiceRecorder-CJecnefX.js";import{t as n}from"./page-DWkUH4Z_.js";import"./graph-labels-Dlcb6cW7.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{file-download-sXU3_umF.js → file-download-C_fSe4dm.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{L as e}from"./useSubAccountSwitcher-HjQZjJBr.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);function n(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 r(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 i(e,t){let n=document.createElement(`a`);n.href=`/api/admin/routines/${encodeURIComponent(t)}/runs.csv?session_key=${encodeURIComponent(e)}`,n.rel=`noopener noreferrer`,document.body.appendChild(n),n.click(),n.remove()}function a(e,t,n=`data`){return`/api/admin/files/download?session_key=${encodeURIComponent(e)}&path=${encodeURIComponent(t)}&disposition=inline`+(n===`data`?``:`&root=${encodeURIComponent(n)}`)}export{t as a,r as i,n,i as r,a as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{L as e}from"./useSubAccountSwitcher-HjQZjJBr.js";var t=e(`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`}]]);export{t};
|
|
Binary file
|
|
Binary file
|