@rubytech/create-maxy-code 0.1.47 → 0.1.49
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/dist/__tests__/premium-mcp-discover.test.js +85 -0
- package/dist/index.js +17 -0
- package/dist/lib/premium-mcp-discover.js +34 -0
- package/package.json +1 -1
- package/payload/platform/plugins/docs/references/deployment.md +2 -0
- package/payload/server/public/assets/admin-DBuCWSPS.js +216 -0
- package/payload/server/public/assets/{data-DwQ7ZEyy.js → data-BeblX4m4.js} +1 -1
- package/payload/server/public/assets/{graph-CwZkD6GX.js → graph-ZuBiYril.js} +1 -1
- package/payload/server/public/assets/graph-labels-CnbJR6cp.js +1 -0
- package/payload/server/public/assets/{page-SOCqJGlV.js → page-DDyny08O.js} +2 -2
- package/payload/server/public/assets/{page-CQ7ELqGs.js → page-nAY64ID7.js} +1 -1
- package/payload/server/public/data.html +3 -3
- package/payload/server/public/graph.html +3 -3
- package/payload/server/public/index.html +4 -4
- package/payload/server/public/assets/admin-SyUHjvNs.js +0 -216
- package/payload/server/public/assets/graph-labels-CVkmOHhw.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,c as n,d as r,f as i,h as a,l as o,o as s,r as c,s as l,t as u,u as d}from"./brand-Dln107gD.js";var f=i(`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`}]]),p=i(`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`}]]),m=i(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),h=i(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),g=i(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),_=i(`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`}]]),v=i(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),y=i(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),ee=i(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),te=i(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),b=i(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),x=i(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),S=i(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),C=i(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),w=i(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),ne=i(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),T=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),E=i(`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`}]]),re=i(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),D=e(a(),1),O=s(),k=`maxy-shell-side-px`;function A(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function j(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-A());return Math.min(Math.max(e,248),n)}function ie(){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)&&t>=248)return j(t)}catch{}return 264}function ae({targetSelector:e=`.platform`}){let t=(0,D.useRef)(null),[n,r]=(0,D.useState)(()=>ie()),i=(0,D.useRef)(n);(0,D.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,D.useCallback)(()=>{r(e=>{let t=j(e);return t===e?e:t})},[]);(0,D.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(j(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(k,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=j(264);r(e);try{window.localStorage.removeItem(k)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,O.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}function M(e,t,n,r){let i=e===`pane`?`pane-action`:`sidebar-${t}`;console.info(`[admin-ui] ${i} sessionId=${n.slice(0,8)} action=${t} outcome=${r}`)}var N=/session_([A-Za-z0-9_-]+)/;function P(e){if(!e)return null;let t=e.match(N);return t?t[1]:null}async function F(e,t,n,r,i){let a=P(r)??`unknown`,o=e=>e.slice(0,8),s=t===`pane`?`pane-action action=resume-archive`:`sidebar-resume-archive`,c;try{let t=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(n)}/archive?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:`archive`})});c=t.ok?`ok`:t.status===409?`409`:`error`;let r=`[admin-ui] ${s} sourceSessionId=${o(n)} newSessionId=${o(a)} result=${c}`;c===`error`?console.error(r):console.info(r)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] ${s} sourceSessionId=${o(n)} newSessionId=${o(a)} result=error detail=${t}`)}finally{i.refetch()}}function oe(e,t,n=`pane`){let[r,i]=(0,D.useState)(null),a=(0,D.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`resume`);try{let i=await fetch(`/api/admin/claude-sessions/resume?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({claudeSessionId:r,channel:`browser`})}),a=await i.json();if(!i.ok||!(`sessionId`in a)){let e=a.error??`POST returned ${i.status}`;return M(n,`resume`,r,String(i.status)),{ok:!1,error:e}}return t.setSessions(e=>[a,...e.filter(e=>e.sessionId!==r)]),M(n,`resume`,r,`200`),F(e,n,r,a.url,t),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return M(n,`resume`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{i(null)}},[e,t,n]),o=(0,D.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`end`);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}?session_key=${encodeURIComponent(e)}`,{method:`DELETE`});if(!i.ok){let e=await i.text().catch(()=>``);return M(n,`end`,r,String(i.status)),t.refetch(),{ok:!1,error:`DELETE ${i.status} ${e.slice(0,200)}`}}return M(n,`end`,r,`200`),t.refetch(),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return M(n,`end`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{i(null)}},[e,t,n]),s=(0,D.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`purge`);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}?purge=1&session_key=${encodeURIComponent(e)}`,{method:`DELETE`});if(!i.ok){let e=await i.json().catch(()=>({})),t=e.detail||e.error||`DELETE ?purge=1 ${i.status}`;return M(n,`purge`,r,String(i.status)),{ok:!1,error:t}}return t.setSessions(e=>e.filter(e=>e.sessionId!==r)),M(n,`purge`,r,`200`),t.refetch(),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return M(n,`purge`,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]),c=(0,D.useCallback)(async(r,a)=>{if(!e)return{ok:!1,error:`no-cache-key`};i(a);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}/archive?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:a})});if(!i.ok){let e=await i.json().catch(()=>({})),t=e.detail||e.error||`POST /archive ${i.status}`;return M(n,a,r,String(i.status)),{ok:!1,error:t}}return a===`archive`&&t.setSessions(e=>e.filter(e=>e.sessionId!==r)),t.refetch(),M(n,a,r,`200`),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return M(n,a,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]);return{inFlight:r,resume:a,end:o,purge:s,archive:(0,D.useCallback)(e=>c(e,`archive`),[c]),unarchive:(0,D.useCallback)(e=>c(e,`unarchive`),[c])}}function I(e){return`code.session.pinned.${e}`}function L(e){if(typeof window>`u`)return new Set;try{let t=window.localStorage.getItem(I(e));if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function R(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(I(e),JSON.stringify([...t]))}catch{}}function se(e){let[t,n]=(0,D.useState)(()=>L(e));(0,D.useEffect)(()=>{n(L(e))},[e]);let r=(0,D.useCallback)(t=>{n(n=>{let r=new Set(n);return r.has(t)?r.delete(t):r.add(t),R(e,r),r})},[e]);return{pinned:t,isPinned:(0,D.useCallback)(e=>t.has(e),[t]),togglePin:r}}function ce(e){let{businessName:t,cacheKey:n,conversationId:i,onLaunchBrowser:a,onNavigate:s,onToggleSidebar:d,sidebarOpen:f,onLogout:p,browserLaunching:_}=e,[x,S]=(0,D.useState)(!1),C=(0,D.useRef)(null),ne=(0,D.useRef)(null),[T,E]=(0,D.useState)(null),[k,A]=(0,D.useState)(!1),[j,ie]=(0,D.useState)(null),[ae,M]=(0,D.useState)(null),[N,P]=(0,D.useState)(null),[F,oe]=(0,D.useState)(``);(0,D.useEffect)(()=>{oe(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,D.useEffect)(()=>{if(!x)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]),(0,D.useEffect)(()=>{if(!x)return;let e=e=>{e.key===`Escape`&&S(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x]),(0,D.useEffect)(()=>{x&&ne.current?.focus()},[x]),(0,D.useEffect)(()=>{if(!x)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||P(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[x]);let I=(0,D.useCallback)(()=>{S(e=>{let t=!e;return t&&console.info(`[admin-ui] header-menu-open`),t})},[]),L=(0,D.useCallback)(()=>{S(!1),a()},[a]),R=(0,D.useCallback)(e=>{S(!1),s(e)},[s]),se=(0,D.useCallback)(async()=>{if(T!==null){E(null),M(null);return}A(!0),ie(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);E((await e.json()).agents??[])}catch(e){console.error(`[admin/agents] list failed:`,e),ie(e instanceof Error?e.message:String(e)),E([])}finally{A(!1)}},[T]),ce=(0,D.useCallback)(e=>{M(null),E(t=>t?.filter(t=>t.slug!==e)??null),fetch(`/api/admin/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},[]),le=(0,D.useCallback)(async()=>{if(S(!1),!n){console.warn(`[admin-ui] header-menu-report-turn cacheKey=null — skipping POST`);return}try{let e=await fetch(`/api/admin/failure-report`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionKey:n,conversationId:i??``,lastUserMessageId:``,lastAssistantMessageId:``,clickTs:new Date().toISOString(),clientSnapshot:{sseReadyState:``,lastEventType:``,lastAppliedMessageId:``}})});console.info(`[admin-ui] header-menu-report-turn ok=${e.ok} status=${e.status}`)}catch(e){console.error(`[admin-ui] header-menu-report-turn failed:`,e)}},[n,i]),z=(0,D.useCallback)(()=>{S(!1),p()},[p]),ue=t||u.productName;return(0,O.jsxs)(`header`,{className:`admin-header`,children:[(0,O.jsx)(`button`,{type:`button`,className:`admin-sidebar-toggle`,"aria-label":f?`Hide sidebar`:`Show sidebar`,title:f?`Hide sidebar`:`Show sidebar`,"aria-expanded":f,onClick:d,children:f?(0,O.jsx)(te,{size:20}):(0,O.jsx)(b,{size:20})}),(0,O.jsxs)(`div`,{className:`chat-header-label`,children:[(0,O.jsx)(`span`,{className:`chat-logo-btn`,"aria-hidden":`true`,children:(0,O.jsx)(`img`,{src:c,alt:``,className:`chat-logo`})}),(0,O.jsx)(`h1`,{className:`chat-tagline`,children:ue})]}),(0,O.jsxs)(`div`,{className:`chat-burger-wrap`,ref:C,children:[(0,O.jsx)(`button`,{type:`button`,className:`admin-burger`,onClick:I,"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":x,children:(0,O.jsx)(ee,{size:20})}),x&&(0,O.jsxs)(`div`,{className:`admin-menu`,role:`menu`,children:[(0,O.jsxs)(`button`,{ref:ne,type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:L,disabled:_,children:[(0,O.jsx)(o,{size:14}),` Browser`,_&&(0,O.jsx)(v,{size:12,className:`spin`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>R(`data`),children:[(0,O.jsx)(m,{size:14}),` Data`]}),(0,O.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>R(`graph`),children:[(0,O.jsx)(w,{size:14}),` Graph`]}),(0,O.jsx)(`div`,{className:`chat-menu-divider`}),(0,O.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:se,children:[(0,O.jsx)(h,{size:14}),` Public`,k&&(0,O.jsx)(v,{size:12,className:`spin`})]}),T!==null&&(0,O.jsxs)(`div`,{className:`chat-menu-agents`,children:[j&&(0,O.jsx)(`span`,{className:`chat-menu-agent-error`,children:j}),T.length===0&&!j&&(0,O.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),T.map(e=>(0,O.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,O.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,O.jsxs)(`span`,{className:`agent-text`,children:[(0,O.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,O.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),ae===e.slug?(0,O.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,O.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>ce(e.slug),children:(0,O.jsx)(r,{size:12})}),(0,O.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>M(null),children:(0,O.jsx)(re,{size:12})})]}):(0,O.jsxs)(`span`,{className:`agent-actions`,children:[(0,O.jsx)(`a`,{href:`${F}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>S(!1),children:(0,O.jsx)(h,{size:12})}),(0,O.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>M(e.slug),children:(0,O.jsx)(l,{size:12})})]})]},e.slug))]}),(0,O.jsx)(`div`,{className:`chat-menu-divider`}),(0,O.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,O.jsx)(g,{size:14}),(0,O.jsxs)(`span`,{className:`version-installed`,children:[N?`v${N.installed}`:`…`,N&&!N.updateAvailable&&(0,O.jsx)(`span`,{className:`version-uptodate-dot`}),N?.updateAvailable&&(0,O.jsx)(`span`,{className:`version-update-dot`})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,"data-testid":`report-turn`,onClick:le,children:[(0,O.jsx)(g,{size:14}),` Report this turn`]}),(0,O.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:z,children:[(0,O.jsx)(y,{size:14}),` Log out`]})]})]})]})}var le=`maxy-admin-session`,z=typeof BroadcastChannel<`u`;function ue(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`rotation`&&typeof t.newKey==`string`&&t.newKey.length>0&&(t.surface===`chat`||t.surface===`graph`||t.surface===`data`||t.surface===`sessions`)&&typeof t.ts==`number`}function B(e){if(!z)return()=>{};let t=new BroadcastChannel(le),n=t=>{if(!ue(t.data)){console.warn(`[admin-session-broadcast] outcome=received-malformed payload=${JSON.stringify(t.data)}`);return}e(t.data)};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var de=`maxy-admin-session-key`;function V(e,t){return`${e}${e.includes(`?`)?`&`:`?`}session_key=${encodeURIComponent(t)}`}async function H(e){let t;try{t=await e.clone().json()}catch{return`parse-failed`}if(typeof t!=`object`||!t)return`unknown-401`;let n=t.code;return n===`session-missing`||n===`session-not-registered`||n===`session-expired-age`||n===`grant-expired`?n:`unknown-401`}function fe(){try{return sessionStorage.getItem(de)}catch{return null}}function pe(e){let{initialCacheKey:t,surface:n}=e,[r,i]=(0,D.useState)(t),a=(0,D.useRef)(t);(0,D.useEffect)(()=>{a.current=r},[r]),(0,D.useEffect)(()=>{t!==a.current&&(i(t),a.current=t,s(e=>e+1))},[t]);let[o,s]=(0,D.useState)(0),[c,l]=(0,D.useState)(null);(0,D.useEffect)(()=>B(e=>{let t=a.current.slice(0,8),r=e.newKey.slice(0,8);e.newKey!==a.current&&(console.log(`[admin-session-broadcast] outcome=received oldKey=${t} newKey=${r} surface=${n} senderSurface=${e.surface}`),i(e.newKey),s(e=>e+1),l(null))}),[n]);let u=(0,D.useCallback)(()=>{try{sessionStorage.removeItem(de)}catch{}window.location.href=`/`},[]);return{adminFetch:(0,D.useCallback)(async(e,t)=>{let r=a.current,o=V(e,r),c=await fetch(o,t);if(c.status!==401)return c;let d=await H(c);if(d===`session-missing`)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=${d} surface=${n} path=${e}`),u(),c;if(d!==`session-not-registered`)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=${d} surface=${n} path=${e}`),l({message:`Your admin session has expired. Click to reload and sign in.`,reason:d}),c;let f=fe();if(!f||f===r)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=session-not-registered-no-fresh-key surface=${n} path=${e}`),l({message:`Your admin session was renewed in another tab. Click to reload.`,reason:`session-not-registered`}),c;i(f),a.current=f,s(e=>e+1),console.log(`[useAdminFetch] outcome=retry-after-rotation oldKey=${r.slice(0,8)} newKey=${f.slice(0,8)} surface=${n} path=${e}`);let p=V(e,f),m=await fetch(p,t);return m.status===401&&(console.warn(`[useAdminFetch] outcome=redirect-to-login reason=second-401-after-retry surface=${n} path=${e}`),l({message:`Your admin session has expired. Click to reload and sign in.`,reason:`session-not-registered`})),m},[u,n]),cacheKey:r,sessionRefetchNonce:o,banner:c,reloadToLogin:u}}var me=`/api/admin/claude-sessions/events`,U=`admin-session-list-view`,W=`admin-session-list-include-subagents`,G=`admin-session-list-include-background`;function he(e){return e===`active`||e===`archived`||e===`all`}function K(){let e={rows:[],view:`active`,includeBackground:!1,connected:!1},t=new Map,n=new Set,r=null,i=null,a=0,o=0,s=null,c=!1,l=!1;function u(){let n=[...t.values()].sort((e,t)=>t.updatedAt===e.updatedAt?e.sessionId<t.sessionId?-1:1:t.updatedAt-e.updatedAt);e={...e,rows:n}}function d(){for(let e of n)e()}function f(e,n){if(e===`row-removed`){let e=n?.sessionId;if(typeof e!=`string`||!t.delete(e))return;u(),d();return}let r=n;if(typeof r.sessionId!=`string`)return;let i={sessionId:r.sessionId,live:r.live===!0,status:r.status===`busy`?`busy`:r.status===`idle`?`idle`:`gone`,agentLabel:typeof r.agentLabel==`string`&&r.agentLabel.length>0?r.agentLabel:null,bridgeSessionId:typeof r.bridgeSessionId==`string`?r.bridgeSessionId:null,cwd:typeof r.cwd==`string`?r.cwd:null,firstPrompt:typeof r.firstPrompt==`string`?r.firstPrompt:r.sessionId.slice(0,8),updatedAt:typeof r.updatedAt==`number`?r.updatedAt:0};t.set(i.sessionId,i),u(),d()}function p(t){if(r&&s===t||(r&&=(r.close(),null),!t))return;s=t,c=!1,l=!1;let n=V(me,t);try{r=new EventSource(n)}catch(e){console.error(`[admin-ui] session-row-store EventSource construct failed:`,e),h(`auto`);return}r.addEventListener(`open`,()=>{c=!0,a=0,e={...e,connected:!0},d(),console.info(`[admin-ui] session-row-store connected events-received=${o}`)});for(let e of[`row-created`,`row-updated`,`row-archived`,`row-removed`])r.addEventListener(e,t=>{o+=1;try{f(e,JSON.parse(t.data))}catch(t){console.error(`[admin-ui] session-row-store parse failed kind=${e}:`,t)}});r.addEventListener(`error`,()=>{r&&=(r.close(),null),e={...e,connected:!1},d(),!c&&!l&&(l=!0,m(n)),h(`auto`)})}async function m(e){let t=a+1,n=0,r=`unknown`;try{let t=await fetch(e,{method:`GET`});n=t.status,r=t.status>=400&&t.status<500?await H(t):`unknown`}catch(e){console.error(`[admin-ui] session-row-store sse-error-probe-failed:`,e);return}console.error(`[admin-ui] session-row-store sse-error status=${n} code=${r} attempt=${t}`)}function h(e){if(i)return;a+=1;let t=Math.min(1e3*2**Math.min(a,5),3e4);console.info(`[admin-ui] session-row-store reconnect trigger=${e} attempt=${a} delay-ms=${t}`),i=setTimeout(()=>{i=null,s&&p(s)},t)}function g(){i&&=(clearTimeout(i),null),a=0,r&&=(r.close(),null),console.info(`[admin-ui] session-row-store reconnect trigger=manual attempt=0 delay-ms=0`),s&&p(s)}function _(){if(!(typeof window>`u`))try{let t=window.localStorage.getItem(U);he(t)&&(e={...e,view:t});let n=window.localStorage.getItem(W);if(n===null){let e=window.localStorage.getItem(G);e!==null&&(window.localStorage.setItem(W,e),window.localStorage.removeItem(G),n=e,console.info(`[admin-ui] session-list-storage-migrated from=${G} to=${W} value=${e}`))}n===`1`&&(e={...e,includeBackground:!0})}catch{}}function v(t){e={...e,view:t};try{window.localStorage.setItem(U,t)}catch{}d()}function y(t){e={...e,includeBackground:t};try{window.localStorage.setItem(W,t?`1`:`0`)}catch{}d()}function ee(e){return n.add(e),()=>{n.delete(e)}}function te(){return e}function b(){r&&=(r.close(),null),i&&=(clearTimeout(i),null),s=null,e={...e,connected:!1}}function x(e,t){f(e,t)}function S(t){e={...e,connected:t},d()}function C(){t.clear(),u(),d()}function w(e){let n=new Set(e),r=0;for(let e of[...t.keys()])n.has(e)||(t.delete(e),r+=1);r!==0&&(console.info(`[admin-ui] session-row-store reconcile evicted=${r} kept=${t.size}`),u(),d())}return _(),{subscribe:ee,getSnapshot:te,connect:p,disconnect:b,setView:v,setIncludeBackground:y,reconnectNow:g,reconcileFromList:w,_injectEventForTesting:x,_setConnectedForTesting:S,_clearRowsForTesting:C}}var q=K();q._injectEventForTesting,q.connect,q._setConnectedForTesting,q.getSnapshot,q.reconcileFromList;function ge(e){let t=(0,D.useSyncExternalStore)(q.subscribe,q.getSnapshot,q.getSnapshot);(0,D.useEffect)(()=>{e&&q.connect(e)},[e]);let n=(0,D.useCallback)(e=>q.setView(e),[]),r=(0,D.useCallback)(e=>q.setIncludeBackground(e),[]),i=(0,D.useCallback)(()=>q.reconnectNow(),[]),a=(0,D.useCallback)(e=>q.reconcileFromList(e),[]);return{rows:t.rows,view:t.view,includeBackground:t.includeBackground,connected:t.connected,setView:n,setIncludeBackground:r,reconnectNow:i,reconcileFromList:a}}function _e(e,t,n){return e.filter(e=>!(t===`active`&&!e.live||t===`archived`&&e.live||!n&&e.agentLabel!==null&&e.agentLabel!==`admin`))}var J=(0,D.forwardRef)(function(e,t){let{businessName:i,cacheKey:a,role:o,userName:s,userAvatar:c,sessions:m,sessionsLoading:g,sessionsError:y,ensureSessionsLoaded:ee,refetchSessions:te,onSelectArtefact:b,onSelectProjects:C,onSelectPeople:w,onSelectTasks:re,onSelectAgents:k,onCloseMobileDrawer:A,onSelectSession:j,selectedSessionId:ie,collapsed:ae,mobileDrawerOpen:M,recentsActions:N}=e,[P,F]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),[R,ce]=(0,D.useState)(!1);(0,D.useEffect)(()=>{ee()},[ee]);let le=(0,D.useRef)(null),[z,ue]=(0,D.useState)(!1),[B,de]=(0,D.useState)(`default`),[V,H]=(0,D.useState)(null),fe=u.productName,pe=typeof s==`string`?s:s===null?`name unavailable`:i||fe,me=(pe.trim().charAt(0)||`?`).toUpperCase(),U=se(u.hostname),W=ge(a),G=(0,D.useMemo)(()=>{let e=_e(W.rows,W.view,W.includeBackground);if(U.pinned.size===0)return e;let t=[],n=[];for(let r of e)(U.pinned.has(r.sessionId)?t:n).push(r);return[...t,...n]},[W.rows,W.view,W.includeBackground,U.pinned]),he=G.length,[K,q]=(0,D.useState)(`chat`),[J,ve]=(0,D.useState)([]),[Se,Ce]=(0,D.useState)(!1),[we,Y]=(0,D.useState)(null),[Te,Ee]=(0,D.useState)(!1);(0,D.useImperativeHandle)(t,()=>({patchArtefact(e,t){ve(n=>n.map(n=>n.id===e?{...n,...t}:n))}}),[]);let[X,De]=(0,D.useState)(!1),Oe=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(!X)return;function e(e){Oe.current&&!Oe.current.contains(e.target)&&(console.info(`[admin-ui] sidebar-mode-picker action=close mode=${B}`),De(!1))}function t(e){e.key===`Escape`&&(console.info(`[admin-ui] sidebar-mode-picker action=close mode=${B}`),De(!1))}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[X,B]);let ke={default:`Ask`,acceptEdits:`Accept edits`,plan:`Plan`,auto:`Auto`},Ae=[`default`,`acceptEdits`,`plan`,`auto`],Z=(0,D.useCallback)(async()=>{if(a){Ee(!0),Y(null);try{let e=await fetch(`/api/admin/sidebar-artefacts?session_key=${encodeURIComponent(a)}`);if(!e.ok)throw Error(`status ${e.status}`);ve((await e.json()).artefacts??[]),Ce(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Y(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Ee(!1)}}},[a]),je=()=>{q(`chat`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${he}`)},Me=()=>{q(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${Se?J.length:0} collapsed=${ae}`),Se||Z()},Q=ae?24:16,Ne=K===`chat`?`Sessions`:`Artefacts`,Pe=K===`chat`?g?`…`:String(he):Te?`…`:String(J.length),Fe=K===`chat`?g:Te,Ie=()=>{console.info(`[admin-ui] sidebar-refresh surface=${K}`),K===`chat`?te().then(e=>{e!==null&&W.reconcileFromList(e.map(e=>e.sessionId))}):Z()},Le=(0,D.useCallback)(async()=>{if(z||!a){console.info(`[admin-ui] sidebar-new-session-click-ignored startingSession=${z} cacheKey=${a?`set`:`missing`}`);return}let e=Date.now();console.info(`[admin-ui] sidebar-new-session-click permissionMode=${B} cacheKey-prefix=${a.slice(0,8)}`),ue(!0),H(null);try{let t=new Date().toISOString();console.info(`[admin-ui] sidebar-new-session-fetch-start permissionMode=${B} initialMessage=${t}`);let n=await fetch(`/api/admin/claude-sessions?session_key=${encodeURIComponent(a)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({channel:`browser`,permissionMode:B,initialMessage:t})}),r=Date.now()-e;console.info(`[admin-ui] sidebar-new-session-fetch-done status=${n.status} ok=${n.ok} ms=${r}`);let i=await n.json();if(!n.ok||!(`sessionId`in i)){let t=i,r=t.error??`POST returned ${n.status}`,a=t.reason?`${r}: ${t.reason}`:r;console.error(`[admin-ui] sidebar-new-session-failed status=${n.status} ms=${Date.now()-e} error=${r} reason=${t.reason??`none`} tail=${JSON.stringify(t.stderrTail??``)}`),H(a);return}console.info(`[admin-ui] sidebar-new-session-ok pid=${i.pid} sessionId=${i.sessionId.slice(0,8)} permissionMode=${B} ms=${Date.now()-e}`),N.setSessions(e=>[i,...e])}catch(t){let n=t instanceof Error?t.message:String(t);H(n),console.error(`[admin-ui] sidebar-new-session-threw ms=${Date.now()-e} message=${n}`)}finally{ue(!1)}},[a,z,N,B]),$=oe(a,N,`sidebar`),Re=(0,D.useCallback)(async e=>{let t=await $.resume(e);t.ok||console.error(`[admin-ui] sidebar-resume failed: ${t.error}`)},[$]),ze=(0,D.useCallback)(async e=>{ce(!0),L(null);let t=await $.purge(e);t.ok?F(null):L(t.error??`purge failed`),ce(!1)},[$]),Be=(0,D.useCallback)(async e=>{let t=await $.end(e);t.ok||console.error(`[admin-ui] sidebar-end-session failed: ${t.error}`)},[$]);return(0,O.jsxs)(`aside`,{className:`side`,children:[K===`chat`&&(0,O.jsxs)(`div`,{className:`side-new-session-row`,ref:Oe,children:[(0,O.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:()=>void Le(),disabled:z||!a,children:[z?(0,O.jsx)(v,{size:14,className:`spinning`}):(0,O.jsx)(x,{size:14}),(0,O.jsx)(`span`,{children:`New session`})]}),(0,O.jsx)(`button`,{type:`button`,className:`side-mode-trigger`,onClick:()=>{let e=!X;console.info(`[admin-ui] sidebar-mode-picker action=${e?`open`:`close`} mode=${B}`),De(e)},disabled:z,"aria-haspopup":`menu`,"aria-expanded":X,"aria-label":`Permission mode for the next session`,children:ke[B]}),X&&(0,O.jsxs)(`div`,{className:`side-mode-popover`,role:`menu`,"aria-label":`Mode`,children:[(0,O.jsx)(`div`,{className:`side-mode-popover-head`,children:`Mode`}),Ae.map(e=>(0,O.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`side-mode-popover-item`,onClick:()=>{console.info(`[admin-ui] sidebar-mode-picker action=select mode=${e}`),de(e),De(!1)},children:[(0,O.jsx)(`span`,{children:ke[e]}),e===B&&(0,O.jsx)(r,{size:12})]},e))]})]}),(0,O.jsxs)(`nav`,{className:`side-nav`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`nav-row${K===`chat`?` active`:``}`,onClick:je,children:[(0,O.jsx)(T,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,O.jsx)(`span`,{className:`kbd`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),w(),A()},children:[(0,O.jsx)(E,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`People`}),(0,O.jsx)(`span`,{className:`kbd`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),k(),A()},children:[(0,O.jsx)(f,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`Agents`}),(0,O.jsx)(`span`,{className:`kbd`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),C(),A()},children:[(0,O.jsx)(p,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`Projects`}),(0,O.jsx)(`span`,{className:`kbd`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),re(),A()},children:[(0,O.jsx)(_,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,O.jsx)(`span`,{className:`kbd`})]}),(0,O.jsxs)(`button`,{type:`button`,className:`nav-row${K===`artefacts`?` active`:``}`,onClick:Me,children:[(0,O.jsx)(d,{size:Q}),(0,O.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,O.jsx)(`span`,{className:`kbd`})]})]}),(0,O.jsxs)(`div`,{className:`side-list`,ref:le,children:[(0,O.jsxs)(`div`,{className:`group-head`,children:[(0,O.jsx)(`span`,{children:Ne}),(0,O.jsxs)(`span`,{className:`group-head-meta`,children:[(0,O.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh ${Ne.toLowerCase()}`,"aria-label":`Refresh ${Ne.toLowerCase()}`,onClick:Ie,disabled:Fe,children:(0,O.jsx)(S,{size:12,className:Fe?`spinning`:void 0})}),(0,O.jsx)(`span`,{children:Pe})]})]}),V&&K===`chat`&&(0,O.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:V}),K===`chat`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(ye,{view:W.view,setView:e=>{console.info(`[admin-ui] sidebar-view-change view=${e}`),W.setView(e)},includeBackground:W.includeBackground,setIncludeBackground:e=>{console.info(`[admin-ui] sidebar-background-toggle include=${e}`),W.setIncludeBackground(e)},connected:W.connected,reconnectNow:W.reconnectNow}),y&&(0,O.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:y}),G.map(e=>{let t=ie===e.sessionId,r=e.agentLabel??`admin`;return(0,O.jsxs)(`div`,{className:`conv${t?` active`:``}`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`conv-name-button`,onClick:()=>{j(e.sessionId),A()},title:`Show metadata`,children:[(0,O.jsx)(T,{size:12,className:`conv-channel-icon`,"aria-label":`claude session`}),(0,O.jsx)(be,{live:e.live,status:e.status}),(0,O.jsx)(`span`,{className:`conv-name`,children:e.firstPrompt}),(0,O.jsx)(`span`,{className:`conv-agent-badge`,"data-kind":e.agentLabel?`specialist`:`admin`,children:r})]}),e.live?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Open in new tab`,"aria-label":`Open in new tab`,onClick:()=>void xe(e.sessionId,a),children:(0,O.jsx)(h,{size:13})}),(0,O.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`End session`,"aria-label":`End session`,onClick:()=>void Be(e.sessionId),children:(0,O.jsx)(ne,{size:13})})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Resume session`,"aria-label":`Resume session`,onClick:()=>void Re(e.sessionId),children:(0,O.jsx)(n,{size:13})}),(0,O.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Purge JSONL`,"aria-label":`Purge JSONL`,onClick:()=>{L(null),F({sessionId:e.sessionId,displayName:e.firstPrompt})},children:(0,O.jsx)(l,{size:13})})]})]},e.sessionId)})]}),K===`artefacts`&&(0,O.jsxs)(O.Fragment,{children:[we&&(0,O.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:we}),Se&&!we&&J.length===0&&(0,O.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),J.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>{b({docId:e.id,name:e.name,content:e.content,editable:e.editable,mimeType:e.mimeType,skipReason:e.skipReason},`sidebar-artefacts`),A()},children:[(0,O.jsx)(`span`,{className:`conv-name`,children:e.name}),(0,O.jsx)(`span`,{className:`conv-kind`,"data-kind":e.kind===`agent-template`?`agent`:`doc`,children:e.kind===`agent-template`?`agent`:`doc`})]},e.id))]})]}),(0,O.jsxs)(`div`,{className:`side-foot`,children:[(0,O.jsx)(`div`,{className:`avatar`,children:c?(0,O.jsx)(`img`,{src:c,alt:pe}):me}),(0,O.jsxs)(`div`,{className:`who`,children:[(0,O.jsx)(`span`,{className:`name`,children:pe}),(0,O.jsx)(`span`,{className:`role`,children:o??`operator`})]})]}),P&&(0,O.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`purge-confirm-title`,className:`modal-overlay`,onClick:e=>{e.target===e.currentTarget&&!R&&F(null)},children:(0,O.jsxs)(`div`,{className:`modal-card`,children:[(0,O.jsx)(`h3`,{id:`purge-confirm-title`,style:{margin:0,marginBottom:8,fontSize:16,fontWeight:600},children:`Purge session JSONL?`}),(0,O.jsxs)(`p`,{style:{margin:0,marginBottom:8,fontSize:13},children:[`This hard-deletes the transcript and sidecar for `,(0,O.jsx)(`strong`,{children:P.displayName}),`. The action cannot be undone.`]}),I&&(0,O.jsx)(`p`,{style:{margin:0,marginBottom:8,fontSize:12,color:`var(--text-tertiary)`},children:I}),(0,O.jsxs)(`div`,{className:`modal-action-row`,children:[(0,O.jsx)(`button`,{type:`button`,className:`modal-action-btn`,disabled:R,onClick:()=>F(null),children:`Cancel`}),(0,O.jsx)(`button`,{type:`button`,className:`modal-action-btn`,"data-variant":`danger`,disabled:R,onClick:()=>void ze(P.sessionId),children:R?(0,O.jsx)(v,{size:13,className:`spinning`}):`Purge`})]})]})})]})}),ve=[{value:`active`,label:`Active`},{value:`archived`,label:`Archived`},{value:`all`,label:`All`}];function ye(e){let{view:n,setView:r,includeBackground:i,setIncludeBackground:a,connected:o,reconnectNow:s}=e;return(0,O.jsxs)(`div`,{className:`session-view-controls`,children:[(0,O.jsx)(t,{checked:i,onChange:a,label:`Include subagents`}),(0,O.jsxs)(`div`,{className:`session-view-segmented`,role:`tablist`,"aria-label":`Session view`,children:[ve.map(e=>(0,O.jsx)(`button`,{type:`button`,role:`tab`,className:`session-view-tab${n===e.value?` active`:``}`,"aria-selected":n===e.value,onClick:()=>r(e.value),children:e.label},e.value)),o?(0,O.jsx)(`span`,{className:`session-view-connection connected`,"aria-label":`Live updates connected.`,title:`Live updates connected.`}):(0,O.jsx)(`button`,{type:`button`,className:`session-view-connection disconnected`,"aria-label":`Live updates paused. Click to retry.`,title:`Live updates paused. Click to retry.`,onClick:s})]})]})}function be({live:e,status:t}){return e?t===`busy`?(0,O.jsxs)(`span`,{className:`session-status session-status-busy`,"aria-label":`session busy`,children:[(0,O.jsx)(`span`,{className:`session-status-dot`}),(0,O.jsx)(`span`,{className:`session-status-dot`}),(0,O.jsx)(`span`,{className:`session-status-dot`})]}):(0,O.jsx)(`span`,{className:`session-status session-status-idle`,"aria-label":`session idle`}):(0,O.jsx)(`span`,{className:`session-status session-status-archived`,"aria-label":`session archived`})}async function xe(e,t){if(t){console.info(`[admin-ui] sidebar-open-session sessionId=${e.slice(0,8)}`);try{let n=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(e)}/meta?session_key=${encodeURIComponent(t)}`);if(!n.ok){console.error(`[admin-ui] sidebar-open-session-meta-failed sessionId=${e.slice(0,8)} status=${n.status}`);return}let r=await n.json();r.url&&window.open(r.url,`_blank`,`noopener,noreferrer`)}catch(t){console.error(`[admin-ui] sidebar-open-session-meta-threw sessionId=${e.slice(0,8)} message=${t instanceof Error?t.message:String(t)}`)}}}function Se(e){return e.map(e=>[e.sessionId,e.claudeSessionId,e.displayName,e.lastMessageAt,e.status])}function Ce(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r[0]!==i[0]||r[1]!==i[1]||r[2]!==i[2]||r[3]!==i[3]||r[4]!==i[4])return!1}return!0}function we(e){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(null),[s,c]=(0,D.useState)(null),l=(0,D.useRef)([]),u=(0,D.useCallback)(async t=>{if(!e||!t&&s===e)return null;i(!0),o(null);try{let t=await fetch(`/api/admin/claude-sessions?session_key=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`claude-sessions fetch returned ${t.status}`);let r=await t.json(),i=Array.isArray(r)?r:r.sessions??[],a=Se(i),o=Ce(l.current,a);return o||(n(i),l.current=a),c(e),console.info(`[admin-ui] sessions-poll outcome=${o?`unchanged`:`changed`} count=${i.length} cacheKey=${e.slice(0,8)}`),i}catch(t){return console.info(`[admin-ui] sessions-poll outcome=error count=0 cacheKey=${e.slice(0,8)}`),console.error(`[admin/claude-sessions] fetch failed:`,t),o(t instanceof Error?t.message:String(t)),null}finally{i(!1)}},[e,s]);(0,D.useEffect)(()=>{e||(c(null),n([]),o(null),l.current=[])},[e]);let d=(0,D.useCallback)(()=>u(!1),[u]),f=(0,D.useCallback)(()=>u(!0),[u]);return{sessions:t,setSessions:n,loading:r,loaded:s!==null&&s===e,error:a,ensureLoaded:d,refetch:f}}var Y=`admin-sidebar-collapsed`,Te=`admin-sidebar-drawer-open`;function Ee(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Y)===`1`}catch{return!1}}function X(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Y,`1`):window.sessionStorage.removeItem(Y)}catch{}}function De(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Te)===`1`}catch{return!1}}function Oe(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Te,`1`):window.sessionStorage.removeItem(Te)}catch{}}var ke=720;function Ae(e){let{cacheKey:t,businessName:n,conversationId:r,onLaunchBrowser:i,onLogout:a,browserLaunching:o=!1,userName:s,userAvatar:c,role:l,selectedSessionId:u,onSelectSession:d,onSelectArtefact:f,dataArtefact:p=`closed`,children:m,footer:h}=e,[g,_]=(0,D.useState)(()=>Ee()),[v,y]=(0,D.useState)(()=>De()),[ee,te]=(0,D.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${ke}px)`).matches);(0,D.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${ke}px)`),t=e=>te(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let b=(0,D.useCallback)(e=>{X(e),_(e)},[]),x=(0,D.useCallback)(e=>{Oe(e),y(e)},[]);(0,D.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} collapsed=${g} drawer=${v}`)},[]);let S=ee?v:!g,C=(0,D.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${ke}px)`).matches){let e=v;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),x(!e)}else{let e=g;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),b(!e)}},[g,v,b,x]),w=(0,D.useCallback)(e=>{console.info(`[admin-ui] header-menu-nav target=${e}`),window.location.href=e===`data`?`/data`:`/graph`},[]),ne=(0,D.useCallback)(()=>{},[]),T=we(t),E=(0,D.useCallback)(e=>{if(d){d(e);return}window.location.assign(`/?sessionId=${encodeURIComponent(e)}`)},[d]),re=(0,D.useCallback)(e=>{f&&f(e)},[f]),k={collapsed:g,mobileDrawerOpen:v,sidebarOpen:S,onToggleSidebar:C,setMobileDrawerOpen:x,sessionsState:T};return(0,O.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,O.jsx)(ce,{businessName:n,cacheKey:t,conversationId:r,onLaunchBrowser:i??ne,onNavigate:w,onToggleSidebar:C,sidebarOpen:S,onLogout:a,browserLaunching:o}),(0,O.jsxs)(`div`,{className:`platform${v?` menu-open`:``}${g?` sidebar-collapsed`:``}`,"data-artefact":p,children:[(0,O.jsx)(J,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,sessions:T.sessions,sessionsLoading:T.loading,sessionsError:T.error,ensureSessionsLoaded:T.ensureLoaded,refetchSessions:T.refetch,onSelectArtefact:re,onSelectProjects:()=>{window.location.href=`/graph?label=Project`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>x(!1),onSelectSession:E,selectedSessionId:u??null,collapsed:g,mobileDrawerOpen:v,recentsActions:{setSessions:T.setSessions,refetch:T.refetch}}),typeof m==`function`?m(k):m]}),v&&(0,O.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>x(!1)}),h]})}var Z={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Organization:`#8A6B47`,Person:`#B86E4A`,UserProfile:`#D08960`,Preference:`#DFA67A`,AdminUser:`#8C5230`,AccessGrant:`#66381F`,KnowledgeDocument:`#6E8A5A`,ConversationArchive:`#82A06A`,Section:`#8AA876`,Chunk:`#A6C194`,DigitalDocument:`#5A7548`,CreativeWork:`#B5C9A2`,Question:`#C7D6B5`,FAQPage:`#95B385`,DefinedTerm:`#76906A`,Review:`#3F5A2E`,ImageObject:`#A0BB8C`,Conversation:`#6B5A85`,AdminConversation:`#4F4070`,PublicConversation:`#8A75A8`,Message:`#6B7280`,UserMessage:`#DFA67A`,AssistantMessage:`#C9A876`,ToolCall:`#B5ABCB`,Task:`#B0617A`,Project:`#8E4A60`,Event:`#C68095`,Workflow:`#3A6F77`,WorkflowStep:`#5A8E96`,WorkflowRun:`#7AAAB2`,StepResult:`#9CC4CB`,Email:`#6F7F4A`,EmailAccount:`#91A063`,Agent:`#B8893D`},je=`#94A3B8`;Object.freeze(Object.keys(Z)),Object.freeze(new Set([`Chunk`,`GraphPreference`]));var Me=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.AdminConversation.PublicConversation.Task.Project.Event.Workflow.Email.EmailAccount.Agent`.split(`.`)));Object.freeze(new Set([`ToolCall`,`StepResult`,`WorkflowStep`,`WorkflowRun`])),Object.freeze(new Set([`HAS_TOOL_CALL`,`RUN_OF`,`HAS_STEP`,`HAS_RESULT`]));function Q(e){for(let t=1;t<e.length;t++)if(Object.prototype.hasOwnProperty.call(Z,e[t]))return e[t];return e[0]??null}function Ne(e){return Z[e]??`#94A3B8`}function Pe(e){let t=Q(e),n=t?Ne(t):je,r=0;for(let t=1;t<e.length;t++)Object.prototype.hasOwnProperty.call(Z,e[t])&&r++;return{displayLabel:t,colour:n,driftCandidates:r}}export{m as _,Ae as a,oe as c,w as d,C as f,h as g,v as h,Pe as i,ae as l,x as m,Ne as n,pe as o,S as p,Q as r,se as s,Me as t,re as u};
|