@rubytech/create-sitedesk-code 0.1.526 → 0.1.527
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +73 -7
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +7 -0
- package/payload/platform/plugins/docs/references/admin-ui.md +70 -4
- package/payload/platform/plugins/docs/references/internals.md +1 -1
- package/payload/platform/plugins/docs/references/platform.md +1 -1
- package/payload/platform/plugins/linkedin-extension/extension/README.md +10 -2
- package/payload/platform/plugins/linkedin-extension/extension/background/sw.js +37 -4
- package/payload/platform/plugins/linkedin-extension/extension/content/profile.js +17 -2
- package/payload/platform/plugins/linkedin-extension/extension/content/thread.js +17 -2
- package/payload/platform/plugins/linkedin-extension/extension/manifest.json +1 -0
- package/payload/platform/plugins/linkedin-extension/extension/options/options.html +1 -0
- package/payload/platform/plugins/linkedin-extension/extension/options/options.js +78 -3
- package/payload/server/{chunk-WT2PFGY4.js → chunk-KY3BBT67.js} +216 -1
- package/payload/server/maxy-edge.js +226 -6
- package/payload/server/public/activity.html +5 -5
- package/payload/server/public/agents.html +4 -4
- package/payload/server/public/assets/{AdminLoginScreens-BgDjueVe.js → AdminLoginScreens-DSt9DYZZ.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-DSt9DYZZ.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-DSt9DYZZ.js.gz +0 -0
- package/payload/server/public/assets/{AdminShell-YctTrR-D.js → AdminShell-MM3_yp3N.js} +1 -1
- package/payload/server/public/assets/AdminShell-MM3_yp3N.js.br +0 -0
- package/payload/server/public/assets/AdminShell-MM3_yp3N.js.gz +0 -0
- package/payload/server/public/assets/{activity-DGQt5ys_.js → activity-aVvbaVd4.js} +1 -1
- package/payload/server/public/assets/activity-aVvbaVd4.js.br +0 -0
- package/payload/server/public/assets/activity-aVvbaVd4.js.gz +0 -0
- package/payload/server/public/assets/{admin-DnUxbB3P.js → admin-B0lQnkH-.js} +1 -1
- package/payload/server/public/assets/admin-B0lQnkH-.js.br +0 -0
- package/payload/server/public/assets/admin-B0lQnkH-.js.gz +0 -0
- package/payload/server/public/assets/{agents-Bc2LZjwC.js → agents-CrpVTPRG.js} +1 -1
- package/payload/server/public/assets/agents-CrpVTPRG.js.br +0 -0
- package/payload/server/public/assets/agents-CrpVTPRG.js.gz +0 -0
- package/payload/server/public/assets/browser-CYHUzTop.js +1 -0
- package/payload/server/public/assets/browser-CYHUzTop.js.br +0 -0
- package/payload/server/public/assets/browser-CYHUzTop.js.gz +0 -0
- package/payload/server/public/assets/{calendar-D25EhXbD.js → calendar-4IWQpwYv.js} +1 -1
- package/payload/server/public/assets/calendar-4IWQpwYv.js.br +0 -0
- package/payload/server/public/assets/calendar-4IWQpwYv.js.gz +0 -0
- package/payload/server/public/assets/chat-DmjZTqnV.js +1 -0
- package/payload/server/public/assets/chat-DmjZTqnV.js.br +0 -0
- package/payload/server/public/assets/chat-DmjZTqnV.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-CIl-s3LZ.js +1 -0
- package/payload/server/public/assets/chevron-left-CIl-s3LZ.js.br +0 -0
- package/payload/server/public/assets/chevron-right-DpAi2BsF.js +1 -0
- package/payload/server/public/assets/chevron-right-DpAi2BsF.js.br +0 -0
- package/payload/server/public/assets/clock-CGuM9VRx.js +1 -0
- package/payload/server/public/assets/clock-CGuM9VRx.js.br +0 -0
- package/payload/server/public/assets/data-BpdFiZKH.js +1 -0
- package/payload/server/public/assets/data-BpdFiZKH.js.br +2 -0
- package/payload/server/public/assets/data-BpdFiZKH.js.gz +0 -0
- package/payload/server/public/assets/{file-download-CiGklOfA.js → file-download-DayBHhKS.js} +1 -1
- package/payload/server/public/assets/file-download-DayBHhKS.js.br +0 -0
- package/payload/server/public/assets/file-download-DayBHhKS.js.gz +0 -0
- package/payload/server/public/assets/{file-text-XjJPULAZ.js → file-text-BSyhVH0m.js} +1 -1
- package/payload/server/public/assets/file-text-BSyhVH0m.js.br +0 -0
- package/payload/server/public/assets/file-text-BSyhVH0m.js.gz +0 -0
- package/payload/server/public/assets/{graph-BjHJ0z_6.js → graph-Bjv3Tc3B.js} +1 -1
- package/payload/server/public/assets/graph-Bjv3Tc3B.js.br +0 -0
- package/payload/server/public/assets/graph-Bjv3Tc3B.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-D-0u37KA.js → graph-labels-DegLKGdx.js} +1 -1
- package/payload/server/public/assets/graph-labels-DegLKGdx.js.br +0 -0
- package/payload/server/public/assets/graph-labels-DegLKGdx.js.gz +0 -0
- package/payload/server/public/assets/{maximize-2-BJ9S-nfS.js → maximize-2-DJFG2EXJ.js} +1 -1
- package/payload/server/public/assets/maximize-2-DJFG2EXJ.js.br +0 -0
- package/payload/server/public/assets/maximize-2-DJFG2EXJ.js.gz +0 -0
- package/payload/server/public/assets/{operator-Cay4rOOK.js → operator-Du9Ve_PR.js} +1 -1
- package/payload/server/public/assets/operator-Du9Ve_PR.js.br +0 -0
- package/payload/server/public/assets/operator-Du9Ve_PR.js.gz +0 -0
- package/payload/server/public/assets/{page-shuh4ES9.js → page-DgHYxG3M.js} +1 -1
- package/payload/server/public/assets/page-DgHYxG3M.js.br +0 -0
- package/payload/server/public/assets/page-DgHYxG3M.js.gz +0 -0
- package/payload/server/public/assets/{page-Cci_j_y7.js → page-qV1ypb6i.js} +5 -5
- package/payload/server/public/assets/page-qV1ypb6i.js.br +0 -0
- package/payload/server/public/assets/page-qV1ypb6i.js.gz +0 -0
- package/payload/server/public/assets/{public-BbJcQGsO.js → public-CNVEM-Bx.js} +1 -1
- package/payload/server/public/assets/public-CNVEM-Bx.js.br +0 -0
- package/payload/server/public/assets/public-CNVEM-Bx.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-jeSVwUAv.js → rotate-ccw-DQCaky8_.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-DQCaky8_.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-DQCaky8_.js.gz +0 -0
- package/payload/server/public/assets/{routines-D3M1Wh3a.js → routines-DwK5FeLm.js} +1 -1
- package/payload/server/public/assets/routines-DwK5FeLm.js.br +0 -0
- package/payload/server/public/assets/routines-DwK5FeLm.js.gz +0 -0
- package/payload/server/public/assets/{skills-Bhej2ub1.js → skills-CosN3uA4.js} +1 -1
- package/payload/server/public/assets/skills-CosN3uA4.js.br +0 -0
- package/payload/server/public/assets/skills-CosN3uA4.js.gz +0 -0
- package/payload/server/public/assets/tasks-f0QikHmw.js +3 -0
- package/payload/server/public/assets/tasks-f0QikHmw.js.br +0 -0
- package/payload/server/public/assets/tasks-f0QikHmw.js.gz +0 -0
- package/payload/server/public/assets/{time-entry-format-r5UY9rjG.js → time-entry-format-DLTdS35_.js} +1 -1
- package/payload/server/public/assets/time-entry-format-DLTdS35_.js.br +0 -0
- package/payload/server/public/assets/time-entry-format-DLTdS35_.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert--PCKaewD.js → triangle-alert-CpwrbdYq.js} +1 -1
- package/payload/server/public/assets/triangle-alert-CpwrbdYq.js.br +3 -0
- package/payload/server/public/assets/triangle-alert-CpwrbdYq.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-Dg5lNgqH.js → useCopyFeedback-D01gSp36.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-D01gSp36.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-D01gSp36.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CJzJ9xV3.css +1 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CJzJ9xV3.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-CJzJ9xV3.css.gz +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-BY6ZsGMH.js → useVoiceRecorder-DiPgyDUy.js} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-DiPgyDUy.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-DiPgyDUy.js.gz +0 -0
- package/payload/server/public/assets/{wrench-Bw1FMolk.js → wrench-C5SJreEu.js} +1 -1
- package/payload/server/public/assets/wrench-C5SJreEu.js.br +1 -0
- package/payload/server/public/assets/wrench-C5SJreEu.js.gz +0 -0
- package/payload/server/public/brand-defaults.css +1 -1
- package/payload/server/public/browser.html +4 -4
- 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 +15 -15
- package/payload/server/public/operator.html +14 -14
- 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 +43 -5
- package/payload/server/public/assets/AdminLoginScreens-BgDjueVe.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-BgDjueVe.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-YctTrR-D.js.br +0 -0
- package/payload/server/public/assets/AdminShell-YctTrR-D.js.gz +0 -0
- package/payload/server/public/assets/activity-DGQt5ys_.js.br +0 -0
- package/payload/server/public/assets/activity-DGQt5ys_.js.gz +0 -0
- package/payload/server/public/assets/admin-DnUxbB3P.js.br +0 -0
- package/payload/server/public/assets/admin-DnUxbB3P.js.gz +0 -0
- package/payload/server/public/assets/agents-Bc2LZjwC.js.br +0 -0
- package/payload/server/public/assets/agents-Bc2LZjwC.js.gz +0 -0
- package/payload/server/public/assets/browser-BtF7SzvG.js +0 -1
- package/payload/server/public/assets/browser-BtF7SzvG.js.br +0 -0
- package/payload/server/public/assets/browser-BtF7SzvG.js.gz +0 -0
- package/payload/server/public/assets/calendar-D25EhXbD.js.br +0 -0
- package/payload/server/public/assets/calendar-D25EhXbD.js.gz +0 -0
- package/payload/server/public/assets/chat-z4jsHFXg.js +0 -1
- package/payload/server/public/assets/chat-z4jsHFXg.js.br +0 -0
- package/payload/server/public/assets/chat-z4jsHFXg.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-BD09SN6R.js +0 -1
- package/payload/server/public/assets/chevron-right-ChmWeo7T.js +0 -1
- package/payload/server/public/assets/chevron-right-ChmWeo7T.js.br +0 -0
- package/payload/server/public/assets/clock-Yqf7Ke7I.js +0 -1
- package/payload/server/public/assets/clock-Yqf7Ke7I.js.br +0 -0
- package/payload/server/public/assets/clock-Yqf7Ke7I.js.gz +0 -0
- package/payload/server/public/assets/data-RmnKj5nC.js +0 -1
- package/payload/server/public/assets/data-RmnKj5nC.js.br +0 -2
- package/payload/server/public/assets/data-RmnKj5nC.js.gz +0 -0
- package/payload/server/public/assets/file-download-CiGklOfA.js.br +0 -0
- package/payload/server/public/assets/file-download-CiGklOfA.js.gz +0 -0
- package/payload/server/public/assets/file-text-XjJPULAZ.js.br +0 -0
- package/payload/server/public/assets/file-text-XjJPULAZ.js.gz +0 -0
- package/payload/server/public/assets/graph-BjHJ0z_6.js.br +0 -0
- package/payload/server/public/assets/graph-BjHJ0z_6.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-D-0u37KA.js.br +0 -0
- package/payload/server/public/assets/graph-labels-D-0u37KA.js.gz +0 -0
- package/payload/server/public/assets/maximize-2-BJ9S-nfS.js.br +0 -0
- package/payload/server/public/assets/maximize-2-BJ9S-nfS.js.gz +0 -0
- package/payload/server/public/assets/operator-Cay4rOOK.js.br +0 -0
- package/payload/server/public/assets/operator-Cay4rOOK.js.gz +0 -0
- package/payload/server/public/assets/page-Cci_j_y7.js.br +0 -0
- package/payload/server/public/assets/page-Cci_j_y7.js.gz +0 -0
- package/payload/server/public/assets/page-shuh4ES9.js.br +0 -0
- package/payload/server/public/assets/page-shuh4ES9.js.gz +0 -0
- package/payload/server/public/assets/public-BbJcQGsO.js.br +0 -0
- package/payload/server/public/assets/public-BbJcQGsO.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-jeSVwUAv.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-jeSVwUAv.js.gz +0 -0
- package/payload/server/public/assets/routines-D3M1Wh3a.js.br +0 -0
- package/payload/server/public/assets/routines-D3M1Wh3a.js.gz +0 -0
- package/payload/server/public/assets/skills-Bhej2ub1.js.br +0 -0
- package/payload/server/public/assets/skills-Bhej2ub1.js.gz +0 -0
- package/payload/server/public/assets/tasks-qY-dtOI2.js +0 -1
- package/payload/server/public/assets/tasks-qY-dtOI2.js.br +0 -0
- package/payload/server/public/assets/tasks-qY-dtOI2.js.gz +0 -0
- package/payload/server/public/assets/time-entry-format-r5UY9rjG.js.br +0 -0
- package/payload/server/public/assets/time-entry-format-r5UY9rjG.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert--PCKaewD.js.br +0 -2
- package/payload/server/public/assets/triangle-alert--PCKaewD.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-Dg5lNgqH.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-Dg5lNgqH.js.gz +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-BYfe9vj8.css +0 -1
- package/payload/server/public/assets/useSubAccountSwitcher-BYfe9vj8.css.br +0 -0
- package/payload/server/public/assets/useSubAccountSwitcher-BYfe9vj8.css.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-BY6ZsGMH.js.br +0 -0
- package/payload/server/public/assets/useVoiceRecorder-BY6ZsGMH.js.gz +0 -0
- package/payload/server/public/assets/wrench-Bw1FMolk.js.br +0 -0
- package/payload/server/public/assets/wrench-Bw1FMolk.js.gz +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-CnpeWIYq.js → useSubAccountSwitcher-BRHYXwGO.js} +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-CnpeWIYq.js.br → useSubAccountSwitcher-BRHYXwGO.js.br} +0 -0
- /package/payload/server/public/assets/{useSubAccountSwitcher-CnpeWIYq.js.gz → useSubAccountSwitcher-BRHYXwGO.js.gz} +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{H as t,J as n,K as r}from"./useSubAccountSwitcher-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{H as t,J as n,K as r}from"./useSubAccountSwitcher-BRHYXwGO.js";import"./useVoiceRecorder-DiPgyDUy.js";import{w as i}from"./AdminShell-MM3_yp3N.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-qV1ypb6i.js";import"./useCopyFeedback-D01gSp36.js";var d=r(),f=e(n(),1),p=t();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{I as e}from"./useSubAccountSwitcher-BRHYXwGO.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{D as t,G as n,H as r,I as i,J as a,K as o,L as s,f as c,h as l,j as u,u as d,v as f,w as p,y as m}from"./useSubAccountSwitcher-CnpeWIYq.js";import{E as h,f as g,t as _}from"./AdminShell-YctTrR-D.js";import{a as v,r as y}from"./file-download-CiGklOfA.js";import{t as b}from"./clock-Yqf7Ke7I.js";import{t as x}from"./wrench-Bw1FMolk.js";var S=i(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),C=i(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),w=i(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=o(),E=e(a(),1);function D(e){return/^\d+$/.test(e)?Number(e):null}function O(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t,s=D(n),c=D(r);if(s===null||c===null||s>59||c>23||a!==`*`)return null;if(i===`*`&&o===`*`)return{frequency:`daily`,minute:s,hour:c,weekdays:[],dayOfMonth:1};if(i===`*`&&o!==`*`){let e=o.split(`,`).map(D);return e.some(e=>e===null||e>6)?null:{frequency:`weekly`,minute:s,hour:c,weekdays:e,dayOfMonth:1}}if(o===`*`&&i!==`*`){let e=D(i);return e===null||e<1||e>31?null:{frequency:`monthly`,minute:s,hour:c,weekdays:[],dayOfMonth:e}}return null}function k(e){let t=String(e.minute),n=String(e.hour);return e.frequency===`daily`?`${t} ${n} * * *`:e.frequency===`weekly`?`${t} ${n} * * ${e.weekdays.length?[...e.weekdays].sort((e,t)=>e-t).join(`,`):`*`}`:`${t} ${n} ${e.dayOfMonth} * *`}var A=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function j(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function M(e){return String(e).padStart(2,`0`)}function N(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${A[e%7]} to ${A[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>A[Number(e)%7]).join(`, `):`invalid`}function P(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return e;let s=j(n,59),c=j(r,23);if(!s||!c)return e;let l=N(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${M(c.value)}:00 to ${M(c.value)}:59${u}`:`${e}, ${M(c.rangeStart)}:00 to ${M(d(c))}:00${u}`}if(c.kind===`step`){let e=M(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${M(c.rangeStart)}:${e} to ${M(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${M(c.rangeStart)}:${e} to ${M(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${M(s.value)}`}${u}`;let f=`${M(c.value)}:${M(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var F=r(),I=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function L(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`}var R={frequency:`daily`,minute:0,hour:9,weekdays:[1],dayOfMonth:1};function ee({recurrence:e,onChange:t,disabled:n}){let r=e?O(e):R,[i,a]=(0,E.useState)(r??R),[o]=(0,E.useState)(e!=null&&r==null),[s,c]=(0,E.useState)(e??``);if(o)return(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Schedule (advanced)`}),(0,F.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,F.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(k(e))},u=e=>{let t=e===`weekly`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,frequency:e,weekdays:t})},d=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},f=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},p=e=>l({...i,dayOfMonth:Number(e)||1});return(0,F.jsxs)(`div`,{className:`routine-sched`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Frequency`}),(0,F.jsxs)(`select`,{value:i.frequency,disabled:n,onChange:e=>u(e.target.value),children:[(0,F.jsx)(`option`,{value:`daily`,children:`Daily`}),(0,F.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,F.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Time of day`}),(0,F.jsx)(`input`,{type:`time`,value:L(i),disabled:n,onChange:e=>d(e.target.value)})]}),i.frequency===`weekly`&&(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Days`}),(0,F.jsx)(`div`,{className:`routine-weekdays`,children:I.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>f(e.value),children:e.label},e.value))})]}),i.frequency===`monthly`&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Day of month`}),(0,F.jsx)(`select`,{value:i.dayOfMonth,disabled:n,onChange:e=>p(e.target.value),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]})]})}var z={scheduled:`live`,due:`live`,suspended:`stood-down`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}function V({eventStatus:e}){let t=B(e);return(0,F.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function H(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function U({routine:e,adminFetch:n,onClose:r,onSaved:i,onDeleted:a,onViewRuns:o}){let[s,l]=(0,E.useState)(!1),[u,h]=(0,E.useState)(!1),[_,v]=(0,E.useState)(null),[y,T]=(0,E.useState)(e),[D,O]=(0,E.useState)(!1),k=y.agentChannel!=null,A=y.eventStatus===`suspended`,[j,M]=(0,E.useState)(!1),[N,I]=(0,E.useState)(e.agentPrompt??``),[L,R]=(0,E.useState)(e.recurrence),[z,B]=(0,E.useState)(e.agentChannel??``),[U,W]=(0,E.useState)(e.agentDestination??``),[G,K]=(0,E.useState)(null),[q,J]=(0,E.useState)(null),Y=k||y.actionPlugin==null;(0,E.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!u&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,r]),(0,E.useEffect)(()=>{if(!s||!Y||G!==null)return;let e=!1;return n(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||K(t.destinations)}).catch(t=>{e||(K([]),J(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[s,Y,G,n]);let X=(G??[]).filter(e=>e.channel===z),Z=z.length>0&&U.length>0,te=z.length>0&&U.length===0||Z&&N.trim().length===0,Q=(0,E.useCallback)(()=>{let e={},t=z.length>0&&U.length>0;return(k||t)&&N!==(y.agentPrompt??``)&&(e.agentPrompt=N),L!=null&&L!==(y.recurrence??null)&&(e.recurrence=L),t&&(z!==(y.agentChannel??``)||U!==(y.agentDestination??``))?(e.agentChannel=z,e.agentDestination=U):!t&&z===``&&(y.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[k,N,L,z,U,y]),$=(0,E.useCallback)(async()=>{let t=Q();if(Object.keys(t).length===0){l(!1);return}h(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let a=await r.json();T(a.routine),I(a.routine.agentPrompt??``),R(a.routine.recurrence),B(a.routine.agentChannel??``),W(a.routine.agentDestination??``),i(a.routine),l(!1)}catch(e){v(e instanceof Error?e.message:`Save failed`)}finally{h(!1)}},[n,Q,e.eventId,i]),ne=(0,E.useCallback)(async()=>{if(u)return;if(!j){O(!1),M(!0);return}let t=A?`resume`:`suspend`;h(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${t}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let a=await r.json();T(a.routine),i(a.routine),M(!1)}catch(e){v(e instanceof Error?e.message:`${t} failed`),M(!1)}finally{h(!1)}},[n,u,j,A,e.eventId,i]),re=(0,E.useCallback)(async()=>{if(!u){if(!D){M(!1),O(!0);return}h(!0),v(null);try{let t=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e.eventId)}catch(e){v(e instanceof Error?e.message:`Delete failed`),O(!1)}finally{h(!1)}}},[n,u,D,e.eventId,a]);return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{u||r()},children:(0,F.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":s?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,F.jsx)(g,{size:13}),` Routine`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:u,children:(0,F.jsx)(f,{size:16})})]}),!s&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:y.name??`Untitled routine`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:y.recurrence?P(y.recurrence):`One-time`})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(V,{eventStatus:y.eventStatus}),(0,F.jsxs)(`span`,{children:[`Status: `,y.eventStatus??`unknown`]})]}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Next run: `,H(y.nextRun)]})}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(w,{size:14}),(0,F.jsxs)(`span`,{children:[`Last run: `,H(y.lastTriggered),y.lastDispatchResult?` (${y.lastDispatchResult})`:``]})]}),k?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(c,{channel:y.agentChannel,size:14}),(0,F.jsxs)(`span`,{children:[d[y.agentChannel]??y.agentChannel,` to `,y.agentDestination??`—`]})]}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,F.jsx)(`span`,{children:y.agentPrompt??`No instruction set.`})})]}):y.actionPlugin?(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsxs)(`span`,{children:[y.actionPlugin,`.`,y.actionTool,y.actionArgs?` ${y.actionArgs}`:``]})]}):(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]})]}),s&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[Y&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Send to`}),(0,F.jsxs)(`select`,{value:z,disabled:u,onChange:e=>{B(e.target.value),W(``)},children:[(0,F.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,F.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,F.jsx)(`option`,{value:`telegram`,children:`Telegram`})]})]}),z!==``&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Destination`}),(0,F.jsxs)(`select`,{value:U,disabled:u||G===null,onChange:e=>W(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:G===null?`Loading destinations`:X.length===0?`No registered destinations`:`Choose a destination`}),U!==``&&!X.some(e=>e.destination===U)&&(0,F.jsxs)(`option`,{value:U,children:[U,` (not in the current list)`]}),X.map(e=>(0,F.jsxs)(`option`,{value:e.destination,children:[e.label,` · `,e.destination]},e.destination))]})]}),q&&(0,F.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,q]})]}),(k||Z)&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Instruction`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:N,onChange:e=>I(e.target.value),disabled:u,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,F.jsx)(ee,{recurrence:y.recurrence,onChange:R,disabled:u})]}),_&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:_}),(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!s&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{O(!1),M(!1),l(!0)},disabled:u,children:[(0,F.jsx)(p,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>o(y),disabled:u,children:[(0,F.jsx)(w,{size:14}),` Runs`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:ne,disabled:u,children:[u&&j?(0,F.jsx)(t,{size:14,className:`spin`}):A?(0,F.jsx)(C,{size:14}):(0,F.jsx)(S,{size:14}),j?A?`Confirm resume`:`Confirm suspend`:A?`Resume`:`Suspend`]}),j&&(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:A?`This routine will run at its next scheduled time. It will not run for the times it missed.`:`This routine stops running until you resume it. Nothing is deleted.`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:re,disabled:u,children:[u&&D?(0,F.jsx)(t,{size:14,className:`spin`}):(0,F.jsx)(m,{size:14}),D?`Confirm delete`:`Delete`]})]}),s&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:$,disabled:u||te,children:[u?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{l(!1),v(null)},disabled:u,children:`Cancel`})]})]})]})})}function W(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function G(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function K({run:e,routineName:t,onClose:n}){return(0,E.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,F.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,F.jsx)(w,{size:13}),` Run`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,F.jsx)(f,{size:16})})]}),(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),(0,F.jsx)(`div`,{className:`cal-modal-row`,children:(0,F.jsx)(`span`,{children:e.status})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Due: `,W(e.scheduledFor)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Started: `,W(e.startedAt)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Dispatch ended: `,W(e.endedAt),` (`,G(e.ranMs),`)`]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Output seen: `,W(e.finishedAt)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,F.jsx)(`span`,{children:e.error})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsx)(`span`,{children:`This run shares its conversation with other traffic, so what it produced cannot be separated out. Its status stays at whatever the dispatch reported.`})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}var q=500;function J(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Y(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var X={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function Z(e){if(e===`no-dispatch-configured`)return`This routine has no dispatch set up, so there was nothing to do.`;if(e===`no-action-plugin`)return`The tool action names no plugin, so nothing ran.`;if(e===`no-action-tool`)return`The tool action names no tool, so nothing ran.`;let t=e.startsWith(`no-`)?e.slice(3).split(`+`):[];if(t.length>0&&t.every(e=>e in X)){let e=t.map(e=>X[e]);return`This routine has no ${(e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`).replace(/^an? /,``)} set, so nothing was sent.`}return e}function te(e){return e.status===`no-destination`?e.error?Z(e.error):`Nothing was dispatched, and no reason was recorded.`:e.status===`failed`?e.error??e.dispatchResult??`The dispatch failed.`:e.status===`open`?`Opened and never closed. The dispatch did not report back.`:null}function Q({routine:e,adminFetch:n,cacheKey:r,onBack:i}){let[a,o]=(0,E.useState)([]),[s,c]=(0,E.useState)(!0),[l,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null);(0,E.useEffect)(()=>{let t=!1;return c(!0),d(null),n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${q}`).then(async e=>{if(t)return;if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();o(Array.isArray(n.runs)?n.runs:[])}).catch(e=>{t||(d(e instanceof Error?e.message:`Failed to load`),o([]))}).finally(()=>{t||c(!1)}),()=>{t=!0}},[n,e.eventId]);let m=(0,E.useCallback)(()=>{y(r,e.eventId)},[r,e.eventId]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsx)(`header`,{className:`cal-header`,children:(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,children:[(0,F.jsx)(v,{size:14}),` Routines`]}),(0,F.jsxs)(`span`,{className:`cal-range-label`,children:[(0,F.jsx)(w,{size:16}),` `,e.name??`Untitled routine`]}),s&&(0,F.jsx)(t,{size:16,className:`spin`}),a.length>0&&(0,F.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:m,children:[(0,F.jsx)(u,{size:14}),` Download all runs`]})})]})}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[l&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,l]}),!l&&!s&&a.length===0&&(0,F.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,F.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,F.jsx)(`p`,{children:`That means one of three things, and this page cannot tell them apart: it has never run, it ran but no record was written, or every run it did have is older than the 30 days records are kept for.`}),(0,F.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,F.jsx)(`code`,{children:` fires-without-records `}),` count above zero names a routine that fired and left no record. It does not distinguish the other two, and it does not cover a one-time routine.`]})]}),a.length>=q&&(0,F.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,q,` runs. There may be more; the download has everything still on record.`]}),(0,F.jsx)(`div`,{className:`routine-list`,children:a.map(e=>{let t=te(e);return(0,F.jsxs)(`button`,{type:`button`,className:`routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>p(e),children:[(0,F.jsx)(`span`,{className:`routine-card-title`,children:e.status}),(0,F.jsx)(`span`,{className:`routine-card-sched`,children:Y(e.ranMs)}),(0,F.jsx)(`span`,{className:`routine-card-target`,children:e.target}),(0,F.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,J(e.scheduledFor)]}),t&&(0,F.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),f&&(0,F.jsx)(K,{run:f,routineName:e.name,onClose:()=>p(null)})]})}var $=`maxy-admin-session-key`;function ne(e){return e?P(e):`One-time`}function re(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ie(){let[e,t]=(0,E.useState)(null),[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(void 0),[o,c]=(0,E.useState)(null),[u,d]=(0,E.useState)(void 0),[f,p]=(0,E.useState)(null),[m,g]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),g(e.role??null),d(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,E.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,E.useState)(!1),x=(0,E.useCallback)(async()=>{b(!0);try{let e=await h();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(l,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(_,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:u,userAvatar:f,role:m,children:(0,F.jsx)(ae,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(s,{surface:`gate`})}function ae({cacheKey:e}){let{adminFetch:r,cacheKey:i,sessionRefetchNonce:a}=n({initialCacheKey:e,surface:`routines`}),[o,l]=(0,E.useState)([]),[u,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),[h,_]=(0,E.useState)(null),[v,y]=(0,E.useState)(null),[w,T]=(0,E.useState)(null),D=(0,E.useCallback)(()=>{let e=!1;return f(!0),_(null),r(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();l(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(_(t instanceof Error?t.message:`Failed to load`),l([]))}).finally(()=>{e||(f(!1),m(!0))}),()=>{e=!0}},[r]);(0,E.useEffect)(()=>D(),[D,a]);let O=(0,E.useCallback)(e=>{l(t=>t.map(t=>t.eventId===e.eventId?e:t)),y(e)},[]),k=(0,E.useCallback)(e=>{l(t=>t.filter(t=>t.eventId!==e)),y(null)},[]),[A,j]=(0,E.useState)(!1),[M,N]=(0,E.useState)(null),P=o.filter(e=>e.eventStatus===`scheduled`).length,I=o.filter(e=>e.suspendedInBulk).length,L=(0,E.useCallback)(async e=>{j(!0),N(null);try{let t=await r(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let n=await t.json(),i=n.refused?.length??0;N(e===`suspend-all`?`Suspended ${n.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${n.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),D()}catch(e){N(e instanceof Error?e.message:`Failed`)}finally{j(!1)}},[r,D]);return p?w?(0,F.jsx)(Q,{routine:w,adminFetch:r,cacheKey:i,onBack:()=>T(null)}):(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsx)(`header`,{className:`cal-header`,children:(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsxs)(`span`,{className:`cal-range-label`,children:[(0,F.jsx)(g,{size:16}),` Routines`]}),u&&(0,F.jsx)(t,{size:16,className:`spin`}),(0,F.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>L(`suspend-all`),disabled:A||P===0,children:[(0,F.jsx)(S,{size:14}),` Suspend all (`,P,`)`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>L(`resume-all`),disabled:A||I===0,children:[(0,F.jsx)(C,{size:14}),` Resume all (`,I,`)`]})]})]})}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[M&&(0,F.jsx)(`div`,{className:`cal-modal-confirm-text`,children:M}),h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,h]}),!h&&!u&&o.length===0&&(0,F.jsx)(`div`,{className:`cal-empty`,children:(0,F.jsx)(`p`,{children:`No routines yet.`})}),(0,F.jsx)(`div`,{className:`routine-list`,children:o.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>y(e),children:[(0,F.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.name??`Untitled routine`}),(0,F.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,F.jsx)(b,{size:13}),` `,ne(e.recurrence)]}),(0,F.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(c,{channel:e.agentChannel,size:13}),` `,d[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(x,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(b,{size:13}),` Scheduled trigger`]})}),(0,F.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,F.jsx)(V,{eventStatus:e.eventStatus}),`Next: `,re(e.nextRun),` · `,e.eventStatus??`unknown`]})]},e.eventId))})]}),v&&(0,F.jsx)(U,{routine:v,adminFetch:r,onClose:()=>y(null),onSaved:O,onDeleted:k,onViewRuns:e=>{y(null),T(e)}})]}):(0,F.jsx)(s,{surface:`gate`})}(0,T.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(ie,{}));
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{D as t,G as n,H as r,I as i,J as a,K as o,L as s,f as c,h as l,j as u,u as d,v as f,w as p,y as m}from"./useSubAccountSwitcher-BRHYXwGO.js";import{E as h,f as g,t as _}from"./AdminShell-MM3_yp3N.js";import{a as v,r as y}from"./file-download-DayBHhKS.js";import{t as b}from"./clock-CGuM9VRx.js";import{t as x}from"./wrench-C5SJreEu.js";var S=i(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),C=i(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),w=i(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=o(),E=e(a(),1);function D(e){return/^\d+$/.test(e)?Number(e):null}function O(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t,s=D(n),c=D(r);if(s===null||c===null||s>59||c>23||a!==`*`)return null;if(i===`*`&&o===`*`)return{frequency:`daily`,minute:s,hour:c,weekdays:[],dayOfMonth:1};if(i===`*`&&o!==`*`){let e=o.split(`,`).map(D);return e.some(e=>e===null||e>6)?null:{frequency:`weekly`,minute:s,hour:c,weekdays:e,dayOfMonth:1}}if(o===`*`&&i!==`*`){let e=D(i);return e===null||e<1||e>31?null:{frequency:`monthly`,minute:s,hour:c,weekdays:[],dayOfMonth:e}}return null}function k(e){let t=String(e.minute),n=String(e.hour);return e.frequency===`daily`?`${t} ${n} * * *`:e.frequency===`weekly`?`${t} ${n} * * ${e.weekdays.length?[...e.weekdays].sort((e,t)=>e-t).join(`,`):`*`}`:`${t} ${n} ${e.dayOfMonth} * *`}var A=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function j(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function M(e){return String(e).padStart(2,`0`)}function N(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${A[e%7]} to ${A[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>A[Number(e)%7]).join(`, `):`invalid`}function P(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return e;let s=j(n,59),c=j(r,23);if(!s||!c)return e;let l=N(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${M(c.value)}:00 to ${M(c.value)}:59${u}`:`${e}, ${M(c.rangeStart)}:00 to ${M(d(c))}:00${u}`}if(c.kind===`step`){let e=M(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${M(c.rangeStart)}:${e} to ${M(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${M(c.rangeStart)}:${e} to ${M(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${M(s.value)}`}${u}`;let f=`${M(c.value)}:${M(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var F=r(),I=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function L(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`}var R={frequency:`daily`,minute:0,hour:9,weekdays:[1],dayOfMonth:1};function ee({recurrence:e,onChange:t,disabled:n}){let r=e?O(e):R,[i,a]=(0,E.useState)(r??R),[o]=(0,E.useState)(e!=null&&r==null),[s,c]=(0,E.useState)(e??``);if(o)return(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Schedule (advanced)`}),(0,F.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,F.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(k(e))},u=e=>{let t=e===`weekly`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,frequency:e,weekdays:t})},d=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},f=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},p=e=>l({...i,dayOfMonth:Number(e)||1});return(0,F.jsxs)(`div`,{className:`routine-sched`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Frequency`}),(0,F.jsxs)(`select`,{value:i.frequency,disabled:n,onChange:e=>u(e.target.value),children:[(0,F.jsx)(`option`,{value:`daily`,children:`Daily`}),(0,F.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,F.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Time of day`}),(0,F.jsx)(`input`,{type:`time`,value:L(i),disabled:n,onChange:e=>d(e.target.value)})]}),i.frequency===`weekly`&&(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Days`}),(0,F.jsx)(`div`,{className:`routine-weekdays`,children:I.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>f(e.value),children:e.label},e.value))})]}),i.frequency===`monthly`&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Day of month`}),(0,F.jsx)(`select`,{value:i.dayOfMonth,disabled:n,onChange:e=>p(e.target.value),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]})]})}var z={scheduled:`live`,due:`live`,suspended:`stood-down`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}function V({eventStatus:e}){let t=B(e);return(0,F.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function H(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function U({routine:e,adminFetch:n,onClose:r,onSaved:i,onDeleted:a,onViewRuns:o}){let[s,l]=(0,E.useState)(!1),[u,h]=(0,E.useState)(!1),[_,v]=(0,E.useState)(null),[y,T]=(0,E.useState)(e),[D,O]=(0,E.useState)(!1),k=y.agentChannel!=null,A=y.eventStatus===`suspended`,[j,M]=(0,E.useState)(!1),[N,I]=(0,E.useState)(e.agentPrompt??``),[L,R]=(0,E.useState)(e.recurrence),[z,B]=(0,E.useState)(e.agentChannel??``),[U,W]=(0,E.useState)(e.agentDestination??``),[G,K]=(0,E.useState)(null),[q,J]=(0,E.useState)(null),Y=k||y.actionPlugin==null;(0,E.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!u&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,r]),(0,E.useEffect)(()=>{if(!s||!Y||G!==null)return;let e=!1;return n(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||K(t.destinations)}).catch(t=>{e||(K([]),J(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[s,Y,G,n]);let X=(G??[]).filter(e=>e.channel===z),Z=z.length>0&&U.length>0,te=z.length>0&&U.length===0||Z&&N.trim().length===0,Q=(0,E.useCallback)(()=>{let e={},t=z.length>0&&U.length>0;return(k||t)&&N!==(y.agentPrompt??``)&&(e.agentPrompt=N),L!=null&&L!==(y.recurrence??null)&&(e.recurrence=L),t&&(z!==(y.agentChannel??``)||U!==(y.agentDestination??``))?(e.agentChannel=z,e.agentDestination=U):!t&&z===``&&(y.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[k,N,L,z,U,y]),$=(0,E.useCallback)(async()=>{let t=Q();if(Object.keys(t).length===0){l(!1);return}h(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let a=await r.json();T(a.routine),I(a.routine.agentPrompt??``),R(a.routine.recurrence),B(a.routine.agentChannel??``),W(a.routine.agentDestination??``),i(a.routine),l(!1)}catch(e){v(e instanceof Error?e.message:`Save failed`)}finally{h(!1)}},[n,Q,e.eventId,i]),ne=(0,E.useCallback)(async()=>{if(u)return;if(!j){O(!1),M(!0);return}let t=A?`resume`:`suspend`;h(!0),v(null);try{let r=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${t}`,{method:`POST`});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`HTTP ${r.status}`)}let a=await r.json();T(a.routine),i(a.routine),M(!1)}catch(e){v(e instanceof Error?e.message:`${t} failed`),M(!1)}finally{h(!1)}},[n,u,j,A,e.eventId,i]),re=(0,E.useCallback)(async()=>{if(!u){if(!D){M(!1),O(!0);return}h(!0),v(null);try{let t=await n(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e.eventId)}catch(e){v(e instanceof Error?e.message:`Delete failed`),O(!1)}finally{h(!1)}}},[n,u,D,e.eventId,a]);return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{u||r()},children:(0,F.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":s?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,F.jsx)(g,{size:13}),` Routine`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:u,children:(0,F.jsx)(f,{size:16})})]}),!s&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:y.name??`Untitled routine`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:y.recurrence?P(y.recurrence):`One-time`})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(V,{eventStatus:y.eventStatus}),(0,F.jsxs)(`span`,{children:[`Status: `,y.eventStatus??`unknown`]})]}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Next run: `,H(y.nextRun)]})}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(w,{size:14}),(0,F.jsxs)(`span`,{children:[`Last run: `,H(y.lastTriggered),y.lastDispatchResult?` (${y.lastDispatchResult})`:``]})]}),k?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(c,{channel:y.agentChannel,size:14}),(0,F.jsxs)(`span`,{children:[d[y.agentChannel]??y.agentChannel,` to `,y.agentDestination??`—`]})]}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,F.jsx)(`span`,{children:y.agentPrompt??`No instruction set.`})})]}):y.actionPlugin?(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsxs)(`span`,{children:[y.actionPlugin,`.`,y.actionTool,y.actionArgs?` ${y.actionArgs}`:``]})]}):(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]})]}),s&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[Y&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Send to`}),(0,F.jsxs)(`select`,{value:z,disabled:u,onChange:e=>{B(e.target.value),W(``)},children:[(0,F.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,F.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,F.jsx)(`option`,{value:`telegram`,children:`Telegram`})]})]}),z!==``&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Destination`}),(0,F.jsxs)(`select`,{value:U,disabled:u||G===null,onChange:e=>W(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:G===null?`Loading destinations`:X.length===0?`No registered destinations`:`Choose a destination`}),U!==``&&!X.some(e=>e.destination===U)&&(0,F.jsxs)(`option`,{value:U,children:[U,` (not in the current list)`]}),X.map(e=>(0,F.jsxs)(`option`,{value:e.destination,children:[e.label,` · `,e.destination]},e.destination))]})]}),q&&(0,F.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,q]})]}),(k||Z)&&(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Instruction`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:N,onChange:e=>I(e.target.value),disabled:u,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,F.jsx)(ee,{recurrence:y.recurrence,onChange:R,disabled:u})]}),_&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:_}),(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!s&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{O(!1),M(!1),l(!0)},disabled:u,children:[(0,F.jsx)(p,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>o(y),disabled:u,children:[(0,F.jsx)(w,{size:14}),` Runs`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:ne,disabled:u,children:[u&&j?(0,F.jsx)(t,{size:14,className:`spin`}):A?(0,F.jsx)(C,{size:14}):(0,F.jsx)(S,{size:14}),j?A?`Confirm resume`:`Confirm suspend`:A?`Resume`:`Suspend`]}),j&&(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:A?`This routine will run at its next scheduled time. It will not run for the times it missed.`:`This routine stops running until you resume it. Nothing is deleted.`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:re,disabled:u,children:[u&&D?(0,F.jsx)(t,{size:14,className:`spin`}):(0,F.jsx)(m,{size:14}),D?`Confirm delete`:`Delete`]})]}),s&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:$,disabled:u||te,children:[u?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{l(!1),v(null)},disabled:u,children:`Cancel`})]})]})]})})}function W(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function G(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function K({run:e,routineName:t,onClose:n}){return(0,E.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,F.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,F.jsx)(w,{size:13}),` Run`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,F.jsx)(f,{size:16})})]}),(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),(0,F.jsx)(`div`,{className:`cal-modal-row`,children:(0,F.jsx)(`span`,{children:e.status})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Due: `,W(e.scheduledFor)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Started: `,W(e.startedAt)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Dispatch ended: `,W(e.endedAt),` (`,G(e.ranMs),`)`]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Output seen: `,W(e.finishedAt)]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,F.jsx)(`span`,{children:e.error})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsx)(`span`,{children:`This run shares its conversation with other traffic, so what it produced cannot be separated out. Its status stays at whatever the dispatch reported.`})}),(0,F.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,F.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}var q=500;function J(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Y(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var X={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function Z(e){if(e===`no-dispatch-configured`)return`This routine has no dispatch set up, so there was nothing to do.`;if(e===`no-action-plugin`)return`The tool action names no plugin, so nothing ran.`;if(e===`no-action-tool`)return`The tool action names no tool, so nothing ran.`;let t=e.startsWith(`no-`)?e.slice(3).split(`+`):[];if(t.length>0&&t.every(e=>e in X)){let e=t.map(e=>X[e]);return`This routine has no ${(e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`).replace(/^an? /,``)} set, so nothing was sent.`}return e}function te(e){return e.status===`no-destination`?e.error?Z(e.error):`Nothing was dispatched, and no reason was recorded.`:e.status===`failed`?e.error??e.dispatchResult??`The dispatch failed.`:e.status===`open`?`Opened and never closed. The dispatch did not report back.`:null}function Q({routine:e,adminFetch:n,cacheKey:r,onBack:i}){let[a,o]=(0,E.useState)([]),[s,c]=(0,E.useState)(!0),[l,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null);(0,E.useEffect)(()=>{let t=!1;return c(!0),d(null),n(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${q}`).then(async e=>{if(t)return;if(!e.ok)throw Error(`HTTP ${e.status}`);let n=await e.json();o(Array.isArray(n.runs)?n.runs:[])}).catch(e=>{t||(d(e instanceof Error?e.message:`Failed to load`),o([]))}).finally(()=>{t||c(!1)}),()=>{t=!0}},[n,e.eventId]);let m=(0,E.useCallback)(()=>{y(r,e.eventId)},[r,e.eventId]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsx)(`header`,{className:`cal-header`,children:(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,children:[(0,F.jsx)(v,{size:14}),` Routines`]}),(0,F.jsxs)(`span`,{className:`cal-range-label`,children:[(0,F.jsx)(w,{size:16}),` `,e.name??`Untitled routine`]}),s&&(0,F.jsx)(t,{size:16,className:`spin`}),a.length>0&&(0,F.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:m,children:[(0,F.jsx)(u,{size:14}),` Download all runs`]})})]})}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[l&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,l]}),!l&&!s&&a.length===0&&(0,F.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,F.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,F.jsx)(`p`,{children:`That means one of three things, and this page cannot tell them apart: it has never run, it ran but no record was written, or every run it did have is older than the 30 days records are kept for.`}),(0,F.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,F.jsx)(`code`,{children:` fires-without-records `}),` count above zero names a routine that fired and left no record. It does not distinguish the other two, and it does not cover a one-time routine.`]})]}),a.length>=q&&(0,F.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,q,` runs. There may be more; the download has everything still on record.`]}),(0,F.jsx)(`div`,{className:`routine-list`,children:a.map(e=>{let t=te(e);return(0,F.jsxs)(`button`,{type:`button`,className:`routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>p(e),children:[(0,F.jsx)(`span`,{className:`routine-card-title`,children:e.status}),(0,F.jsx)(`span`,{className:`routine-card-sched`,children:Y(e.ranMs)}),(0,F.jsx)(`span`,{className:`routine-card-target`,children:e.target}),(0,F.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,J(e.scheduledFor)]}),t&&(0,F.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),f&&(0,F.jsx)(K,{run:f,routineName:e.name,onClose:()=>p(null)})]})}var $=`maxy-admin-session-key`;function ne(e){return e?P(e):`One-time`}function re(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function ie(){let[e,t]=(0,E.useState)(null),[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(void 0),[o,c]=(0,E.useState)(null),[u,d]=(0,E.useState)(void 0),[f,p]=(0,E.useState)(null),[m,g]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),g(e.role??null),d(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,E.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,E.useState)(!1),x=(0,E.useCallback)(async()=>{b(!0);try{let e=await h();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(l,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(_,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:u,userAvatar:f,role:m,children:(0,F.jsx)(ae,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(s,{surface:`gate`})}function ae({cacheKey:e}){let{adminFetch:r,cacheKey:i,sessionRefetchNonce:a}=n({initialCacheKey:e,surface:`routines`}),[o,l]=(0,E.useState)([]),[u,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),[h,_]=(0,E.useState)(null),[v,y]=(0,E.useState)(null),[w,T]=(0,E.useState)(null),D=(0,E.useCallback)(()=>{let e=!1;return f(!0),_(null),r(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();l(Array.isArray(n.routines)?n.routines:[])}).catch(t=>{e||(_(t instanceof Error?t.message:`Failed to load`),l([]))}).finally(()=>{e||(f(!1),m(!0))}),()=>{e=!0}},[r]);(0,E.useEffect)(()=>D(),[D,a]);let O=(0,E.useCallback)(e=>{l(t=>t.map(t=>t.eventId===e.eventId?e:t)),y(e)},[]),k=(0,E.useCallback)(e=>{l(t=>t.filter(t=>t.eventId!==e)),y(null)},[]),[A,j]=(0,E.useState)(!1),[M,N]=(0,E.useState)(null),P=o.filter(e=>e.eventStatus===`scheduled`).length,I=o.filter(e=>e.suspendedInBulk).length,L=(0,E.useCallback)(async e=>{j(!0),N(null);try{let t=await r(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let n=await t.json(),i=n.refused?.length??0;N(e===`suspend-all`?`Suspended ${n.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${n.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),D()}catch(e){N(e instanceof Error?e.message:`Failed`)}finally{j(!1)}},[r,D]);return p?w?(0,F.jsx)(Q,{routine:w,adminFetch:r,cacheKey:i,onBack:()=>T(null)}):(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsx)(`header`,{className:`cal-header`,children:(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsxs)(`span`,{className:`cal-range-label`,children:[(0,F.jsx)(g,{size:16}),` Routines`]}),u&&(0,F.jsx)(t,{size:16,className:`spin`}),(0,F.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>L(`suspend-all`),disabled:A||P===0,children:[(0,F.jsx)(S,{size:14}),` Suspend all (`,P,`)`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>L(`resume-all`),disabled:A||I===0,children:[(0,F.jsx)(C,{size:14}),` Resume all (`,I,`)`]})]})]})}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[M&&(0,F.jsx)(`div`,{className:`cal-modal-confirm-text`,children:M}),h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,h]}),!h&&!u&&o.length===0&&(0,F.jsx)(`div`,{className:`cal-empty`,children:(0,F.jsx)(`p`,{children:`No routines yet.`})}),(0,F.jsx)(`div`,{className:`routine-list`,children:o.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>y(e),children:[(0,F.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.name??`Untitled routine`}),(0,F.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,F.jsx)(b,{size:13}),` `,ne(e.recurrence)]}),(0,F.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(c,{channel:e.agentChannel,size:13}),` `,d[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(x,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(b,{size:13}),` Scheduled trigger`]})}),(0,F.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,F.jsx)(V,{eventStatus:e.eventStatus}),`Next: `,re(e.nextRun),` · `,e.eventStatus??`unknown`]})]},e.eventId))})]}),v&&(0,F.jsx)(U,{routine:v,adminFetch:r,onClose:()=>y(null),onSaved:O,onDeleted:k,onViewRuns:e=>{y(null),T(e)}})]}):(0,F.jsx)(s,{surface:`gate`})}(0,T.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(ie,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{D as t,G as n,H as r,J as i,K as a,L as o,h as s,k as c,v as l,y as u}from"./useSubAccountSwitcher-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{D as t,G as n,H as r,J as i,K as a,L as o,h as s,k as c,v as l,y as u}from"./useSubAccountSwitcher-BRHYXwGO.js";import{E as d,p as f,t as p}from"./AdminShell-MM3_yp3N.js";import{t as m}from"./file-text-BSyhVH0m.js";var h=a(),g=e(i(),1),_=r();function v({summary:e,adminFetch:n,onClose:r,onDeleted:i}){let[a,o]=(0,g.useState)(null),[s,d]=(0,g.useState)(!0),[p,h]=(0,g.useState)(null),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let t=!1;return d(!0),h(null),n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);o((await e.json()).skill)}}).catch(e=>{t||h(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||d(!1)}),()=>{t=!0}},[n,e.plugin,e.skill]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,r]);let S=(0,g.useCallback)(async()=>{x(!0),h(null);try{let t=await n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}i(e)}catch(e){h(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[n,e,i]);return(0,_.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||r()},children:(0,_.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,_.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,_.jsx)(f,{size:13}),` Skill`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,_.jsx)(l,{size:16})})]}),(0,_.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,_.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(m,{size:14}),(0,_.jsx)(`span`,{children:e.plugin})]}),s&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(t,{size:14,className:`spin`}),(0,_.jsx)(`span`,{children:`Loading…`})]}),a&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,_.jsx)(`span`,{children:a.frontmatter.description||`No description.`})}),a.frontmatter.publicEmbed&&(0,_.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,_.jsx)(c,{size:14}),(0,_.jsx)(`span`,{children:`Public embed`})]}),(0,_.jsx)(`pre`,{className:`skill-body`,children:a.body.trim()||`No body content.`}),a.references.length>0&&(0,_.jsxs)(`div`,{className:`skill-refs`,children:[(0,_.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),a.references.map(e=>(0,_.jsxs)(`span`,{className:`skill-ref`,children:[(0,_.jsx)(m,{size:13}),` `,e]},e))]})]})]}),p&&(0,_.jsx)(`div`,{className:`cal-modal-error`,children:p}),(0,_.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||s,children:[(0,_.jsx)(u,{size:14}),` Delete`]}),v&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,_.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,_.jsx)(t,{size:14,className:`spin`}):(0,_.jsx)(u,{size:14}),` Delete`]}),(0,_.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var y=`maxy-admin-session-key`;function b(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(void 0),[c,l]=(0,g.useState)(null),[u,f]=(0,g.useState)(void 0),[m,h]=(0,g.useState)(null),[v,b]=(0,g.useState)(null);(0,g.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(y)}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(y)}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),b(e.role??null),f(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 S=(0,g.useCallback)(()=>{try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},[]),[C,w]=(0,g.useState)(!1),T=(0,g.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,_.jsx)(s,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},children:(0,_.jsx)(p,{cacheKey:e,businessName:i,sessionId:c,onLogout:S,onDisconnect:T,disconnecting:C,userName:u,userAvatar:m,role:v,children:(0,_.jsx)(x,{cacheKey:e})})}):(0,_.jsx)(`div`,{className:`cal-page`,children:(0,_.jsxs)(`div`,{className:`cal-empty`,children:[(0,_.jsx)(`p`,{children:`You are not signed in.`}),(0,_.jsxs)(`p`,{children:[`Open the `,(0,_.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,_.jsx)(o,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`skills`}),[a,s]=(0,g.useState)([]),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),[p,h]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useCallback)(()=>{let e=!1;return l(!0),h(null),r(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(h(t instanceof Error?t.message:`Failed to load`),s([]))}).finally(()=>{e||(l(!1),d(!0))}),()=>{e=!0}},[r]);(0,g.useEffect)(()=>x(),[x,i]);let S=(0,g.useCallback)(e=>{s(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),b(null),x()},[x]);return u?(0,_.jsxs)(`div`,{className:`cal-page`,children:[(0,_.jsx)(`header`,{className:`cal-header`,children:(0,_.jsxs)(`div`,{className:`cal-nav`,children:[(0,_.jsxs)(`span`,{className:`cal-range-label`,children:[(0,_.jsx)(f,{size:16}),` Skills`]}),c&&(0,_.jsx)(t,{size:16,className:`spin`})]})}),(0,_.jsxs)(`div`,{className:`cal-body`,children:[p&&(0,_.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,p]}),!p&&!c&&a.length===0&&(0,_.jsx)(`div`,{className:`cal-empty`,children:(0,_.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),a.length>0&&(0,_.jsx)(`div`,{className:`routine-list`,children:a.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,onClick:()=>b(e),children:[(0,_.jsx)(`span`,{className:`admin-card-title routine-card-title`,children:e.skill}),(0,_.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,_.jsx)(m,{size:13}),` `,e.plugin]}),(0,_.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,_.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),y&&(0,_.jsx)(v,{summary:y,adminFetch:r,onClose:()=>b(null),onDeleted:S})]}):(0,_.jsx)(o,{surface:`gate`})}(0,h.createRoot)(document.getElementById(`root`)).render((0,_.jsx)(b,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
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,N as o,b as s,h as c,v as l,w as u}from"./useSubAccountSwitcher-BRHYXwGO.js";import{E as d,h as f,r as p,t as m}from"./AdminShell-MM3_yp3N.js";import{n as h,t as g}from"./time-entry-format-DLTdS35_.js";import{t as _}from"./rotate-ccw-DQCaky8_.js";var v=i(),y=e(r(),1);function b(e=3e4){let[t,n]=(0,y.useState)(()=>Date.now());return(0,y.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function x(e,t){let n=new Map,r=(e,t,r)=>{let i=n.get(e)??{openCount:0,totalSeconds:0};i.totalSeconds+=t,r&&(i.openCount+=1),n.set(e,i)};for(let t of e)t.clientName&&r(t.clientName,t.secondsLogged,!0);for(let e of t)e.clientName&&r(e.clientName,e.secondsLogged,!1);let i=[...n.entries()].map(([e,t])=>({name:e,openCount:t.openCount,totalSeconds:t.totalSeconds}));return i.sort((e,t)=>t.openCount-e.openCount||e.name.localeCompare(t.name)),S(e,i),i}function S(e,t){let n=t.reduce((e,t)=>e+t.openCount,0),r=e.filter(e=>!e.clientName).length,i=n+r===e.length;return i||console.warn(`[tasks-clients] reconcile-mismatch assigned=${n} unassigned=${r} openTotal=${e.length}`),i}var C=`__unassigned__`;function w(e,t){return e===`__unassigned__`?`Unassigned`:t||e.slice(0,8)}function T(e){return e===null||e===``?C:e}function ee(e,t){let n=new Map,r=(e,t)=>{let r=T(e.assigneeUserId),i=n.get(r)??{name:null,openCount:0,totalCount:0};i.name===null&&e.assigneeName&&(i.name=e.assigneeName),i.totalCount+=1,t&&(i.openCount+=1),n.set(r,i)};for(let t of e)r(t,!0);for(let e of t)r(e,!1);let i=[...n.entries()].map(([e,t])=>({userId:e,label:w(e,t.name),openCount:t.openCount,totalCount:t.totalCount}));return i.sort((e,t)=>t.openCount-e.openCount||e.label.localeCompare(t.label)),i}function E(e,t){return t===null?!0:T(e.assigneeUserId)===t}var D=n();function O(e){let t=e.name??e.userId.slice(0,8);return e.kind===`owner`?`${t} (owner)`:t}var k=`maxy-admin-session-key`;function A(e){let t=[];return e.clientName&&t.push(e.clientName),e.propertyAddress&&t.push(e.propertyAddress),e.fee!=null&&t.push(`£${e.fee}`),t.join(` · `)}function j(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=new Date(t);return`${n.getUTCDate()} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][n.getUTCMonth()]} ${n.getUTCFullYear()}`}function M(e){return e.assigneeName?e.assigneeName:e.assigneeUserId?e.assigneeUserId.slice(0,8):`Unassigned`}function N(e,t){return[t,j(e.createdAt),M(e)].filter(Boolean).join(` · `)}function P(e,t){if(e.running&&e.runningStartedAt){let n=Date.parse(e.runningStartedAt);if(Number.isFinite(n))return e.secondsLogged+Math.max(0,(t-n)/1e3)}return e.secondsLogged}function te(e){let t=[`Task: ${e.title}\nTask id: ${e.taskId}`],n=e.description.trim();n.length>0&&t.push(n);let r=e.notes.trim();return r.length>0&&t.push(`Notes:\n${r}`),t.join(`
|
|
2
|
+
|
|
3
|
+
`).slice(0,2e3)}function ne({clients:e,onSelect:t}){return(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Clients`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[e.length,` total`]})]}),e.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No clients yet.`}),e.map(e=>(0,D.jsx)(`button`,{className:`tasks-row tasks-client-row`,onClick:()=>t(e.name),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsxs)(`div`,{className:`tasks-row-sub`,children:[e.openCount,` open · `,g(e.totalSeconds),` logged`]})]})},e.name))]})}function re({task:e,roster:t,busy:n,onAssign:r,onClose:i}){return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,D.jsx)(`div`,{className:`tasks-detail-backdrop`,onClick:i,children:(0,D.jsxs)(`div`,{className:`tasks-detail`,role:`dialog`,"aria-modal":`true`,"aria-label":`Task detail`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`tasks-detail-head`,children:[(0,D.jsx)(`h2`,{className:`tasks-detail-title`,children:e?e.name:`Task no longer available`}),(0,D.jsx)(`button`,{className:`tasks-detail-close`,"aria-label":`Close`,onClick:i,children:(0,D.jsx)(l,{size:16})})]}),e===null?(0,D.jsx)(`p`,{className:`tasks-detail-gone`,children:`This task is no longer in the list. It may have been completed, cancelled or removed. Close this and reload to see the current list.`}):(0,D.jsxs)(`dl`,{className:`tasks-detail-fields`,children:[(0,D.jsx)(`dt`,{children:`Status`}),(0,D.jsx)(`dd`,{children:e.status}),(0,D.jsx)(`dt`,{children:`Logged`}),(0,D.jsx)(`dd`,{children:g(e.secondsLogged)}),(0,D.jsx)(`dt`,{children:`Created`}),(0,D.jsx)(`dd`,{children:j(e.createdAt)||`Not recorded`}),(0,D.jsx)(`dt`,{children:`Assignee`}),(0,D.jsx)(`dd`,{children:e.taskId===null?M(e):(0,D.jsxs)(`select`,{className:`tasks-assign-select`,"aria-label":`Assignee`,disabled:n,value:e.assigneeUserId??``,onChange:t=>r(e.taskId,t.target.value===``?null:t.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Unassigned`}),e.assigneeUserId&&!t.some(t=>t.userId===e.assigneeUserId)&&(0,D.jsxs)(`option`,{value:e.assigneeUserId,children:[M(e),` (not in roster)`]}),t.map(e=>(0,D.jsx)(`option`,{value:e.userId,children:O(e)},e.userId))]})}),e.clientName&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Client`}),(0,D.jsx)(`dd`,{children:e.clientName})]}),e.propertyAddress&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Property`}),(0,D.jsx)(`dd`,{children:e.propertyAddress})]}),e.fee!=null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`dt`,{children:`Fee`}),(0,D.jsxs)(`dd`,{children:[`£`,e.fee]})]})]})]})})}function F({adminFetch:e}){let[t,n]=(0,y.useState)({open:[],completed:[]}),[r,i]=(0,y.useState)(!1),[c,d]=(0,y.useState)(!1),m=(0,y.useRef)(!1),v=(0,y.useRef)(``),S=b(1e3),[C,w]=(0,y.useState)(`open`),[T,O]=(0,y.useState)(null),[k,j]=(0,y.useState)(null),[M,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)(null),[ie,B]=(0,y.useState)(null),V=(0,y.useRef)(new Set),[ae,H]=(0,y.useState)(new Set),U=(0,y.useMemo)(()=>{if(R!==null)return[...t.open,...t.completed].find(e=>e.rowKey===R)??null},[t,R]);(0,y.useEffect)(()=>{R!==null&&U===null&&console.error(`[tasks-ui] op=detail-failed rowKey=${R} reason=not-in-list`)},[R,U]);let W=(0,y.useMemo)(()=>x(t.open,t.completed),[t]),G=(0,y.useMemo)(()=>T===null?{open:t.open,completed:t.completed}:{open:t.open.filter(e=>e.clientName===T),completed:t.completed.filter(e=>e.clientName===T)},[t,T]),K=(0,y.useMemo)(()=>ee(G.open,G.completed),[G]),oe=(0,y.useCallback)(e=>{O(e),w(`open`)},[]);(0,y.useEffect)(()=>{T&&!W.some(e=>e.name===T)&&O(null)},[W,T]),(0,y.useEffect)(()=>{k&&!K.some(e=>e.userId===k)&&j(null)},[K,k]),(0,y.useEffect)(()=>{B(null)},[C,T,k]);let q=t.open.filter(e=>e.running||(T===null||e.clientName===T)&&E(e,k)),J=(T?t.completed.filter(e=>e.clientName===T):t.completed).filter(e=>E(e,k)),[se,ce]=(0,y.useState)([]),Y=(0,y.useCallback)(async()=>{let t=await e(`/api/admin/tasks-list`);t.ok&&n(await t.json()),i(!0)},[e]);(0,y.useEffect)(()=>{Y()},[Y]),(0,y.useEffect)(()=>{(async()=>{let t=await e(`/api/admin/admin-users-list`);if(t.ok){let e=await t.json();e.ok&&Array.isArray(e.users)&&ce(e.users)}})()},[e]);let X=(0,y.useCallback)(async(t,n,r)=>{if(m.current)return!1;m.current=!0,d(!0);try{return await e(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:n,...r})}),await Y(),!0}finally{m.current=!1,d(!1)}},[e,Y]),le=(0,y.useCallback)(async e=>{await X(`/api/admin/task-complete`,e)&&console.log(`[tasks-ui] op=complete taskId=${e.slice(0,8)} confirmed=true`)},[X]),ue=(0,y.useCallback)((e,t)=>{let n=String(Math.round(e.secondsLogged/60));v.current=n,F(t),L(n)},[]),Z=(0,y.useCallback)(()=>{F(null),L(``)},[]),de=(0,y.useCallback)(async e=>{let t=I.trim(),n=Number(t);if(!(t===``||!Number.isInteger(n)||n<0)){if(t===v.current){Z();return}F(null),L(``),await X(`/api/admin/task-time-adjust`,e,{newSeconds:n*60})}},[I,X,Z]),fe=(0,y.useCallback)(e=>{X(`/api/admin/task-time-adjust`,e,{newSeconds:0})},[X]),pe=(0,y.useCallback)((e,t)=>{X(`/api/admin/task-assign`,e,{assigneeUserId:t})},[X]),me=(0,y.useCallback)(async t=>{if(!V.current.has(t)){V.current.add(t),H(new Set(V.current));try{let n=await e(`/api/admin/task-session-open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t})});if(!n.ok){console.error(`[admin-ui] task-session op=open-failed taskId=${t} status=${n.status}`);return}let{sessionId:r,title:i,description:a,notes:o}=await n.json();if(r!==null){let e=`/chat?session=${r}`;console.info(`[admin-ui] task-session op=resume taskId=${t} sessionId=${r} target=${e}`),window.location.assign(e);return}let s=te({title:i,taskId:t,description:a??``,notes:o??``}),c=await e(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:i,initialMessage:s})}),l=await c.json().catch(()=>({})),u=p(c.ok,c.status,l),d=l.sessionId??null,f=new TextEncoder().encode(s).length;if(console.info(`[admin-ui] task-session op=spawn taskId=${t} kind=new status=${c.status} outcome=${u.kind} landed=${d??`none`} seedBytes=${f}`),u.kind!==`navigate`){console.error(`[admin-ui] task-session op=spawn-failed taskId=${t} reason=${u.reason}`);return}let m=!1;if(d!==null){let n=await e(`/api/admin/task-session-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:t,sessionId:d})});m=n.ok&&(await n.json().catch(()=>({}))).linked===!0}else console.error(`[admin-ui] task-session op=link-skipped taskId=${t} reason=no-landed-session-id`);console.info(`[admin-ui] task-session op=navigate taskId=${t} sessionId=${d??`none`} linked=${m} sameOrigin=${u.sameOrigin}`),window.location.assign(u.url)}catch(e){console.error(`[admin-ui] task-session op=failed taskId=${t} error=${e instanceof Error?e.message:String(e)}`)}finally{V.current.delete(t),H(new Set(V.current))}}},[e]);if(!r)return(0,D.jsx)(a,{surface:`gate`});let Q=e=>e.taskId!==null&&M===e.taskId,$=(e,t)=>Q(e)?(0,D.jsxs)(`div`,{className:`tasks-edit`,children:[(0,D.jsx)(`input`,{className:`tasks-edit-input`,type:`number`,min:0,step:1,"aria-label":`Logged minutes`,value:I,onChange:e=>L(e.target.value)}),(0,D.jsx)(`span`,{className:`tasks-edit-unit`,children:`min`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:c,onClick:()=>void de(t),children:[(0,D.jsx)(o,{size:14}),` Save`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:Z,children:[(0,D.jsx)(l,{size:14}),` Cancel`]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Edit time`,disabled:c||e.running,title:e.running?`Stop the timer before editing time`:void 0,onClick:()=>ue(e,t),children:(0,D.jsx)(u,{size:14})}),(0,D.jsx)(`button`,{className:`tasks-time-btn`,"aria-label":`Reset time`,disabled:c||e.running,title:e.running?`Stop the timer before resetting time`:void 0,onClick:()=>fe(t),children:(0,D.jsx)(_,{size:14})})]});return(0,D.jsxs)(`div`,{className:`ui-page ui-page--full tasks-body`,children:[R!==null&&(0,D.jsx)(re,{task:U??null,roster:se,busy:c,onAssign:pe,onClose:()=>z(null)}),(0,D.jsxs)(`div`,{className:`tasks-tabs`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${C===`open`?`is-active`:``}`,onClick:()=>w(`open`),children:[`Open `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:t.open.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`completed`?`is-active`:``}`,onClick:()=>w(`completed`),children:[`Completed `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:t.completed.length})]}),(0,D.jsxs)(`button`,{className:`admin-chip ${C===`clients`?`is-active`:``}`,onClick:()=>w(`clients`),children:[`Clients `,(0,D.jsx)(`span`,{className:`tasks-tab-badge`,children:W.length})]})]}),C===`clients`?(0,D.jsx)(ne,{clients:W,onSelect:oe}):(0,D.jsxs)(D.Fragment,{children:[T&&(0,D.jsxs)(`div`,{className:`tasks-filter-banner`,children:[(0,D.jsxs)(`span`,{children:[`Showing `,T]}),(0,D.jsx)(`button`,{className:`tasks-filter-clear`,onClick:()=>O(null),children:`Clear`})]}),K.length>0&&(0,D.jsxs)(`div`,{className:`tasks-assignee-bar`,children:[(0,D.jsxs)(`button`,{className:`admin-chip ${k===null?`is-active`:``}`,"aria-pressed":k===null,onClick:()=>j(null),children:[`All `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:G.open.length})]}),K.map(e=>(0,D.jsxs)(`button`,{className:`admin-chip ${k===e.userId?`is-active`:``}`,"aria-pressed":k===e.userId,"aria-label":`Assignee ${e.label}`,title:e.userId===`__unassigned__`?`Tasks with no assigned admin`:`AdminUser ${e.userId}`,onClick:()=>j(k===e.userId?null:e.userId),children:[e.label,` `,(0,D.jsx)(`span`,{className:`tasks-assignee-count`,children:e.openCount})]},e.userId))]}),C===`open`?(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Open tasks`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[q.length,` to do`]})]}),q.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`No open tasks.`}),q.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row`,children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>z(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:N(e,A(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed ${e.running?`tasks-row-elapsed-running`:``}`,children:g(P(e,S))}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId!==null&&ie===e.taskId?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`tasks-confirm-label`,children:`Complete?`}),(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:c,onClick:()=>{B(null),le(e.taskId)},children:[(0,D.jsx)(o,{size:14}),` Confirm complete`]}),(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,onClick:()=>B(null),children:[(0,D.jsx)(l,{size:14}),` Keep open`]})]}):e.taskId===null?(0,D.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so it cannot be started, edited or completed. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):(0,D.jsxs)(D.Fragment,{children:[$(e,e.taskId),Q(e)?null:(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,"aria-label":`Open session for task: ${e.name}`,disabled:ae.has(e.taskId),title:e.sessionId?`Resume this task’s session`:`Start a session for this task`,onClick:()=>void me(e.taskId),children:[(0,D.jsx)(f,{size:14}),` Session`]}),Q(e)?null:(0,D.jsxs)(`button`,{className:`tasks-btn-secondary tasks-btn-action`,"aria-label":`Complete task: ${e.name}`,disabled:c||e.running,title:e.running?`Stop the timer before completing`:void 0,onClick:()=>B(e.taskId),children:[(0,D.jsx)(o,{size:14}),` Complete`]}),Q(e)?null:e.running?(0,D.jsxs)(`button`,{className:`admin-btn-danger tasks-btn-action`,disabled:c,onClick:()=>void X(`/api/admin/task-timer-stop`,e.taskId),children:[(0,D.jsx)(s,{size:14}),` Stop`]}):(0,D.jsxs)(`button`,{className:`admin-btn-cta tasks-btn-action`,disabled:c,onClick:()=>void X(`/api/admin/task-timer-start`,e.taskId),children:[(0,D.jsx)(h,{size:14}),` Start`]})]})})]},e.rowKey))]}):(0,D.jsxs)(`section`,{className:`admin-card tasks-card`,children:[(0,D.jsxs)(`div`,{className:`tasks-card-head`,children:[(0,D.jsx)(`span`,{className:`tasks-card-title`,children:`Completed`}),(0,D.jsxs)(`span`,{className:`tasks-card-count`,children:[J.length,` done`]})]}),J.length===0&&(0,D.jsx)(`div`,{className:`tasks-empty`,children:`Nothing completed yet.`}),J.map(e=>(0,D.jsxs)(`div`,{className:`tasks-row tasks-row-done`,children:[(0,D.jsx)(`button`,{className:`tasks-row-open`,"aria-label":`Open task detail: ${e.name}`,onClick:()=>z(e.rowKey),children:(0,D.jsxs)(`div`,{className:`tasks-row-main`,children:[(0,D.jsx)(`div`,{className:`tasks-row-name`,children:e.name}),(0,D.jsx)(`div`,{className:`tasks-row-sub`,children:N(e,A(e))})]})}),(0,D.jsx)(`div`,{className:`tasks-row-elapsed`,children:g(e.secondsLogged)}),(0,D.jsx)(`div`,{className:`tasks-row-controls`,children:e.taskId===null?(0,D.jsx)(`span`,{className:`tasks-row-broken`,title:`This task has no id, so its logged time cannot be edited. Repair it by running platform/scripts/backfill-task-ids.sh on this install.`,children:`Needs repair`}):$(e,e.taskId)})]},e.rowKey))]})]})]})}function I({cacheKey:e}){let{adminFetch:n}=t({initialCacheKey:e,surface:`tasks`});return(0,D.jsx)(F,{adminFetch:n})}function L(){let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(!1),[i,o]=(0,y.useState)(void 0),[s,l]=(0,y.useState)(null),[u,f]=(0,y.useState)(null),[p,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(k)}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(k)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),f(e.role??null),h(e.userName===void 0?null:e.userName),_(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,y.useCallback)(()=>{try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},[]),[b,x]=(0,y.useState)(!1),S=(0,y.useCallback)(async()=>{x(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`}return e}finally{x(!1)}},[]);return n?e?(0,D.jsx)(c,{cacheKey:e,surface:`tasks`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=tasks`);try{sessionStorage.removeItem(k)}catch{}window.location.href=`/`},children:(0,D.jsx)(m,{cacheKey:e,businessName:i,sessionId:s,onLogout:v,onDisconnect:S,disconnecting:b,userName:p,userAvatar:g,role:u,children:(0,D.jsx)(I,{cacheKey:e})})}):(0,D.jsx)(`div`,{className:`tasks-page`,children:(0,D.jsxs)(`div`,{className:`tasks-empty`,children:[(0,D.jsx)(`p`,{children:`You are not signed in.`}),(0,D.jsxs)(`p`,{children:[`Open the `,(0,D.jsx)(`a`,{href:`/`,className:`tasks-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,D.jsx)(a,{surface:`gate`})}(0,v.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(L,{}));
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{time-entry-format-r5UY9rjG.js → time-entry-format-DLTdS35_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{I as e}from"./useSubAccountSwitcher-BRHYXwGO.js";var t=e(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);function n(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}:${String(i).padStart(2,`0`)}`}export{t as n,n as t};
|
|
Binary file
|
|
Binary file
|
package/payload/server/public/assets/{triangle-alert--PCKaewD.js → triangle-alert-CpwrbdYq.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e}from"./useSubAccountSwitcher-
|
|
1
|
+
import{I as e}from"./useSubAccountSwitcher-BRHYXwGO.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
|
|
Binary file
|
package/payload/server/public/assets/{useCopyFeedback-Dg5lNgqH.js → useCopyFeedback-D01gSp36.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CltuBf4Z.js";import{J as t,r as n}from"./useSubAccountSwitcher-
|
|
1
|
+
import{o as e}from"./chunk-CltuBf4Z.js";import{J as t,r as n}from"./useSubAccountSwitcher-BRHYXwGO.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(`idle`),a=(0,r.useRef)(null),o=(0,r.useRef)(e?.onResult);return o.current=e?.onResult,(0,r.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]),{status:t,copy:(0,r.useCallback)(async e=>{let t=await n(e);i(t?`ok`:`fail`),o.current?.(t),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},[])}}export{i as t};
|
|
Binary file
|
|
Binary file
|