@rubytech/create-maxy-code 0.1.378 → 0.1.382

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/__tests__/plugin-install.test.js +18 -1
  2. package/dist/index.js +22 -8
  3. package/dist/lib/plugin-install.js +22 -0
  4. package/package.json +1 -1
  5. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +11 -3
  6. package/payload/platform/plugins/docs/references/admin-ui.md +4 -2
  7. package/payload/platform/plugins/docs/references/internals.md +4 -0
  8. package/payload/platform/plugins/docs/references/plugins-guide.md +2 -0
  9. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +13 -0
  10. package/payload/platform/services/claude-session-manager/dist/index.js +32 -0
  11. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  12. package/payload/platform/services/claude-session-manager/dist/skill-registration-drift.d.ts +51 -0
  13. package/payload/platform/services/claude-session-manager/dist/skill-registration-drift.d.ts.map +1 -0
  14. package/payload/platform/services/claude-session-manager/dist/skill-registration-drift.js +163 -0
  15. package/payload/platform/services/claude-session-manager/dist/skill-registration-drift.js.map +1 -0
  16. package/payload/server/{chunk-AQO6KLIH.js → chunk-ZYS5V5QG.js} +0 -21
  17. package/payload/server/maxy-edge.js +1 -1
  18. package/payload/server/public/assets/{AdminLoginScreens-B9u1V35g.js → AdminLoginScreens-C_Qn0UPy.js} +1 -1
  19. package/payload/server/public/assets/AdminShell-iHdYhspw.js +1 -0
  20. package/payload/server/public/assets/{Checkbox-B2g2SCpw.js → Checkbox-B76SHnPC.js} +1 -1
  21. package/payload/server/public/assets/admin-RTEhnrPk.js +1 -0
  22. package/payload/server/public/assets/{browser-B8omhYsK.js → browser-Chmp3Xfv.js} +1 -1
  23. package/payload/server/public/assets/calendar-CjE7hiqV.js +1 -0
  24. package/payload/server/public/assets/chat-DiKmCMO1.js +1 -0
  25. package/payload/server/public/assets/data-5PpEsUR3.js +1 -0
  26. package/payload/server/public/assets/{graph-DJOKFr_s.js → graph-DEHmvpNl.js} +3 -3
  27. package/payload/server/public/assets/{graph-labels-DFdBydWC.js → graph-labels-CYAjU3rz.js} +1 -1
  28. package/payload/server/public/assets/operator-BDTnuQhB.js +1 -0
  29. package/payload/server/public/assets/page-D8FFXoI9.js +1 -0
  30. package/payload/server/public/assets/page-HeiBebPq.js +32 -0
  31. package/payload/server/public/assets/{public-CGl0i1f-.js → public-BIOxrxZK.js} +1 -1
  32. package/payload/server/public/assets/{rotate-ccw-Cg_V4XIU.js → rotate-ccw-K1xZvf3B.js} +1 -1
  33. package/payload/server/public/assets/{useSubAccountSwitcher-Ca1GJeBC.css → useSubAccountSwitcher-B44qYovc.css} +1 -1
  34. package/payload/server/public/assets/useSubAccountSwitcher-DPEkYkYd.js +9 -0
  35. package/payload/server/public/browser.html +4 -4
  36. package/payload/server/public/calendar.html +4 -4
  37. package/payload/server/public/chat.html +6 -6
  38. package/payload/server/public/data.html +5 -5
  39. package/payload/server/public/graph.html +7 -7
  40. package/payload/server/public/index.html +8 -8
  41. package/payload/server/public/operator.html +8 -8
  42. package/payload/server/public/public.html +6 -6
  43. package/payload/server/server.js +387 -122
  44. package/payload/server/public/assets/AdminShell-C2UXTLSB.js +0 -1
  45. package/payload/server/public/assets/admin-CRBQgWsm.js +0 -1
  46. package/payload/server/public/assets/calendar-Blb-5arm.js +0 -1
  47. package/payload/server/public/assets/chat--1ajLxwi.js +0 -1
  48. package/payload/server/public/assets/data-BYUmu98z.js +0 -1
  49. package/payload/server/public/assets/operator-DUVqlubZ.js +0 -1
  50. package/payload/server/public/assets/page-BMeSKYGZ.js +0 -32
  51. package/payload/server/public/assets/page-DBkTNfei.js +0 -1
  52. package/payload/server/public/assets/useSubAccountSwitcher-DAgBUed_.js +0 -9
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,E as r,H as i,K as a,L as o,M as s,N as c,O as l,P as u,R as d,T as f,V as p,_ as m,g as h,j as g,m as ee,n as te,q as _,t as ne,v as re,x as v,y as ie}from"./useSubAccountSwitcher-DAgBUed_.js";async function y(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var b=e(_(),1),x=i(),S={sm:14,md:16,lg:18},ae={sm:30,md:38,lg:46};function C({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=S[t],h={...e===`send`?{width:ae[t],height:ae[t]}:{},...u},g=Object.keys(h).length>0;return(0,x.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,x.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,x.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,x.jsx)(n,{size:m})]}),i&&(0,x.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var w=o(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),oe=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),T=o(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),se=o(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),ce=o(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),le=o(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),E=o(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ue=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),de=o(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),D=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),O=o(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),k=`maxy-shell-side-px`;function fe(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function A(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-fe());return Math.min(Math.max(e,248),n)}function j(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(k);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return A(t)}catch{}return 264}function M({targetSelector:e=`.platform`}){let t=(0,b.useRef)(null),[n,r]=(0,b.useState)(()=>j()),i=(0,b.useRef)(n);(0,b.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,b.useCallback)(()=>{r(e=>{let t=A(e);return t===e?e:t})},[]);(0,b.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(A(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(k,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=A(264);r(e);try{window.localStorage.removeItem(k)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,x.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var pe=a();function me({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,b.useRef)(null),[s,c]=(0,b.useState)({position:`fixed`,visibility:`hidden`}),l=(0,b.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,b.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,b.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,pe.createPortal)((0,x.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function N({action:e,disabled:t,open:n,onToggle:r,onClose:i}){let a=(0,b.useRef)(null);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{ref:a,type:`button`,className:`conv-action`,onClick:r,disabled:t,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":e.label,title:e.title,children:e.icon}),n&&(0,x.jsx)(me,{anchorRef:a,onClose:i,className:e.panelClassName,role:`dialog`,ariaLabel:e.label,children:e.panel()})]})}function he({actions:e,disabled:t,collapsed:n}){let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),u=(0,b.useRef)(null);(0,b.useEffect)(()=>{i(null),o(!1),l(null)},[n]);let d=(0,b.useCallback)(()=>{o(!1),l(null)},[]);return n?(0,x.jsxs)(`div`,{className:`conv-actions`,children:[(0,x.jsx)(`button`,{ref:u,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>o(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`Session actions`,title:`Session actions`,children:(0,x.jsx)(s,{size:12})}),a&&(0,x.jsx)(me,{anchorRef:u,onClose:d,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,x.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,x.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":c===e.key,disabled:t,onClick:()=>l(t=>t===e.key?null:e.key),children:[e.icon,(0,x.jsx)(`span`,{children:e.menuLabel})]}),c===e.key&&(0,x.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,x.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),d()},children:[e.icon,(0,x.jsx)(`span`,{children:e.menuLabel})]},e.key))})]}):(0,x.jsx)(`div`,{className:`conv-actions`,children:e.map(e=>e.panel?(0,x.jsx)(N,{action:e,disabled:t,open:r===e.key,onToggle:()=>i(t=>t===e.key?null:e.key),onClose:()=>i(null)},e.key):(0,x.jsx)(`button`,{type:`button`,className:e.danger?`conv-action conv-action-danger`:`conv-action`,onClick:e.onClick,disabled:t,"aria-busy":e.busy,"aria-label":e.label,title:e.title,children:e.icon},e.key))})}var P=`claude-opus-4-8[1m]`,F=`claude-sonnet-5`,I=`claude-haiku-4-5`,L={[P]:`Opus 4.8 (1M context)`,[F]:`Sonnet 5`,[I]:`Haiku 4.5`};function ge(e){return L[e]??e}var _e=[P,F,I];function R(e){return e.replace(/\[1m\]$/,``)}function z(e){return _e.find(t=>R(t)===R(e))??e}var ve=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...ve],[...B],[...B];var ye=[P,F,I],be={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},xe=ve.map(e=>({value:e,label:be[e]??e})),V={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},H=B.map(e=>({value:e,label:V[e]??e}));function Se(e){if(e){let t=ye.find(t=>R(t)===R(e));if(t)return t}return P}function Ce({row:e,adminFetch:t,onError:n}){let[r,i]=(0,b.useState)(()=>Se(e.model)),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(``),[u,d]=(0,b.useState)(!1),f=(0,b.useRef)(!1);(0,b.useEffect)(()=>{i(Se(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Model`}),(0,x.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:ye.map(e=>(0,x.jsx)(`option`,{value:e,children:ge(e)},e))})]}),(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Mode`}),(0,x.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>o(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Keep current`}),xe.map(e=>(0,x.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,x.jsxs)(`label`,{className:`reseat-field`,children:[(0,x.jsx)(`span`,{children:`Effort`}),(0,x.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:u,onChange:e=>c(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,x.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,x.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}var we=[`whatsapp`,`telegram`];function U(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function W(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function Te(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ee({target:e,onConfirm:t,onCancel:n}){return e?(0,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`span`,{children:`Delete this conversation?`}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,x.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,x.jsx)(C,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,x.jsx)(C,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var G=`auth-refresh-failed`;function De({error:e,onClose:t}){if(!e)return null;let n=e.reason===G,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`span`,{children:r}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,x.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Oe(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,b.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,x.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,x.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)(`div`,{className:`claude-info-header`,children:[(0,x.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,x.jsx)(`span`,{children:`Claude Code`}),(0,x.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,x.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,x.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,x.jsxs)(`div`,{className:`claude-info-section`,children:[(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:p>0?W(p):`—`})]}),(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.jsx)(`span`,{className:`claude-info-value`,children:U(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,x.jsxs)(`div`,{className:`claude-info-row`,children:[(0,x.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,x.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await Te(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}var ke=`https://claude.ai/code`,Ae=200,je=[500,1e3,1500,2e3,2500,3e3,3e3];function Me(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${ke}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function Ne(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Pe(e){let{businessName:i,cacheKey:a,role:o,userName:s,userAvatar:l,onSelectProjects:te,onSelectPeople:_,onSelectTasks:ne,onSelectAgents:ie,onCloseMobileDrawer:y,collapsed:S,selectedWhatsappId:ae,onSelectWhatsappConversation:C,initialWhatsappSurface:k=!1,onSelectData:fe,onCloseData:A,initialDataSurface:j=!1}=e,M=v(a),pe=(0,b.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,x.jsx)(de,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,x.jsx)(Ce,{row:e,adminFetch:M,onError:e=>H({message:e,failed:!0})})}),[M]),me=d.productName,N=typeof s==`string`?s:s===null?`name unavailable`:i||me,P=(N.trim().charAt(0)||`?`).toUpperCase(),[F,I]=(0,b.useState)(j?`data`:k?`whatsapp`:`sessions`),[L,ge]=(0,b.useState)([]),[_e,R]=(0,b.useState)(!1),[z,ve]=(0,b.useState)(null),[B,ye]=(0,b.useState)(!1),[be,xe]=(0,b.useState)(`file`),[V,H]=(0,b.useState)(null),[Se,U]=(0,b.useState)(null),[W,Te]=(0,b.useState)([]),[G,Oe]=(0,b.useState)(!1),[ke,Pe]=(0,b.useState)(null),[Fe,K]=(0,b.useState)(!1),[q,ze]=(0,b.useState)(!1),[J,Be]=(0,b.useState)(!1),[Ve,He]=(0,b.useState)(null),[Ue,We]=(0,b.useState)(new Set),[Ge,Y]=(0,b.useState)(null),[Ke,qe]=(0,b.useState)(new Set),[Je,Ye]=(0,b.useState)(new Set),[Xe,Ze]=(0,b.useState)(new Set),[Qe,$e]=(0,b.useState)(null),[et,X]=(0,b.useState)(``),[tt,nt]=(0,b.useState)(!1),[Z,rt]=(0,b.useState)(!1),it=(0,b.useRef)(null),at=(0,b.useRef)(0),[ot,st]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=it.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;st(e=>Math.abs(e-t)<1?e:t)});return t.observe(e),()=>t.disconnect()},[F]);let ct=ot>0&&ot<400,[lt,ut]=(0,b.useState)([]),[dt,ft]=(0,b.useState)(!1),[pt,mt]=(0,b.useState)(null),[ht,gt]=(0,b.useState)(`whatsapp`),_t=(0,b.useCallback)(e=>{if(y(),!a){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),H({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),H({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ee(a,e.downloadPath,e.downloadRoot??`data`),H({message:`Downloading ${e.name}`,failed:!1})},[a,y]);(0,b.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>H(null),2500);return()=>clearTimeout(e)},[V]);let vt=(0,b.useCallback)(async()=>{if(a){ye(!0),ve(null);try{let e=await M(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);ge((await e.json()).artefacts??[]),R(!0)}catch(e){let t=e instanceof Error?e.message:String(e);ve(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{ye(!1)}}},[a,M]),Q=(0,b.useCallback)(async()=>{if(!a)return null;let e=++at.current;K(!0),Pe(null);try{let t=await M(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===at.current?(Te(r),He(n.accountId??null),Oe(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===at.current&&Pe(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===at.current&&K(!1)}},[a,M]),yt=(0,b.useCallback)(async()=>{if(a){mt(null);try{let e=await M(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);ut((await e.json()).conversations??[]),ft(!0)}catch(e){let t=e instanceof Error?e.message:String(e);mt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[a,M]);(0,b.useEffect)(()=>{!a||G||Q()},[a,G,Q]),(0,b.useEffect)(()=>{if(!a)return;let e=null;return yt(),e=setInterval(()=>{yt()},Ie),()=>{e!==null&&clearInterval(e)}},[a,yt]),(0,b.useEffect)(()=>{if(!a)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Le))}function r(){e!==null&&(clearInterval(e),e=null)}function i(){document.hidden?r():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,i),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[a,Q]);let bt=(0,b.useMemo)(()=>{let e=new Map;for(let t of we)e.set(t,[]);for(let t of lt)e.get(t.channel)?.push(t);for(let t of we)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[lt]),xt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},St=()=>{C(null),I(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${_e?L.length:0} collapsed=${S}`),vt()},$=1.5,Ct=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),vt()},wt=()=>{C(null),I(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${G?W.length:0} collapsed=${S}`),G||Q()},Tt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Et=()=>{I(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${S}`),fe(),y()},Dt=e=>{A?.(),I(`whatsapp`),gt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${bt.get(e)?.length??0} collapsed=${S}`)},Ot=(0,b.useCallback)(async e=>{if(Ke.has(e.sessionId))return;qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Me(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(y(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),U(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),U({sessionId:e.sessionId,reason:r})}finally{qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[M,y,Ke]),kt=(0,b.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=je.length;n++){await new Promise(e=>setTimeout(e,je[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),At=(0,b.useCallback)(async()=>{if(!Z){rt(!0);try{let e=await M(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Me(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?kt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),U(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),U({sessionId:null,reason:t})}finally{rt(!1)}}},[M,Z,kt]),jt=(0,b.useCallback)((e,t)=>{e.stopPropagation(),Y(t)},[]),Mt=(0,b.useCallback)(async e=>{if(!Ue.has(e.sessionId)){We(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await M(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),H({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Te(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),H({message:`Delete failed: ${n}`,failed:!0})}finally{We(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[M,Ue,Q]),Nt=(0,b.useCallback)(async(e,t)=>{if(e.stopPropagation(),!Je.has(t.sessionId)){Ye(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),H({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),H({message:`Stop failed: ${n}`,failed:!0})}finally{Ye(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,Je,Q]),Pt=(0,b.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!Xe.has(t.sessionId)){Ze(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await M(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{Ze(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[M,Xe,Q]),Ft=(0,b.useCallback)(async e=>{let t=et.trim();if(!t){H({message:`Title can’t be empty`,failed:!0});return}if(t.length>Ae){H({message:`Title too long (max ${Ae})`,failed:!0});return}nt(!0);try{let n=await M(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),H({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),$e(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),H({message:`Rename failed: ${n}`,failed:!0})}finally{nt(!1)}},[M,et,Q]);return(0,x.jsxs)(`aside`,{className:`side`,children:[(0,x.jsx)(`div`,{className:`side-new-session-row`,children:(0,x.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:At,disabled:Z,"aria-busy":Z,children:[(0,x.jsx)(ue,{size:14}),(0,x.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,x.jsxs)(`nav`,{className:`side-nav`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),_(),y()},children:[(0,x.jsx)(O,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`People`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ie(),y()},children:[(0,x.jsx)(T,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Agents`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),te(),y()},children:[(0,x.jsx)(se,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:p().term}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),ne(),y()},children:[(0,x.jsx)(le,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${F===`artefacts`?` active`:``}`,onClick:St,children:[(0,x.jsx)(t,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${F===`sessions`?` active`:``}`,onClick:wt,children:[(0,x.jsx)(ce,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,x.jsx)(`span`,{className:`kbd`})]}),(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${F===`data`?` active`:``}`,onClick:Et,children:[(0,x.jsx)(u,{size:20,strokeWidth:$}),(0,x.jsx)(`span`,{className:`label`,children:`Data`}),(0,x.jsx)(`span`,{className:`kbd`})]}),dt&&we.filter(e=>bt.get(e).length>0).map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`nav-row${F===`whatsapp`&&ht===e?` active`:``}`,onClick:()=>Dt(e),children:[(0,x.jsx)(m,{channel:e,size:16}),(0,x.jsx)(`span`,{className:`label`,children:xt[e]}),(0,x.jsx)(`span`,{className:`kbd`})]},e)),pt&&(0,x.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,x.jsx)(`span`,{className:`label`,children:pt})})]}),F===`artefacts`&&(0,x.jsxs)(`div`,{className:`side-list`,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:`Artefacts`}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Ct,disabled:B,children:(0,x.jsx)(f,{size:12,className:B?`spinning`:void 0})}),(0,x.jsx)(`span`,{children:B?`…`:String(L.length)})]})]}),z&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:z}),_e&&!z&&L.length>0&&(()=>{let e=L.filter(e=>e.kind===`agent-template`).length,t=L.length-e;return(0,x.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:L.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,x.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${be===e.key?` active`:``}`,onClick:()=>xe(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,x.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),_e&&!z&&L.length===0&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),L.filter(e=>be===`all`?!0:be===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let n=e.kind===`agent-template`,r=n?T:t,i=Ne(e.updatedAt),a=e.downloadPath!==null;return(0,x.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>_t(e),disabled:!a,style:a?void 0:{cursor:`default`},title:a?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,x.jsx)(r,{size:14,className:`conv-icon`,"data-kind":n?`agent`:`file`,"aria-label":n?`agent template`:`file`}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsx)(`span`,{className:`conv-name-line`,children:(0,x.jsx)(`span`,{className:`conv-name`,children:e.name})}),i&&(0,x.jsx)(`span`,{className:`conv-timestamp`,children:i})]}),a&&(0,x.jsx)(c,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),F===`sessions`&&(()=>{let e=W.filter(e=>q?!0:!e.isSubagent).filter(e=>J?!0:!e.archived),t=W.some(e=>e.isSubagent),i=W.some(e=>e.archived);return(0,x.jsxs)(`div`,{className:`side-list`,ref:it,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:`Sessions`}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Tt,disabled:Fe,children:(0,x.jsx)(f,{size:12,className:Fe?`spinning`:void 0})}),(0,x.jsx)(`span`,{children:Fe?`…`:String(e.length)})]})]}),Ve&&(0,x.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,x.jsx)(`code`,{children:Ve})}),(t||i)&&(0,x.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,x.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${q?` active`:``}`,"aria-pressed":q,onClick:()=>ze(e=>!e),title:q?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),i&&(0,x.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${J?` active`:``}`,"aria-pressed":J,onClick:()=>Be(e=>!e),title:J?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),ke&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:ke}),G&&!ke&&e.length===0&&(0,x.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=Ne(e.startedAt),i=Ke.has(e.sessionId),a=Ue.has(e.sessionId),o=Je.has(e.sessionId),s=Xe.has(e.sessionId),c=i||a||o||s,l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,x.jsx)(g,{size:12}),busy:i,onClick:()=>{Ot(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,x.jsx)(E,{size:12}),onClick:()=>{window.location.assign(`/chat?session=${e.sessionId}`)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,x.jsx)(D,{size:12}),busy:o,onClick:t=>{Nt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,x.jsx)(w,{size:12}),busy:s,onClick:t=>{Pt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,x.jsx)(oe,{size:12}),busy:s,onClick:t=>{Pt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,x.jsx)(r,{size:12}),busy:tt&&Qe===e.sessionId,onClick:t=>{t.stopPropagation(),$e(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,x.jsx)(n,{size:12}),danger:!0,busy:a,onClick:t=>{jt(t,e)}},pe({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,x.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,x.jsxs)(`div`,{className:`conv-main-static`,children:[(0,x.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,x.jsx)(re,{channel:e.channel,size:13}),Qe===e.sessionId?(0,x.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:et,disabled:tt,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Ft(e)):t.key===`Escape`&&(t.preventDefault(),$e(null),X(``))},onBlur:()=>{Qe===e.sessionId&&!tt&&($e(null),X(``))}}):(0,x.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,x.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,x.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,x.jsxs)(`span`,{children:[` · `,t]})]})]})]}),(0,x.jsx)(he,{actions:l,disabled:c,collapsed:ct})]},e.sessionId)})]})})(),F===`whatsapp`&&(0,x.jsxs)(`div`,{className:`side-list`,children:[(0,x.jsxs)(`div`,{className:`group-head`,children:[(0,x.jsx)(`span`,{children:xt[ht]}),(0,x.jsxs)(`span`,{className:`group-head-meta`,children:[(0,x.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{yt()},children:(0,x.jsx)(f,{size:12})}),(0,x.jsx)(`span`,{children:String(bt.get(ht).length)})]})]}),bt.get(ht).map(e=>{let t=Ne(e.lastMessageAt);return(0,x.jsxs)(`div`,{className:`conv conv-with-actions${ae===e.sessionId?` active`:``}`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{C(e),y()},title:e.title,children:[(0,x.jsx)(m,{channel:e.channel,size:14}),(0,x.jsxs)(`span`,{className:`conv-stack`,children:[(0,x.jsxs)(`span`,{className:`conv-name-line`,children:[(0,x.jsx)(`span`,{className:`conv-name`,children:h(e)}),e.role===`public`&&(0,x.jsx)(`span`,{className:`conv-tag conv-tag-public`,children:`Public`})]}),t&&(0,x.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),(0,x.jsx)(he,{actions:[pe({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1,collapsed:ct})]},e.sessionId)})]}),(0,x.jsx)(Re,{}),(0,x.jsxs)(`div`,{className:`side-foot`,children:[(0,x.jsx)(`div`,{className:`avatar`,children:l?(0,x.jsx)(`img`,{src:l,alt:N}):P}),(0,x.jsxs)(`div`,{className:`who`,children:[(0,x.jsx)(`span`,{className:`name`,children:N}),(0,x.jsx)(`span`,{className:`role`,children:o??`operator`})]})]}),V&&(0,x.jsx)(`div`,{className:`copy-toast${V.failed?` copy-toast-failed`:``}`,role:`status`,children:V.message}),(0,x.jsx)(De,{error:Se,onClose:()=>U(null)}),(0,x.jsx)(Ee,{target:Ge,onCancel:()=>Y(null),onConfirm:()=>{let e=Ge;Y(null),e&&Mt(e)}})]})}var Fe=5e3,Ie=3e4,Le=3e4;function Re(){let[e,t]=(0,b.useState)(null);if((0,b.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},Fe))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,x.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,x.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,x.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,x.jsx)(`div`,{className:`system-stats__bar`,children:(0,x.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,x.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,x.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,x.jsx)(`div`,{className:`system-stats__bar`,children:(0,x.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var K=`admin-sidebar-collapsed`,q=`admin-sidebar-drawer-open`;function ze(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(K)===`1`}catch{return!1}}function J(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(K,`1`):window.sessionStorage.removeItem(K)}catch{}}function Be(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(q)===`1`}catch{return!1}}function Ve(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(q,`1`):window.sessionStorage.removeItem(q)}catch{}}var He=720;function Ue(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.sessionId)}&projectDir=${encodeURIComponent(t.projectDir)}`}}function We(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function Ge(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`projectDir`);return!r||!i?null:{sessionId:r,projectDir:i,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`admin`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,rowType:`session`}}function Y(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function Ke(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function qe(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,userName:s,userAvatar:c,role:l,onOpenConversations:u,children:d,footer:f}=e,{subAccounts:m,activeAccountId:h,switching:g,switchAccount:ee}=ne(t),[_,re]=(0,b.useState)(()=>ze()),[v,y]=(0,b.useState)(()=>Be()),[S,ae]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${He}px)`).matches),[C,w]=(0,b.useState)(()=>typeof window>`u`||Y(window.location.pathname,window.location.search)?null:Ge(window.location.pathname,window.location.search)),[oe]=(0,b.useState)(()=>C!==null),[T,se]=(0,b.useState)(()=>typeof window>`u`?!1:Y(window.location.pathname,window.location.search)),[ce]=(0,b.useState)(()=>T);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${He}px)`),t=e=>ae(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let le=(0,b.useCallback)(e=>{J(e),re(e)},[]),E=(0,b.useCallback)(e=>{Ve(e),y(e)},[]);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${_} drawer=${v}`)},[]),(0,b.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ sessionId=${C.sessionId.slice(0,8)}`),window.history.replaceState(null,``,`/`))},[]),(0,b.useEffect)(()=>{typeof window>`u`||!T||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ue=(0,b.useCallback)(e=>{if(se(!1),e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Ue(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),de=(0,b.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=We(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}w(null),se(!0)},[]),D=S?v:!_,O=(0,b.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${He}px)`).matches){let e=v;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),E(!e)}else{let e=_;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),le(!e)}},[_,v,le,E]),k=(0,b.useCallback)(e=>{let t=Ke(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),[fe,A]=(0,b.useState)(`chat`),[j,pe]=(0,b.useState)([]);(0,b.useEffect)(()=>{if(r!==`operator`||!t)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(t)}&includePersistedOnly=1`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||pe(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[r,t]);let me=(0,b.useMemo)(()=>[...new Set(j.map(e=>e.channel))],[j]),N={collapsed:_,mobileDrawerOpen:v,sidebarOpen:D,onToggleSidebar:O,setMobileDrawerOpen:E,selectedWhatsapp:C,onClearWhatsapp:()=>w(null),dataOpen:T};return r===`operator`?(0,x.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,x.jsx)(ie,{businessName:n,variant:r,onNavigate:k,conversationsCount:j.length,conversationsChannels:me,onOpenConversations:()=>A(`conversations`),onToggleSidebar:O,sidebarOpen:D,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:m,activeAccountId:h,switchingAccount:g,onSwitchAccount:ee}),(0,x.jsx)(`div`,{className:`platform platform-operator`,children:fe===`conversations`?(0,x.jsx)(te,{conversations:j,sessionKey:t??``,onBack:()=>A(`chat`)}):typeof d==`function`?d(N):d}),f]}):(0,x.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,x.jsx)(ie,{businessName:n,variant:r,onNavigate:k,onOpenConversations:u,onToggleSidebar:O,sidebarOpen:D,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:m,activeAccountId:h,switchingAccount:g,onSwitchAccount:ee}),(0,x.jsxs)(`div`,{className:`platform${v?` menu-open`:``}${_?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,x.jsx)(Pe,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,onSelectProjects:()=>{window.location.href=`/graph?label=${p().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>E(!1),collapsed:_,mobileDrawerOpen:v,selectedWhatsappId:C?.sessionId??null,onSelectWhatsappConversation:ue,initialWhatsappSurface:oe,onSelectData:de,onCloseData:()=>se(!1),initialDataSurface:ce}),!S&&(0,x.jsx)(M,{}),typeof d==`function`?d(N):d]}),v&&(0,x.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>E(!1)}),f]})}export{w as _,I as a,z as c,D as d,de as f,oe as g,T as h,Te as i,ge as l,le as m,Me as n,P as o,ue as p,Oe as r,F as s,qe as t,O as u,C as v,y};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{G as t,H as n,b as r,o as i,q as a}from"./useSubAccountSwitcher-DAgBUed_.js";import{n as o,t as s}from"./AdminLoginScreens-B9u1V35g.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-C2UXTLSB.js";import"./Checkbox-B2g2SCpw.js";import{n as u}from"./page-DBkTNfei.js";import"./graph-labels-DFdBydWC.js";var d=t(),f=e(a(),1),p=n();function m({onOpen:e}){return(0,p.jsx)(`footer`,{className:`admin-footer`,children:(0,p.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,p.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,p.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function h(){let e=o(),[t,n]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,f.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),d=(0,f.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,p.jsx)(r,{cacheKey:e.cacheKey,onSessionExpired:d,surface:`chat`,children:(0,p.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(m,{onOpen:a}),(0,p.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,p.jsx)(p.Fragment,{children:t.dataOpen&&e.cacheKey?(0,p.jsx)(u,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?(0,p.jsx)(i,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,p.jsx)(`main`,{})})})}):(0,p.jsx)(s,{auth:e})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(h,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{C as t,E as n,F as r,G as i,H as a,L as o,N as s,O as c,S as l,W as u,b as d,j as f,q as p}from"./useSubAccountSwitcher-DAgBUed_.js";import{t as m,u as h,y as g}from"./AdminShell-C2UXTLSB.js";var _=o(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=o(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=o(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=o(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),S=o(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),C=i(),w=e(p(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function j(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function M(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function N(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function P(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function F(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var I=a(),L=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],R=3;function z(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,I.jsxs)(`div`,{className:`cal-month`,children:[(0,I.jsx)(`div`,{className:`cal-weekday-row`,children:L.map(e=>(0,I.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,I.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>P(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=P(e,a);return(0,I.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,I.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,R).map(e=>(0,I.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...F(e,n),children:[!e.isAllDay&&(0,I.jsx)(`span`,{className:`cal-chip-time`,children:z(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>R&&(0,I.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-R,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsx)(`div`,{className:`cal-day-col`,children:(0,I.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,I.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=U(n),o=P(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,I.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...F(t,r),children:[(0,I.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,I.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,I.jsxs)(`div`,{className:`cal-timed`,children:[(0,I.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,I.jsxs)(`div`,{className:`cal-day-head${P(e,i)?` cal-day-head-today`:``}`,children:[(0,I.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,I.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e)).map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,I.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,I.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var ee=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,I.jsx)(`div`,{className:`cal-year`,children:(0,I.jsx)(`div`,{className:`cal-year-grid`,children:j(e).map(e=>{let t=k(e),a=e.getMonth();return(0,I.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,I.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,I.jsx)(`div`,{className:`cal-mini-weekrow`,children:ee.map((e,t)=>(0,I.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,I.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=P(e,r),o=!t&&i.has(te(e));return(0,I.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,I.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,I.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,I.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,I.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:r,onClose:i,onSaved:a,onDeleted:o}){let u=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[g,v]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,j]=(0,w.useState)(e.title??``),[M,N]=(0,w.useState)(ie(e.startsAt)),[P,F]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[L,R]=(0,w.useState)(e.location??``),[z,B]=(0,w.useState)(e.privateNote??``),[V,H]=(0,w.useState)(``),[U,W]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,i]);let G=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?ae(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=L.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,L,z,O]),K=(0,w.useCallback)(async()=>{let t=G();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();k(i.meeting),a(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[r,G,e.meetingId,a]),q=(0,w.useCallback)(async()=>{let t=V.trim(),n=U.trim();if(!(!t&&!n)){T(!0),D(null);try{let i=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:n||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();k(o.meeting),a(o.meeting),H(``),W(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[r,V,U,e.meetingId,a]),J=(0,w.useCallback)(async t=>{let n=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),a(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[r,e.meetingId,a]),Y=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);o(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[r,e.meetingId,o]),X=(0,w.useCallback)(async t=>{v(!1),T(!0),D(null);try{let n=await r(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.blob(),a=se(n.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[r,e.meetingId]),Z=re[e.kind??`meeting`],ee=V.trim().length>0||U.trim().length>0;return(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||i()},children:(0,I.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsx)(`span`,{className:`cal-modal-kind`,children:Z}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,I.jsx)(l,{size:16})})]}),!d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(b,{size:14}),(0,I.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(h,{size:14}),(0,I.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,I.jsx)(`div`,{className:`cal-attendee-row`,children:(0,I.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(x,{size:14}),(0,I.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(_,{size:14}),(0,I.jsx)(`span`,{children:Z})]})]}),d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Title`}),(0,I.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Start`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`End`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Location`}),(0,I.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),disabled:C})]}),(0,I.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Attendees`}),(0,I.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,I.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,I.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,I.jsx)(le,{a:e}),(0,I.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>J(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,I.jsx)(l,{size:13})})]},ce(e,t)))]}),(0,I.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,I.jsx)(`input`,{type:`text`,placeholder:`Name`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,I.jsx)(`input`,{type:`email`,placeholder:`Email`,value:U,onChange:e=>W(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:q,disabled:C||!ee,"aria-label":`Add attendee`,children:C?(0,I.jsx)(c,{size:13,className:`spin`}):(0,I.jsx)(S,{size:13})})]})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Private note`}),(0,I.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>B(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,I.jsx)(`div`,{className:`cal-modal-error`,children:E}),u&&(0,I.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!g&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,I.jsx)(n,{size:14}),` Edit`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,I.jsx)(t,{size:14}),` Delete`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?v(!0):X(!1)},disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):(0,I.jsx)(s,{size:14}),` Download`]})]}),g&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>X(!0),disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Yes`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>X(!1),disabled:C,children:`No`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:C,children:`Cancel`})]}),d&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:K,disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Save`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Y,disabled:C,children:[C?(0,I.jsx)(c,{size:14,className:`spin`}):null,` Delete`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=M(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(void 0),[o,s]=(0,w.useState)(null),[l,u]=(0,w.useState)(void 0),[f,p]=(0,w.useState)(null),[h,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await g();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,I.jsx)(d,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,I.jsx)(m,{cacheKey:e,businessName:i,sessionId:o,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:f,role:h,children:(0,I.jsx)(me,{cacheKey:e})})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-loading`,children:[(0,I.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=u({initialCacheKey:e,surface:`calendar`}),[i,a]=(0,w.useState)(`month`),[o,s]=(0,w.useState)(()=>new Date),[l,d]=(0,w.useState)([]),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(null),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&S(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:r}=M(i,o);return m(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(r.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();d(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),d([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[i,o,n,t]);let C=(0,w.useCallback)(()=>s(new Date),[]),T=(0,w.useCallback)(()=>s(e=>N(i,e,-1)),[i]),E=(0,w.useCallback)(()=>s(e=>N(i,e,1)),[i]),D=(0,w.useCallback)(e=>{s(e),a(`month`)},[]);(0,w.useEffect)(()=>{b(null)},[i,o]);let O=(0,w.useCallback)(e=>{d(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),k=(0,w.useCallback)(e=>{d(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsxs)(`header`,{className:`cal-header`,children:[(0,I.jsxs)(`div`,{className:`cal-title`,children:[(0,I.jsx)(_,{size:20}),` Calendar`]}),(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:C,children:`Today`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Previous`,children:(0,I.jsx)(r,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:E,"aria-label":`Next`,children:(0,I.jsx)(v,{size:18})}),(0,I.jsx)(`span`,{className:`cal-range-label`,children:fe(i,o)}),p&&(0,I.jsx)(c,{size:16,className:`spin`})]}),(0,I.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===i?` cal-view-btn-active`:``}`,onClick:()=>a(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,I.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(f,{size:14}),` Booking page`]})]}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),i===`day`&&(0,I.jsx)(Z,{anchor:o,meetings:l,onSelect:b}),i===`week`&&(0,I.jsx)(J,{anchor:o,meetings:l,onSelect:b}),i===`month`&&(0,I.jsx)(B,{anchor:o,meetings:l,onSelect:b}),i===`year`&&(0,I.jsx)(ne,{anchor:o,meetings:l,onPickMonth:D})]}),y&&(0,I.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:O,onDeleted:k})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(pe,{}));
@@ -1 +0,0 @@
1
- import{G as e,H as t}from"./useSubAccountSwitcher-DAgBUed_.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-C2UXTLSB.js";import{n}from"./page-BMeSKYGZ.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{G as e,H as t}from"./useSubAccountSwitcher-DAgBUed_.js";import{t as n}from"./page-DBkTNfei.js";import"./graph-labels-DFdBydWC.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{G as t,H as n,q as r}from"./useSubAccountSwitcher-DAgBUed_.js";import{n as i,t as a}from"./AdminLoginScreens-B9u1V35g.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-C2UXTLSB.js";import"./Checkbox-B2g2SCpw.js";import{t as o}from"./page-BMeSKYGZ.js";var s=t(),c=e(r(),1),l=n();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState,console.info(`[operator-ui] op=auth-gate state=${e.appState}`))},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));