@rubytech/create-maxy-code 0.1.123 → 0.1.126

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 (65) hide show
  1. package/dist/index.js +49 -4
  2. package/package.json +2 -2
  3. package/payload/platform/lib/graph-style/dist/index.d.ts +78 -0
  4. package/payload/platform/lib/graph-style/dist/index.d.ts.map +1 -0
  5. package/payload/platform/lib/graph-style/dist/index.js +296 -0
  6. package/payload/platform/lib/graph-style/dist/index.js.map +1 -0
  7. package/payload/platform/lib/graph-style/src/__tests__/parity.test.ts +114 -0
  8. package/payload/platform/lib/graph-style/src/index.ts +307 -0
  9. package/payload/platform/lib/graph-style/tsconfig.json +9 -0
  10. package/payload/platform/lib/graph-style/vitest.config.ts +9 -0
  11. package/payload/platform/neo4j/schema.cypher +50 -0
  12. package/payload/platform/package-lock.json +318 -0
  13. package/payload/platform/package.json +3 -2
  14. package/payload/platform/plugins/.claude-plugin/marketplace.json +5 -0
  15. package/payload/platform/plugins/docs/references/visitor-graph.md +5 -4
  16. package/payload/platform/plugins/docs/references/voice-mirror-guide.md +60 -0
  17. package/payload/platform/plugins/email/skills/email-composition/SKILL.md +6 -2
  18. package/payload/platform/plugins/graph-viewer/.claude-plugin/plugin.json +8 -0
  19. package/payload/platform/plugins/graph-viewer/PLUGIN.md +56 -0
  20. package/payload/platform/plugins/graph-viewer/mcp/dist/index.d.ts +7 -0
  21. package/payload/platform/plugins/graph-viewer/mcp/dist/index.d.ts.map +1 -0
  22. package/payload/platform/plugins/graph-viewer/mcp/dist/index.js +74 -0
  23. package/payload/platform/plugins/graph-viewer/mcp/dist/index.js.map +1 -0
  24. package/payload/platform/plugins/graph-viewer/mcp/dist/lib/neo4j.d.ts +5 -0
  25. package/payload/platform/plugins/graph-viewer/mcp/dist/lib/neo4j.d.ts.map +1 -0
  26. package/payload/platform/plugins/graph-viewer/mcp/dist/lib/neo4j.js +43 -0
  27. package/payload/platform/plugins/graph-viewer/mcp/dist/lib/neo4j.js.map +1 -0
  28. package/payload/platform/plugins/graph-viewer/mcp/dist/render/draw.d.ts +28 -0
  29. package/payload/platform/plugins/graph-viewer/mcp/dist/render/draw.d.ts.map +1 -0
  30. package/payload/platform/plugins/graph-viewer/mcp/dist/render/draw.js +73 -0
  31. package/payload/platform/plugins/graph-viewer/mcp/dist/render/draw.js.map +1 -0
  32. package/payload/platform/plugins/graph-viewer/mcp/dist/render/layout.d.ts +40 -0
  33. package/payload/platform/plugins/graph-viewer/mcp/dist/render/layout.d.ts.map +1 -0
  34. package/payload/platform/plugins/graph-viewer/mcp/dist/render/layout.js +77 -0
  35. package/payload/platform/plugins/graph-viewer/mcp/dist/render/layout.js.map +1 -0
  36. package/payload/platform/plugins/graph-viewer/mcp/dist/tools/graph-render.d.ts +45 -0
  37. package/payload/platform/plugins/graph-viewer/mcp/dist/tools/graph-render.d.ts.map +1 -0
  38. package/payload/platform/plugins/graph-viewer/mcp/dist/tools/graph-render.js +170 -0
  39. package/payload/platform/plugins/graph-viewer/mcp/dist/tools/graph-render.js.map +1 -0
  40. package/payload/platform/plugins/graph-viewer/mcp/package.json +25 -0
  41. package/payload/platform/plugins/graph-viewer/mcp/vitest.config.ts +8 -0
  42. package/payload/platform/plugins/graph-viewer/skills/render-graph/SKILL.md +35 -0
  43. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/schema-loader.test.js +17 -0
  44. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/schema-loader.test.js.map +1 -1
  45. package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.d.ts.map +1 -1
  46. package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js +11 -2
  47. package/payload/platform/plugins/memory/mcp/dist/lib/schema-loader.js.map +1 -1
  48. package/payload/platform/plugins/memory/references/schema-base.md +12 -4
  49. package/payload/platform/plugins/venture-studio/skills/investor-data-room/SKILL.md +2 -0
  50. package/payload/platform/scripts/check-plugin-tools-mcp-consistency.mjs +136 -0
  51. package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +2 -0
  52. package/payload/server/public/assets/{admin-D6IfAzYY.js → admin-FcRHAL-3.js} +7 -7
  53. package/payload/server/public/assets/{data-BGbQyufe.js → data-Ds37mflX.js} +1 -1
  54. package/payload/server/public/assets/{graph-D-1lRTeL.js → graph-CmWRhaiS.js} +1 -1
  55. package/payload/server/public/assets/graph-labels-Ch2r00Gt.js +1 -0
  56. package/payload/server/public/assets/page-BOtNny_4.js +51 -0
  57. package/payload/server/public/assets/page-BcHhJXUt.js +1 -0
  58. package/payload/server/public/data.html +3 -3
  59. package/payload/server/public/graph.html +3 -3
  60. package/payload/server/public/index.html +4 -4
  61. package/payload/server/public/privacy.html +2 -2
  62. package/payload/server/server.js +236 -92
  63. package/payload/server/public/assets/graph-labels-BRXJHNYE.js +0 -1
  64. package/payload/server/public/assets/page-B4oirCvn.js +0 -1
  65. package/payload/server/public/assets/page-FmJ7PIYx.js +0 -51
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-DD-I1_y5.js";import{d as t,g as n,u as r,y as i}from"./ChatInput-CJo_77bp.js";import{_ as a,a as o,i as s,l as c,p as l,t as u,y as d}from"./graph-labels-Ch2r00Gt.js";var f=n(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),p=n(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),m=n(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),h=n(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),g=n(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function _(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||u.has(e)&&(t.add(e),n.push(e)));return n}var v=80;function y(e){let t=b(e.properties)??e.labels[0]??``,n=t.length>v?t.slice(0,v):t;return`/graph?${new URLSearchParams({nodeId:e.nodeId,label:n}).toString()}`}function b(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}var x=e(i(),1),S=r();function C(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,o]=(0,x.useState)(void 0),[l,u]=(0,x.useState)(null),[f,p]=(0,x.useState)(void 0),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.conversationId!==void 0&&u(e.conversationId??null),_(e.role??null),p(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return n?e?(0,S.jsxs)(s,{cacheKey:e,businessName:i,conversationId:l,onLogout:v,userName:f,userAvatar:m,role:g,children:[(0,S.jsx)(c,{}),(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsx)(w,{cacheKey:e})]})]}):(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsxs)(`div`,{className:`data-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,S.jsx)(`div`,{className:`data-page`,children:(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function w({cacheKey:e,onOpenInGraph:t}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:s}=o({initialCacheKey:e,surface:`data`});return(0,S.jsxs)(`main`,{className:`data-main`,children:[a&&(0,S.jsx)(`button`,{type:`button`,className:`data-session-banner`,onClick:s,"data-reason":a.reason,children:a.message}),(0,S.jsx)(T,{adminFetch:n,sessionRefetchNonce:i,onOpenInGraph:t}),(0,S.jsx)(A,{adminFetch:n,cacheKey:r,sessionRefetchNonce:i})]})}function T({adminFetch:e,sessionRefetchNonce:t,onOpenInGraph:n}){let[r,i]=(0,x.useState)(``),[o,s]=(0,x.useState)(``),[c,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(`hybrid`),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(0),[T,O]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=r.trim();if(!e){s(``),u(null);return}O(!1);let t=setTimeout(()=>s(e),300);return()=>clearTimeout(t)},[r]),(0,x.useEffect)(()=>{if(!o)return;let t=!1;return m(!0),g(null),e(`/api/admin/graph-search?q=${encodeURIComponent(o)}&labels=*&limit=20${T?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(u(e.results),f(e.mode??`hybrid`),w(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[o,e,t,T]);let k=(0,x.useMemo)(()=>c?_(c):[],[c]),A=v&&k.includes(v)?v:null,j=(0,x.useMemo)(()=>c?A?c.filter(e=>e.labels.includes(A)):c:null,[c,A]),M=(0,x.useCallback)(e=>{if(n){n(e);return}window.location.href=y(e)},[n]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,S.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,S.jsxs)(`div`,{className:`data-search-input`,children:[(0,S.jsx)(l,{size:14}),(0,S.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),p&&(0,S.jsx)(a,{size:14,className:`spin`})]}),h&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,h]}),k.length>0&&(0,S.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:k.map(e=>{let t=e===A;return(0,S.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>b(t?null:e),children:D([e])??e},e)})}),c&&!p&&(0,S.jsxs)(`div`,{className:`data-results-meta`,children:[j.length,` of `,c.length,` result`,c.length===1?``:`s`]}),c&&!p&&!A&&C>0&&!T&&(0,S.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!0),children:[C,` low-confidence result`,C===1?``:`s`,` hidden — show all`]}),c&&!p&&!A&&T&&(0,S.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!1),children:`Showing all results — hide low-confidence`}),c&&c.length===0&&!p&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),j&&j.length>0&&(0,S.jsx)(`ul`,{className:`data-results`,children:j.map(e=>(0,S.jsx)(E,{hit:e,mode:d,onOpenInGraph:M},e.nodeId))})]})}function E({hit:e,mode:t,onOpenInGraph:n}){let r=O(e.properties),i=k(e.properties),a=D(e.labels),[o,s]=(0,x.useState)(!1),c=i&&i.length>280,l=o||!c?i:i?.slice(0,280)+`…`,u=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`;return(0,S.jsxs)(`li`,{className:`data-result`,children:[(0,S.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Open ${r??a??`node`} in graph`,children:[a&&(0,S.jsx)(`div`,{className:`data-result-header`,children:(0,S.jsx)(`span`,{className:`data-result-labels`,children:a})}),r&&(0,S.jsx)(`div`,{className:`data-result-title`,children:r}),i&&(0,S.jsx)(`pre`,{className:`data-result-body`,children:l}),(0,S.jsx)(`div`,{className:`data-result-scores`,children:u})]}),c&&(0,S.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`Show more`})]})}function D(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function O(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function k(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function A({adminFetch:e,cacheKey:n,sessionRefetchNonce:r}){let[i,o]=(0,x.useState)(`.`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)([]),[d,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),[A,N]=(0,x.useState)(null),P=(0,x.useRef)(null),[F,I]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=!1;return _(!0),y(null),e(`/api/admin/files?path=${encodeURIComponent(i===`.`?``:i)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(c(e.entries),u(e.displayPath??[]))}).catch(e=>{t||(c([]),u([]),y(e instanceof Error?e.message:String(e)))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[e,i,F,r]);let L=(0,x.useCallback)(e=>{o(e)},[]),R=(0,x.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),o(e.length===0?`.`:e.join(`/`))},[i]),z=(0,x.useCallback)(e=>{let t=i===`.`?e.name:`${i}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,a=document.createElement(`a`);a.href=r,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[i,n]),B=(0,x.useCallback)(()=>{P.current?.click()},[]),V=(0,x.useCallback)(e=>{D(null),N(e.name)},[]),H=(0,x.useCallback)(()=>{N(null)},[]),U=(0,x.useCallback)(async t=>{let n=i===`.`?t.name:`${i}/${t.name}`;D(null),N(null),k(t.name);try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`);I(e=>e+1)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[i,e]);(0,x.useEffect)(()=>{if(!A)return;let e=e=>{e.key===`Escape`&&N(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A]);let W=(0,x.useCallback)(async e=>{T(null),C(!0);try{let t=new FormData;t.append(`session_key`,n),t.append(`file`,e);let r=await fetch(`/api/admin/files/upload`,{method:`POST`,body:t}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);o(i.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1),P.current&&(P.current.value=``)}},[n]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,S.jsxs)(`div`,{className:`data-file-actions`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:B,disabled:b,children:[b?(0,S.jsx)(a,{size:14,className:`spin`}):(0,S.jsx)(g,{size:14}),` Upload`]}),(0,S.jsx)(`input`,{type:`file`,ref:P,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&W(t)}})]})]}),(0,S.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,S.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,S.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,S.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(`.`),children:`data`}),l.map((e,t)=>{let n=l.slice(0,t+1).map(e=>e.name).join(`/`);return(0,S.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,S.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(n),title:e.name,children:e.displayName??e.name})]},n)}),i!==`.`&&(0,S.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:R,children:[(0,S.jsx)(f,{size:14}),` Up`]})]}),w&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,w]}),E&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,E]}),v&&(0,S.jsx)(`div`,{className:`data-error`,children:v}),d&&(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!d&&s&&s.length===0&&!v&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!d&&s&&s.length>0&&(0,S.jsx)(`ul`,{className:`data-entries`,children:s.map(e=>{let n=e.displayName??e.name,r=O===e.name,o=A===e.name;return(0,S.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(i===`.`?e.name:`${i}/${e.name}`),children:[(0,S.jsx)(h,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n})]}):e.kind===`file`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>z(e),title:`Download ${n}`,disabled:o,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n}),(0,S.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${M(e.modifiedAt)}`,children:[j(e.sizeBytes),` · `,M(e.modifiedAt)]}),(0,S.jsx)(p,{size:12,className:`data-entry-download-icon`})]}),o?(0,S.jsxs)(`div`,{className:`data-entry-confirm`,role:`group`,"aria-label":`Confirm delete ${n}`,children:[(0,S.jsx)(`span`,{className:`data-entry-confirm-label`,children:`Delete?`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-yes`,onClick:()=>U(e),autoFocus:!0,children:`Yes`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-no`,onClick:H,children:`No`})]}):(0,S.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>V(e),disabled:r,title:`Delete ${n}`,"aria-label":`Delete ${n}`,children:r?(0,S.jsx)(a,{size:14,className:`spin`}):(0,S.jsx)(t,{size:14})})]}):(0,S.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,children:n}),(0,S.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function j(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function M(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{p as i,w as n,b as r,C as t};
@@ -5,11 +5,11 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Data — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/data-BGbQyufe.js"></script>
8
+ <script type="module" crossorigin src="/assets/data-Ds37mflX.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/ChatInput-CJo_77bp.js">
11
- <link rel="modulepreload" crossorigin href="/assets/graph-labels-BRXJHNYE.js">
12
- <link rel="modulepreload" crossorigin href="/assets/page-B4oirCvn.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/graph-labels-Ch2r00Gt.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/page-BcHhJXUt.js">
13
13
  <link rel="stylesheet" crossorigin href="/assets/ChatInput-CJ50oqWt.css">
14
14
  </head>
15
15
  <body>
@@ -5,12 +5,12 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Graph — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/graph-D-1lRTeL.js"></script>
8
+ <script type="module" crossorigin src="/assets/graph-CmWRhaiS.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/ChatInput-CJo_77bp.js">
11
- <link rel="modulepreload" crossorigin href="/assets/graph-labels-BRXJHNYE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/graph-labels-Ch2r00Gt.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/Checkbox-YrQovXpN.js">
13
- <link rel="modulepreload" crossorigin href="/assets/page-FmJ7PIYx.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/page-BOtNny_4.js">
14
14
  <link rel="stylesheet" crossorigin href="/assets/ChatInput-CJ50oqWt.css">
15
15
  </head>
16
16
  <body>
@@ -5,14 +5,14 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-D6IfAzYY.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-FcRHAL-3.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/ChatInput-CJo_77bp.js">
11
- <link rel="modulepreload" crossorigin href="/assets/graph-labels-BRXJHNYE.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/graph-labels-Ch2r00Gt.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/lib-Bnh57com.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/Checkbox-YrQovXpN.js">
14
- <link rel="modulepreload" crossorigin href="/assets/page-B4oirCvn.js">
15
- <link rel="modulepreload" crossorigin href="/assets/page-FmJ7PIYx.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/page-BcHhJXUt.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/page-BOtNny_4.js">
16
16
  <link rel="stylesheet" crossorigin href="/assets/ChatInput-CJ50oqWt.css">
17
17
  <link rel="stylesheet" crossorigin href="/assets/admin-CWMpccrR.css">
18
18
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -51,10 +51,10 @@
51
51
  <p>If you visit anonymously today and later click a personalised marketing link from the agent, prior anonymous visits from the same browser are linked to your contact record. This is the only way an anonymous visit ever becomes named.</p>
52
52
 
53
53
  <h2>Retention</h2>
54
- <p>Visit data is kept for <strong>180 days</strong> by default, then removed automatically. The operator can change this your acting agent will tell you the current value if you ask.</p>
54
+ <p>Visit data is kept until you ask us to remove it. There is no automatic time-based deletion. If you want your data removed, see the next section.</p>
55
55
 
56
56
  <h2>Right to access and erasure</h2>
57
- <p>To see what we hold or to ask for it to be removed, contact the agent. We honour GDPR Article 15 (access) and Article 17 (erasure). Erasure cascades: removing your contact removes every session, page view, click, and scroll milestone tied to your identity. Anonymous page views from browsers we cannot link to you are not removed individually they cannot be identified, and they expire under the retention window above.</p>
57
+ <p>To see what we hold or to ask for it to be removed, contact the agent. We honour GDPR Article 15 (access) and Article 17 (erasure). Erasure cascades: removing your contact removes every session, page view, click, and scroll milestone tied to your identity. Anonymous page views from browsers we cannot link to you cannot be erased individually, because there is nothing identifying you to match them against.</p>
58
58
 
59
59
  <h2>Bots and crawlers</h2>
60
60
  <p>Search engines and link checkers are filtered out by user-agent before any data is written. They are also excluded from rate-limit budgets so legitimate visitors are never blocked because a crawler hammered the endpoint.</p>
@@ -365,6 +365,239 @@ var require_dist = __commonJS({
365
365
  }
366
366
  });
367
367
 
368
+ // ../lib/graph-style/dist/index.js
369
+ var require_dist2 = __commonJS({
370
+ "../lib/graph-style/dist/index.js"(exports) {
371
+ "use strict";
372
+ Object.defineProperty(exports, "__esModule", { value: true });
373
+ exports.ALL_GRAPH_LABELS = exports.FALLBACK_LABEL_COLOUR = exports.GRAPH_LABEL_COLOURS = void 0;
374
+ exports.pickDisplayLabel = pickDisplayLabel2;
375
+ exports.colourForLabel = colourForLabel2;
376
+ exports.resolveNodeColour = resolveNodeColour2;
377
+ exports.formatRunTimestamp = formatRunTimestamp;
378
+ exports.formatMessageTimestamp = formatMessageTimestamp;
379
+ exports.pickShortLabel = pickShortLabel;
380
+ exports.pickDisplayName = pickDisplayName;
381
+ exports.GRAPH_LABEL_COLOURS = {
382
+ // Business identity — slate-blue family
383
+ LocalBusiness: "#4F6B8A",
384
+ Service: "#6B85A0",
385
+ PriceSpecification: "#8AA0B8",
386
+ OpeningHoursSpecification: "#A8BACE",
387
+ // Estate-agent ontology. Listing/Property share the business slate-blue
388
+ // family; Viewing/Offer are transactional events placed in a warm amber
389
+ // family distinct from Agent and from the dusty-rose Task/Project/Event
390
+ // hues so the legend reads them as a separate band.
391
+ Listing: "#3F5670",
392
+ Property: "#5C7A99",
393
+ Viewing: "#D4A574",
394
+ Offer: "#B08850",
395
+ // External business entity — schema:Organization, written by memory-write
396
+ // as the Supplier label. Warm tobacco — distinct hue from internal-business
397
+ // slates so external entities are scannable at a glance.
398
+ Organization: "#8A6B47",
399
+ // People — terracotta family (warm, human)
400
+ Person: "#B86E4A",
401
+ UserProfile: "#D08960",
402
+ Preference: "#DFA67A",
403
+ AdminUser: "#8C5230",
404
+ AccessGrant: "#66381F",
405
+ // Knowledge — moss family (organic)
406
+ KnowledgeDocument: "#6E8A5A",
407
+ // chunked WhatsApp/messaging archive parent. Sits in the
408
+ // knowledge moss family because it's structurally a document parent
409
+ // (HAS_SECTION → :Section:Conversation chunks); the conversational
410
+ // plum family is reserved for the live Conversation/Message labels.
411
+ ConversationArchive: "#82A06A",
412
+ Section: "#8AA876",
413
+ Chunk: "#A6C194",
414
+ DigitalDocument: "#5A7548",
415
+ CreativeWork: "#B5C9A2",
416
+ Question: "#C7D6B5",
417
+ FAQPage: "#95B385",
418
+ DefinedTerm: "#76906A",
419
+ Review: "#3F5A2E",
420
+ ImageObject: "#A0BB8C",
421
+ // Conversational — muted plum/lavender family.
422
+ // Pairwise-distinctness invariants enforced by the UI test
423
+ // graph-labels.test.ts; UserMessage matches Preference (Person/family cue,
424
+ // the one intentional duplicate in the registry).
425
+ Conversation: "#6B5A85",
426
+ AdminConversation: "#4F4070",
427
+ PublicConversation: "#8A75A8",
428
+ Message: "#6B7280",
429
+ UserMessage: "#DFA67A",
430
+ AssistantMessage: "#C9A876",
431
+ ToolCall: "#B5ABCB",
432
+ // Tasks / projects / events — dusty rose family
433
+ Task: "#B0617A",
434
+ Project: "#8E4A60",
435
+ Event: "#C68095",
436
+ // Workflows — muted teal
437
+ Workflow: "#3A6F77",
438
+ WorkflowStep: "#5A8E96",
439
+ WorkflowRun: "#7AAAB2",
440
+ StepResult: "#9CC4CB",
441
+ // Email — muted moss, hue-adjacent to Knowledge but lower-saturation
442
+ // and warmer; never co-rendered with KnowledgeDocument.
443
+ Email: "#6F7F4A",
444
+ EmailAccount: "#91A063",
445
+ // Public-agent projection — burnished bronze sits between
446
+ // people-terracotta and email-moss but shares neither hue.
447
+ Agent: "#B8893D"
448
+ };
449
+ exports.FALLBACK_LABEL_COLOUR = "#94A3B8";
450
+ exports.ALL_GRAPH_LABELS = Object.freeze(Object.keys(exports.GRAPH_LABEL_COLOURS));
451
+ function pickDisplayLabel2(labels) {
452
+ for (let i = 1; i < labels.length; i++) {
453
+ if (Object.prototype.hasOwnProperty.call(exports.GRAPH_LABEL_COLOURS, labels[i])) {
454
+ return labels[i];
455
+ }
456
+ }
457
+ return labels[0] ?? null;
458
+ }
459
+ function colourForLabel2(label) {
460
+ return exports.GRAPH_LABEL_COLOURS[label] ?? exports.FALLBACK_LABEL_COLOUR;
461
+ }
462
+ function resolveNodeColour2(labels) {
463
+ const displayLabel = pickDisplayLabel2(labels);
464
+ const colour = displayLabel ? colourForLabel2(displayLabel) : exports.FALLBACK_LABEL_COLOUR;
465
+ let driftCandidates = 0;
466
+ for (let i = 1; i < labels.length; i++) {
467
+ if (Object.prototype.hasOwnProperty.call(exports.GRAPH_LABEL_COLOURS, labels[i])) {
468
+ driftCandidates++;
469
+ }
470
+ }
471
+ return { displayLabel, colour, driftCandidates };
472
+ }
473
+ var ISO_MINUTE_RE = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/;
474
+ var ISO_SECOND_RE = /^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/;
475
+ function formatRunTimestamp(iso) {
476
+ const m = iso.match(ISO_MINUTE_RE);
477
+ if (!m)
478
+ return null;
479
+ return `${m[1]} ${m[2]}`;
480
+ }
481
+ function formatMessageTimestamp(iso) {
482
+ const m = iso.match(ISO_SECOND_RE);
483
+ if (!m)
484
+ return null;
485
+ return m[1];
486
+ }
487
+ function pickShortLabel(node) {
488
+ const props = node.properties;
489
+ const primaryLabel = node.labels[0];
490
+ if (primaryLabel === "ToolCall") {
491
+ const v = props.toolName;
492
+ if (typeof v === "string" && v.length > 0) {
493
+ return v.length > 24 ? v.slice(0, 24) + "\u2026" : v;
494
+ }
495
+ } else if (primaryLabel === "WorkflowRun") {
496
+ const v = props.startedAt;
497
+ if (typeof v === "string" && v.length > 0) {
498
+ const ts = formatRunTimestamp(v);
499
+ if (ts)
500
+ return ts;
501
+ }
502
+ } else if (primaryLabel === "WorkflowStep") {
503
+ const v = props.label;
504
+ if (typeof v === "string" && v.length > 0) {
505
+ return v.length > 24 ? v.slice(0, 24) + "\u2026" : v;
506
+ }
507
+ } else if (primaryLabel === "Person") {
508
+ const given = typeof props.givenName === "string" ? props.givenName : "";
509
+ const family = typeof props.familyName === "string" ? props.familyName : "";
510
+ const full = [given, family].filter((s) => s.length > 0).join(" ");
511
+ if (full.length > 0) {
512
+ return full.length > 24 ? full.slice(0, 24) + "\u2026" : full;
513
+ }
514
+ } else if (primaryLabel === "Agent") {
515
+ const dn = typeof props.displayName === "string" ? props.displayName : "";
516
+ const slug = typeof props.slug === "string" ? props.slug : "";
517
+ const v = dn.length > 0 ? dn : slug;
518
+ if (v.length > 0) {
519
+ return v.length > 24 ? v.slice(0, 24) + "\u2026" : v;
520
+ }
521
+ } else if (primaryLabel === "Message") {
522
+ const role = typeof props.role === "string" ? props.role : "";
523
+ const roleShort = role === "user" ? "user" : role === "assistant" ? "asst" : role === "system" ? "sys" : role === "tool" ? "tool" : null;
524
+ const createdAt = typeof props.createdAt === "string" ? props.createdAt : "";
525
+ if (roleShort && createdAt) {
526
+ const ts = formatMessageTimestamp(createdAt);
527
+ if (ts)
528
+ return `${roleShort} ${ts}`;
529
+ }
530
+ } else if (primaryLabel === "ConversationArchive") {
531
+ const t = typeof props.title === "string" ? props.title : "";
532
+ if (t.length > 0) {
533
+ return t.length > 24 ? t.slice(0, 24) + "\u2026" : t;
534
+ }
535
+ return primaryLabel;
536
+ }
537
+ for (const k of ["name", "title", "summary", "givenName", "subject", "text"]) {
538
+ const v = props[k];
539
+ if (typeof v === "string" && v.length > 0) {
540
+ return v.length > 24 ? v.slice(0, 24) + "\u2026" : v;
541
+ }
542
+ }
543
+ if (primaryLabel === "Conversation") {
544
+ const id = typeof props.conversationId === "string" ? props.conversationId : null;
545
+ if (id)
546
+ return `Conv ${id.slice(0, 8)}`;
547
+ }
548
+ return primaryLabel ?? "\u2026";
549
+ }
550
+ function pickDisplayName(node) {
551
+ const props = node.properties;
552
+ const primaryLabel = node.labels[0];
553
+ if (primaryLabel === "ToolCall") {
554
+ const v = props.toolName;
555
+ if (typeof v === "string" && v.length > 0)
556
+ return v;
557
+ } else if (primaryLabel === "WorkflowRun") {
558
+ const v = props.startedAt;
559
+ if (typeof v === "string" && v.length > 0) {
560
+ const ts = formatRunTimestamp(v);
561
+ if (ts)
562
+ return ts;
563
+ }
564
+ } else if (primaryLabel === "WorkflowStep") {
565
+ const v = props.label;
566
+ if (typeof v === "string" && v.length > 0)
567
+ return v;
568
+ } else if (primaryLabel === "Person") {
569
+ const given = typeof props.givenName === "string" ? props.givenName : "";
570
+ const family = typeof props.familyName === "string" ? props.familyName : "";
571
+ const full = [given, family].filter((s) => s.length > 0).join(" ");
572
+ if (full.length > 0)
573
+ return full;
574
+ } else if (primaryLabel === "Agent") {
575
+ const dn = typeof props.displayName === "string" ? props.displayName : "";
576
+ const slug = typeof props.slug === "string" ? props.slug : "";
577
+ const v = dn.length > 0 ? dn : slug;
578
+ if (v.length > 0)
579
+ return v;
580
+ } else if (primaryLabel === "ConversationArchive") {
581
+ const t = typeof props.title === "string" ? props.title : "";
582
+ if (t.length > 0)
583
+ return t;
584
+ return primaryLabel;
585
+ }
586
+ for (const k of ["name", "title", "summary", "givenName", "subject", "text"]) {
587
+ const v = props[k];
588
+ if (typeof v === "string" && v.length > 0)
589
+ return v;
590
+ }
591
+ if (primaryLabel === "Conversation") {
592
+ const id = typeof props.conversationId === "string" ? props.conversationId : null;
593
+ if (id)
594
+ return `Conv ${id.slice(0, 8)}`;
595
+ }
596
+ return primaryLabel ?? "\u2026";
597
+ }
598
+ }
599
+ });
600
+
368
601
  // node_modules/hono/dist/utils/mime.js
369
602
  var getMimeType = (filename, mimes = baseMimes) => {
370
603
  const regexp = /\.([a-zA-Z0-9]+?)$/;
@@ -9943,97 +10176,8 @@ var graph_search_default = app19;
9943
10176
  import neo4j from "neo4j-driver";
9944
10177
 
9945
10178
  // app/lib/graph-labels.ts
9946
- var GRAPH_LABEL_COLOURS = {
9947
- // Business identity slate-blue family
9948
- LocalBusiness: "#4F6B8A",
9949
- Service: "#6B85A0",
9950
- PriceSpecification: "#8AA0B8",
9951
- OpeningHoursSpecification: "#A8BACE",
9952
- // Estate-agent ontology (Task 358). :Listing and :Property
9953
- // share the business slate-blue family (they describe a business's
9954
- // inventory). :Viewing and :Offer are transactional events — placed in
9955
- // a warm amber family distinct from Agent (#B8893D) and the dusty-rose
9956
- // Task/Project/Event hues so the legend reads them as a separate band.
9957
- Listing: "#3F5670",
9958
- Property: "#5C7A99",
9959
- Viewing: "#D4A574",
9960
- Offer: "#B08850",
9961
- // External business entity — schema:Organization, written by memory-write
9962
- // as the Supplier label (per platform/plugins/memory/references/schema-base.md).
9963
- // Warm tobacco — distinct hue from internal-business slates so external
9964
- // entities are scannable at a glance.
9965
- Organization: "#8A6B47",
9966
- // People — terracotta family (warm, human)
9967
- Person: "#B86E4A",
9968
- UserProfile: "#D08960",
9969
- Preference: "#DFA67A",
9970
- AdminUser: "#8C5230",
9971
- AccessGrant: "#66381F",
9972
- // Knowledge — moss family (organic)
9973
- KnowledgeDocument: "#6E8A5A",
9974
- // chunked WhatsApp/messaging archive parent. Sits in the
9975
- // knowledge moss family because it's structurally a document parent
9976
- // (HAS_SECTION → :Section:Conversation chunks); the conversational
9977
- // plum family is reserved for the live Conversation/Message labels.
9978
- ConversationArchive: "#82A06A",
9979
- Section: "#8AA876",
9980
- Chunk: "#A6C194",
9981
- DigitalDocument: "#5A7548",
9982
- CreativeWork: "#B5C9A2",
9983
- Question: "#C7D6B5",
9984
- FAQPage: "#95B385",
9985
- DefinedTerm: "#76906A",
9986
- Review: "#3F5A2E",
9987
- ImageObject: "#A0BB8C",
9988
- // Conversational — muted plum/lavender family
9989
- //
9990
- // Pairwise-distinctness invariants (carried forward
9991
- // palette):
9992
- // - Four sublabelled conversation/message labels (AdminConversation,
9993
- // PublicConversation, UserMessage, AssistantMessage) are pairwise
9994
- // distinct on canvas.
9995
- // - UserMessage matches Preference (Person/family cue: a user-authored
9996
- // message inherits the person family colour). This is the one
9997
- // intentional duplicate in the registry — see the
9998
- // `INTENTIONAL_DUPLICATES` set in `graph-labels.test.ts`.
9999
- // - Conversation base distinct from both AdminConversation and
10000
- // PublicConversation so base-Conversation rows don't visually
10001
- // collide with the sublabelled split.
10002
- // - Message base distinct from PublicConversation (`#A78BFA`
10003
- // collision class).
10004
- Conversation: "#6B5A85",
10005
- AdminConversation: "#4F4070",
10006
- PublicConversation: "#8A75A8",
10007
- Message: "#6B7280",
10008
- UserMessage: "#DFA67A",
10009
- AssistantMessage: "#C9A876",
10010
- ToolCall: "#B5ABCB",
10011
- // Tasks / projects / events — dusty rose family
10012
- Task: "#B0617A",
10013
- Project: "#8E4A60",
10014
- Event: "#C68095",
10015
- // Workflows — muted teal
10016
- Workflow: "#3A6F77",
10017
- WorkflowStep: "#5A8E96",
10018
- WorkflowRun: "#7AAAB2",
10019
- StepResult: "#9CC4CB",
10020
- // Email — muted moss (hue-adjacent to Knowledge but lower-saturation
10021
- // and warmer; never co-rendered with KnowledgeDocument so visual
10022
- // confusion doesn't apply, but kept distinguishable for the legend)
10023
- Email: "#6F7F4A",
10024
- EmailAccount: "#91A063",
10025
- // Public-agent projection — burnished bronze sits between
10026
- // people-terracotta and email-moss but shares neither hue, signalling
10027
- // "operator-defined persona that traverses to KnowledgeDocuments,
10028
- // Conversations, and other entities" without colliding with any existing
10029
- // family. Pairs with the four owned KnowledgeDocument projections rendered
10030
- // in the moss family — visual contrast cues the operator that the agent
10031
- // node is a different kind of thing from its IDENTITY/SOUL/KNOWLEDGE docs.
10032
- Agent: "#B8893D"
10033
- };
10034
- var ALL_GRAPH_LABELS = Object.freeze(
10035
- Object.keys(GRAPH_LABEL_COLOURS)
10036
- );
10179
+ var import_dist2 = __toESM(require_dist2(), 1);
10180
+ var import_dist3 = __toESM(require_dist2(), 1);
10037
10181
  var HIDDEN_BY_DEFAULT_LABELS = Object.freeze(
10038
10182
  /* @__PURE__ */ new Set(["Chunk", "GraphPreference"])
10039
10183
  );
@@ -10089,7 +10233,7 @@ var EXCLUDED_EDGE_TYPES = Object.freeze(
10089
10233
  ])
10090
10234
  );
10091
10235
  function isKnownLabel(label) {
10092
- return Object.prototype.hasOwnProperty.call(GRAPH_LABEL_COLOURS, label);
10236
+ return Object.prototype.hasOwnProperty.call(import_dist3.GRAPH_LABEL_COLOURS, label);
10093
10237
  }
10094
10238
  function isHiddenByDefault(label) {
10095
10239
  return HIDDEN_BY_DEFAULT_LABELS.has(label);
@@ -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,g as a,h as o,m as s,p as c,r as l,t as u,u as d,y as f}from"./ChatInput-CJo_77bp.js";var p=a(`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`}]]),m=a(`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`}]]),h=a(`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`}]]),g=a(`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`}]]),_=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),v=a(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),y=a(`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`}]]),b=a(`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`}]]),x=a(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),S=a(`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`}]]),C=a(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),w=a(`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`}]]),T=a(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),E=a(`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`}]]),ee=a(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),D=a(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),O=a(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),k=a(`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`}]]),te=a(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),ne=a(`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`}]]),re=a(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ie=a(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ae=a(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),oe=a(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),A=e(f(),1),j=d(),M=`maxy-shell-side-px`;function N(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function P(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-N());return Math.min(Math.max(e,248),n)}function se(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(M);if(!e)return 264;let t=parseInt(e,10);if(Number.isFinite(t)&&t>=248)return P(t)}catch{}return 264}function ce({targetSelector:e=`.platform`}){let t=(0,A.useRef)(null),[n,r]=(0,A.useState)(()=>se()),i=(0,A.useRef)(n);(0,A.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,A.useCallback)(()=>{r(e=>{let t=P(e);return t===e?e:t})},[]);(0,A.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(P(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(M,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=P(264);r(e);try{window.localStorage.removeItem(M)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,j.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var le=!1;function ue(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function de(){let e=typeof crypto<`u`&&typeof crypto.randomUUID==`function`;if(!le){le=!0;let t=typeof window<`u`&&`isSecureContext`in window?window.isSecureContext:!1;console.info(`[idempotency] uuid-source=${e?`native`:`getRandomValues`} secureContext=${t}`)}return e?crypto.randomUUID():ue()}function fe(e){let t=e.trim();return t.length>=1&&t.length<=200}function F(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 pe=/session_([A-Za-z0-9_-]+)/;function me(e){if(!e)return null;let t=e.match(pe);return t?t[1]:null}async function he(e,t,n,r,i){let a=me(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 ge(e,t,n=`pane`){let[r,i]=(0,A.useState)(null),a=(0,A.useRef)(!1),o=(0,A.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};if(a.current)return F(n,`resume`,r,`skipped-in-flight`),{ok:!1,error:`in-flight`};a.current=!0,i(`resume`);let o=de();try{let i=await fetch(`/api/admin/claude-sessions/resume?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:r,channel:`browser`,idempotencyKey:o})}),a=await i.json();if(!i.ok||!(`sessionId`in a)){let e=a.error??`POST returned ${i.status}`;return F(n,`resume`,r,String(i.status)),{ok:!1,error:e}}return t.setSessions(e=>[a,...e.filter(e=>e.sessionId!==r)]),F(n,`resume`,r,`200`),he(e,n,r,a.url,t),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return F(n,`resume`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{a.current=!1,i(null)}},[e,t,n]),s=(0,A.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)}/stop?session_key=${encodeURIComponent(e)}`,{method:`POST`});if(!i.ok){let e=await i.text().catch(()=>``);return F(n,`end`,r,String(i.status)),t.refetch(),{ok:!1,error:`POST /stop ${i.status} ${e.slice(0,200)}`}}return F(n,`end`,r,`204`),t.refetch(),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return F(n,`end`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{i(null)}},[e,t,n]),c=(0,A.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 F(n,`purge`,r,String(i.status)),{ok:!1,error:t}}return t.setSessions(e=>e.filter(e=>e.sessionId!==r)),F(n,`purge`,r,`200`),t.refetch(),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return F(n,`purge`,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]),l=(0,A.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 F(n,a,r,String(i.status)),{ok:!1,error:t}}return a===`archive`&&t.setSessions(e=>e.filter(e=>e.sessionId!==r)),t.refetch(),F(n,a,r,`200`),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return F(n,a,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]);return{inFlight:r,resume:o,end:s,purge:c,archive:(0,A.useCallback)(e=>l(e,`archive`),[l]),unarchive:(0,A.useCallback)(e=>l(e,`unarchive`),[l]),rename:(0,A.useCallback)(async(t,r)=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`rename`);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(t)}/rename?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:r})});if(!i.ok){let e=await i.json().catch(()=>({})),r=e.detail||e.error||`POST /rename ${i.status}`;return F(n,`rename`,t,String(i.status)),{ok:!1,error:r,reason:e.reason}}return F(n,`rename`,t,`200`),{ok:!0}}catch(e){let r=e instanceof Error?e.message:String(e);return F(n,`rename`,t,`threw`),{ok:!1,error:r}}finally{i(null)}},[e,n])}}function _e(e){return`code.session.pinned.${e}`}function ve(e){if(typeof window>`u`)return new Set;try{let t=window.localStorage.getItem(_e(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 I(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(_e(e),JSON.stringify([...t]))}catch{}}function ye(e){let[t,n]=(0,A.useState)(()=>ve(e));(0,A.useEffect)(()=>{n(ve(e))},[e]);let r=(0,A.useCallback)(t=>{n(n=>{let r=new Set(n);return r.has(t)?r.delete(t):r.add(t),I(e,r),r})},[e]);return{pinned:t,isPinned:(0,A.useCallback)(e=>t.has(e),[t]),togglePin:r}}function be(e){let{businessName:i,onNavigate:a,onToggleSidebar:o,sidebarOpen:s,onLogout:c}=e,[l,u]=(0,A.useState)(!1),d=(0,A.useRef)(null),f=(0,A.useRef)(null),[p,m]=(0,A.useState)(null),[h,g]=(0,A.useState)(!1),[v,S]=(0,A.useState)(null),[D,O]=(0,A.useState)(null),[k,te]=(0,A.useState)(null),[re,ie]=(0,A.useState)(``);(0,A.useEffect)(()=>{ie(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,A.useEffect)(()=>{if(!l)return;let e=e=>{d.current&&!d.current.contains(e.target)&&u(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]),(0,A.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,A.useEffect)(()=>{l&&f.current?.focus()},[l]),(0,A.useEffect)(()=>{if(!l)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||te(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[l]);let ae=(0,A.useCallback)(()=>{u(e=>{let t=!e;return t&&console.info(`[admin-ui] header-menu-open`),t})},[]),M=(0,A.useCallback)(e=>{u(!1),a(e)},[a]),N=(0,A.useCallback)(async()=>{if(p!==null){m(null),O(null);return}g(!0),S(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);m((await e.json()).agents??[])}catch(e){console.error(`[admin/agents] list failed:`,e),S(e instanceof Error?e.message:String(e)),m([])}finally{g(!1)}},[p]),P=(0,A.useCallback)(e=>{O(null),m(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))},[]),se=(0,A.useCallback)(()=>{u(!1),c()},[c]),ce=i||t.productName;return(0,j.jsxs)(`header`,{className:`admin-header`,children:[(0,j.jsx)(`button`,{type:`button`,className:`admin-sidebar-toggle`,"aria-label":s?`Hide sidebar`:`Show sidebar`,title:s?`Hide sidebar`:`Show sidebar`,"aria-expanded":s,onClick:o,children:s?(0,j.jsx)(E,{size:20,strokeWidth:1.5}):(0,j.jsx)(ee,{size:20,strokeWidth:1.5})}),(0,j.jsxs)(`div`,{className:`chat-header-label`,children:[(0,j.jsx)(`span`,{className:`chat-logo-btn`,"aria-hidden":`true`,children:(0,j.jsx)(`img`,{src:n,alt:``,className:`chat-logo`})}),(0,j.jsx)(`h1`,{className:`chat-tagline`,children:ce})]}),(0,j.jsxs)(`div`,{className:`chat-burger-wrap`,ref:d,children:[(0,j.jsx)(`button`,{type:`button`,className:`admin-burger`,onClick:ae,"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":l,children:(0,j.jsx)(T,{size:20})}),l&&(0,j.jsxs)(`div`,{className:`admin-menu`,role:`menu`,children:[(0,j.jsxs)(`button`,{ref:f,type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>M(`data`),children:[(0,j.jsx)(y,{size:14}),` Data`]}),(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>M(`graph`),children:[(0,j.jsx)(ne,{size:14}),` Graph`]}),(0,j.jsx)(`div`,{className:`chat-menu-divider`}),(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:N,children:[(0,j.jsx)(b,{size:14}),` Public`,h&&(0,j.jsx)(C,{size:12,className:`spin`})]}),p!==null&&(0,j.jsxs)(`div`,{className:`chat-menu-agents`,children:[v&&(0,j.jsx)(`span`,{className:`chat-menu-agent-error`,children:v}),p.length===0&&!v&&(0,j.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),p.map(e=>(0,j.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,j.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,j.jsxs)(`span`,{className:`agent-text`,children:[(0,j.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,j.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),D===e.slug?(0,j.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,j.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>P(e.slug),children:(0,j.jsx)(_,{size:12})}),(0,j.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>O(null),children:(0,j.jsx)(oe,{size:12})})]}):(0,j.jsxs)(`span`,{className:`agent-actions`,children:[(0,j.jsx)(`a`,{href:`${re}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>u(!1),children:(0,j.jsx)(b,{size:12})}),(0,j.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>O(e.slug),children:(0,j.jsx)(r,{size:12})})]})]},e.slug))]}),(0,j.jsx)(`div`,{className:`chat-menu-divider`}),(0,j.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,j.jsx)(x,{size:14}),(0,j.jsxs)(`span`,{className:`version-installed`,children:[k?`v${k.installed}`:`…`,k&&!k.updateAvailable&&(0,j.jsx)(`span`,{className:`version-uptodate-dot`}),k?.updateAvailable&&(0,j.jsx)(`span`,{className:`version-update-dot`})]})]}),(0,j.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:se,children:[(0,j.jsx)(w,{size:14}),` Log out`]})]})]})]})}var L=`maxy-admin-session`,R=typeof BroadcastChannel<`u`;function xe(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 Se(e){if(!R)return()=>{};let t=new BroadcastChannel(L),n=t=>{if(!xe(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 z=`maxy-admin-session-key`;function Ce(e,t){return`${e}${e.includes(`?`)?`&`:`?`}session_key=${encodeURIComponent(t)}`}async function B(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 we(){try{return sessionStorage.getItem(z)}catch{return null}}function Te(e){let{initialCacheKey:t,surface:n}=e,[r,i]=(0,A.useState)(t),a=(0,A.useRef)(t);(0,A.useEffect)(()=>{a.current=r},[r]),(0,A.useEffect)(()=>{t!==a.current&&(i(t),a.current=t,s(e=>e+1))},[t]);let[o,s]=(0,A.useState)(0),[c,l]=(0,A.useState)(null);(0,A.useEffect)(()=>Se(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,A.useCallback)(()=>{try{sessionStorage.removeItem(z)}catch{}window.location.href=`/`},[]);return{adminFetch:(0,A.useCallback)(async(e,t)=>{let r=a.current,o=Ce(e,r),c=await fetch(o,t);if(c.status!==401)return c;let d=await B(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=we();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=Ce(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 V=`/api/admin/claude-sessions/events`,H=`admin-session-list-view`,Ee=`admin-session-list-include-subagents`,U=`admin-session-list-include-background`;function De(e){return e===`active`||e===`archived`||e===`all`}function Oe(){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`:r.status===`detached`?`detached`:`gone`,agentLabel:typeof r.agentLabel==`string`&&r.agentLabel.length>0?r.agentLabel:null,cwd:typeof r.cwd==`string`?r.cwd:null,firstPrompt:typeof r.firstPrompt==`string`&&r.firstPrompt.length>0?r.firstPrompt:null,titleSource:r.titleSource===`user`||r.titleSource===`ai`?r.titleSource:null,updatedAt:typeof r.updatedAt==`number`?r.updatedAt:0,url:typeof r.url==`string`&&r.url.length>0?r.url:null,archived:r.archived===!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=Ce(V,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 B(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(H);De(t)&&(e={...e,view:t});let n=window.localStorage.getItem(Ee);if(n===null){let e=window.localStorage.getItem(U);e!==null&&(window.localStorage.setItem(Ee,e),window.localStorage.removeItem(U),n=e,console.info(`[admin-ui] session-list-storage-migrated from=${U} to=${Ee} value=${e}`))}n===`1`&&(e={...e,includeBackground:!0})}catch{}}function v(t){e={...e,view:t};try{window.localStorage.setItem(H,t)}catch{}d()}function y(t){e={...e,includeBackground:t};try{window.localStorage.setItem(Ee,t?`1`:`0`)}catch{}d()}function b(e){return n.add(e),()=>{n.delete(e)}}function x(){return e}function S(){r&&=(r.close(),null),i&&=(clearTimeout(i),null),s=null,e={...e,connected:!1}}function C(e,t){f(e,t)}function w(t){e={...e,connected:t},d()}function T(){t.clear(),u(),d()}function E(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:b,getSnapshot:x,connect:p,disconnect:S,setView:v,setIncludeBackground:y,reconnectNow:g,reconcileFromList:E,_injectEventForTesting:C,_setConnectedForTesting:w,_clearRowsForTesting:T}}var W=Oe();W._injectEventForTesting,W.connect,W._setConnectedForTesting,W.getSnapshot,W.reconcileFromList;function ke(e){let t=(0,A.useSyncExternalStore)(W.subscribe,W.getSnapshot,W.getSnapshot);(0,A.useEffect)(()=>{e&&W.connect(e)},[e]);let n=(0,A.useCallback)(e=>W.setView(e),[]),r=(0,A.useCallback)(e=>W.setIncludeBackground(e),[]),i=(0,A.useCallback)(()=>W.reconnectNow(),[]),a=(0,A.useCallback)(e=>W.reconcileFromList(e),[]);return{rows:t.rows,view:t.view,includeBackground:t.includeBackground,connected:t.connected,setView:n,setIncludeBackground:r,reconnectNow:i,reconcileFromList:a}}function Ae(e,t,n){return e.filter(e=>!(t===`active`&&e.archived||t===`archived`&&!e.archived||!n&&e.agentLabel!==null&&e.agentLabel!==`admin`))}var G=6e4,je=60*G,Me=24*je,K=G,Ne=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],q=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function Pe(e){return e<10?`0${e}`:String(e)}function Fe(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function Ie(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-K)return`—`;let r=n<0?0:n;if(r<G)return`just now`;if(r<je)return`${Math.floor(r/G)}m`;if(r<Me)return`${Math.floor(r/je)}h`;let i=new Date(t),a=new Date(e),o=Math.round((Fe(i)-Fe(a))/Me);if(o===1)return`yesterday`;if(o>=2&&o<=6)return q[a.getDay()];let s=Pe(a.getDate()),c=Ne[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}function Le(e=3e4){let[t,n]=(0,A.useState)(()=>Date.now());return(0,A.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Re={default:`Ask`,acceptEdits:`Accept edits`,plan:`Plan`,auto:`Auto`,bypassPermissions:`Bypass permissions`},ze=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],Be=`Plan does not include auto mode`,Ve=[{value:void 0,label:`Default`},{value:`claude-opus-4-7`,label:`Opus 4.7`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`},{value:`claude-haiku-4-5`,label:`Haiku 4.5`}];function He({seedMode:e,seedModel:t,submitting:n,error:r,onSubmit:i,onCancel:a,onErrorClear:s}){let[c,l]=(0,A.useState)(``),[d,f]=(0,A.useState)(e),[p,m]=(0,A.useState)(t),[h,g]=(0,A.useState)(!1),[y,b]=(0,A.useState)(!1),[x,S]=(0,A.useState)(null),w=(0,A.useRef)(null),T=(0,A.useRef)(null),E=(0,A.useRef)(null);(0,A.useEffect)(()=>{w.current?.focus()},[]),(0,A.useEffect)(()=>{let e=!1,t=Date.now();return(async()=>{try{let n=await fetch(`/api/admin/claude-capabilities`);if(!n.ok)throw Error(`status ${n.status}`);let r=await n.json();if(e)return;S(r.autoModeAvailable),console.info(`[admin-ui] capability-fetch ok=true autoModeAvailable=${r.autoModeAvailable} seatTier=${r.seatTier??`null`} ms=${Date.now()-t}`)}catch(n){if(e)return;let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] capability-fetch ok=false reason="${r}" ms=${Date.now()-t}`)}})(),()=>{e=!0}},[]);let ee=(0,A.useMemo)(()=>e=>e===`auto`&&x===!1,[x]);(0,A.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(h){g(!1),e.stopPropagation();return}if(y){b(!1),e.stopPropagation();return}a(`esc`)}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[h,y,a]),(0,A.useEffect)(()=>{if(!h&&!y)return;function e(e){h&&T.current&&!T.current.contains(e.target)&&g(!1),y&&E.current&&!E.current.contains(e.target)&&b(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h,y]);let D=c.trim(),O=D.length>0&&!n,k=(0,A.useCallback)(()=>{if(D.length===0||n)return;let e=window.open(`about:blank`,`_blank`);console.info(`[admin-ui] new-session-modal-placeholder-open outcome=${e===null?`blocked`:`ok`}`),i({message:c,permissionMode:d,model:p,placeholder:e})},[c,d,p,D,n,i]);function te(e){e.preventDefault(),k()}let ne=Ve.find(e=>e.value===p)?.label??`Default`;return(0,j.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-modal-title`,className:`new-session-modal-overlay`,onClick:e=>{e.target===e.currentTarget&&a(`backdrop`)},children:(0,j.jsxs)(`div`,{className:`new-session-modal`,children:[(0,j.jsx)(`h2`,{id:`new-session-modal-title`,className:`new-session-modal-title`,children:`New session`}),(0,j.jsxs)(`form`,{className:`new-session-modal-form`,onSubmit:te,children:[(0,j.jsx)(`div`,{className:`chat-form`,children:(0,j.jsx)(u,{ref:w,value:c,onChange:e=>{l(e),r&&s()},placeholder:`What should this session do?`,disabled:n})}),r&&(0,j.jsx)(`div`,{className:`tunnel-route__error`,role:`alert`,children:r}),(0,j.jsxs)(`div`,{className:`new-session-modal-actions`,children:[(0,j.jsxs)(`div`,{className:`new-session-modal-pickers`,children:[(0,j.jsxs)(`div`,{className:`new-session-modal-picker-wrap`,ref:T,children:[(0,j.jsxs)(`button`,{type:`button`,className:`side-mode-trigger`,onClick:()=>{let e=!h;console.info(`[admin-ui] new-session-modal-mode-picker action=${e?`open`:`close`} current=${d}`),g(e)},disabled:n,"aria-haspopup":`menu`,"aria-expanded":h,"aria-label":`Permission mode for this session`,children:[Re[d],(0,j.jsx)(o,{size:12,"aria-hidden":`true`})]}),h&&(0,j.jsxs)(`div`,{className:`side-mode-popover`,role:`menu`,"aria-label":`Mode`,children:[(0,j.jsx)(`div`,{className:`side-mode-popover-head`,children:(0,j.jsx)(`span`,{children:`Mode`})}),ze.map((e,t)=>{let n=ee(e);return(0,j.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`side-mode-popover-item`,disabled:n,title:n?Be:void 0,"aria-disabled":n||void 0,onClick:()=>{n||(console.info(`[admin-ui] new-session-modal-mode-change from=${d} to=${e} trigger=click`),f(e),g(!1))},children:[(0,j.jsx)(`span`,{children:Re[e]}),(0,j.jsxs)(`span`,{className:`side-mode-popover-shortcut`,children:[e===d&&(0,j.jsx)(_,{size:12}),(0,j.jsx)(`span`,{children:t+1})]})]},e)})]})]}),(0,j.jsxs)(`div`,{className:`new-session-modal-picker-wrap`,ref:E,children:[(0,j.jsxs)(`button`,{type:`button`,className:`side-mode-trigger`,onClick:()=>{let e=!y;console.info(`[admin-ui] new-session-modal-model-picker action=${e?`open`:`close`} current=${p??`default`}`),b(e)},disabled:n,"aria-haspopup":`menu`,"aria-expanded":y,"aria-label":`Model for this session`,children:[ne,(0,j.jsx)(o,{size:12,"aria-hidden":`true`})]}),y&&(0,j.jsxs)(`div`,{className:`side-mode-popover`,role:`menu`,"aria-label":`Model`,children:[(0,j.jsx)(`div`,{className:`side-mode-popover-head`,children:(0,j.jsx)(`span`,{children:`Model`})}),Ve.map(e=>(0,j.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`side-mode-popover-item`,onClick:()=>{console.info(`[admin-ui] new-session-modal-model-change from=${p??`default`} to=${e.value??`default`} trigger=click`),m(e.value),b(!1)},children:[(0,j.jsx)(`span`,{children:e.label}),(0,j.jsx)(`span`,{className:`side-mode-popover-shortcut`,children:e.value===p&&(0,j.jsx)(_,{size:12})})]},e.label))]})]})]}),(0,j.jsxs)(`div`,{className:`new-session-modal-buttons`,children:[(0,j.jsx)(`button`,{type:`button`,className:`modal-action-btn`,onClick:()=>a(`button`),disabled:n,children:`Cancel`}),(0,j.jsx)(`button`,{type:`submit`,className:`new-session-modal-submit`,disabled:!O,"aria-label":`Send`,children:n?(0,j.jsx)(C,{size:14,className:`spinning`}):(0,j.jsx)(v,{size:14})})]})]})]})]})})}var Ue=1e4,We=(0,A.forwardRef)(function(e,n){let{businessName:a,cacheKey:u,role:d,userName:f,userAvatar:v,sessions:y,sessionsLoading:x,sessionsError:w,ensureSessionsLoaded:T,refetchSessions:E,onSelectArtefact:ee,onSelectProjects:te,onSelectPeople:ne,onSelectTasks:oe,onSelectAgents:M,onCloseMobileDrawer:N,onSelectSession:P,selectedSessionId:se,collapsed:ce,mobileDrawerOpen:le,recentsActions:ue}=e,[de,F]=(0,A.useState)(null),[pe,me]=(0,A.useState)(null),[he,_e]=(0,A.useState)(!1);(0,A.useEffect)(()=>{T()},[T]);let ve=(0,A.useRef)(null),[I,be]=(0,A.useState)(!1),[L,R]=(0,A.useState)(`default`),[xe,Se]=(0,A.useState)(void 0),z=(0,A.useRef)(null),[Ce,B]=(0,A.useState)(null),[we,Te]=(0,A.useState)(!1),V=(0,A.useRef)(0),H=(0,A.useRef)(new Map),Ee=t.productName,U=typeof f==`string`?f:f===null?`name unavailable`:a||Ee,De=(U.trim().charAt(0)||`?`).toUpperCase(),Oe=ye(t.hostname),W=ke(u),G=(0,A.useMemo)(()=>{let e=Ae(W.rows,W.view,W.includeBackground);if(Oe.pinned.size===0)return e;let t=[],n=[];for(let r of e)(Oe.pinned.has(r.sessionId)?t:n).push(r);return[...t,...n]},[W.rows,W.view,W.includeBackground,Oe.pinned]),je=G.length,Me=Le(3e4);(0,A.useEffect)(()=>{if(H.current.size!==0)for(let e of W.rows){let t=H.current.get(e.sessionId);if(!t||e.url===null)continue;H.current.delete(e.sessionId),clearTimeout(t.timeoutId);let n=e.sessionId.slice(0,8);if(t.placeholder.closed){console.info(`[admin-ui] new-session-auto-open outcome=timeout sessionId=${n}`);continue}t.placeholder.location.href=e.url,console.info(`[admin-ui] new-session-auto-open outcome=ok sessionId=${n}`)}},[W.rows]),(0,A.useEffect)(()=>{let e=H.current;return()=>{for(let{timeoutId:t}of e.values())clearTimeout(t);e.clear()}},[]);let[K,Ne]=(0,A.useState)(`chat`),[q,Pe]=(0,A.useState)([]),[Fe,Re]=(0,A.useState)(!1),[ze,Be]=(0,A.useState)(null),[Ve,We]=(0,A.useState)(!1);(0,A.useImperativeHandle)(n,()=>({patchArtefact(e,t){Pe(n=>n.map(n=>n.id===e?{...n,...t}:n))}}),[]);let[J,Y]=(0,A.useState)(!1),Ye=(0,A.useRef)(null),Xe={default:`Ask`,acceptEdits:`Accept edits`,plan:`Plan`,auto:`Auto`,bypassPermissions:`Bypass permissions`},Ze=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`];(0,A.useEffect)(()=>{if(!u)return;let e=!1,t=Date.now();return(async()=>{try{let n=await fetch(`/api/admin/session-defaults?session_key=${encodeURIComponent(u)}`);if(!n.ok)throw Error(`status ${n.status}`);let r=await n.json();if(e)return;let i=r.permissionMode,a=r.model??void 0;R(i),Se(a),z.current={permissionMode:i,model:a},console.info(`[admin-ui] session-defaults-hydrate permissionMode=${i} model=${a??`default`} ms=${Date.now()-t}`)}catch(n){if(e)return;let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] session-defaults-hydrate-failed reason="${r}" ms=${Date.now()-t}`)}})(),()=>{e=!0}},[u]);let X=(0,A.useCallback)(async(e,t)=>{if(!u||!z.current)return;let n=z.current,r=Date.now();console.info(`[admin-ui] session-defaults-put from={mode:${n.permissionMode},model:${n.model??`default`}} to={mode:${e.permissionMode},model:${e.model??`default`}} trigger=${t}`);try{let t=await fetch(`/api/admin/session-defaults?session_key=${encodeURIComponent(u)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({permissionMode:e.permissionMode,model:e.model??null})});if(!t.ok)throw Error(`status ${t.status}`);z.current=e,console.info(`[admin-ui] session-defaults-put-ok ms=${Date.now()-r}`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] session-defaults-put-failed reason="${t}" ms=${Date.now()-r}`),R(n.permissionMode),Se(n.model)}},[u]);(0,A.useEffect)(()=>{if(!J)return;function e(e){Ye.current&&!Ye.current.contains(e.target)&&(console.info(`[admin-ui] sidebar-mode-picker action=close mode=${L}`),Y(!1))}function t(e){if(e.key===`Escape`){console.info(`[admin-ui] sidebar-mode-picker action=close mode=${L}`),Y(!1);return}let t=[`1`,`2`,`3`,`4`,`5`].indexOf(e.key);if(t>=0&&!e.metaKey&&!e.ctrlKey&&!e.altKey){let n=Ze[t];n&&(e.preventDefault(),console.info(`[admin-ui] sidebar-mode-picker action=select mode=${n} via=shortcut`),R(n),Y(!1),X({permissionMode:n,model:xe},`sidebar`))}}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[J,L,xe,X]),(0,A.useEffect)(()=>{function e(e){e.shiftKey&&(e.metaKey||e.ctrlKey)&&(e.key===`m`||e.key===`M`)&&(e.preventDefault(),Y(e=>{let t=!e;return console.info(`[admin-ui] sidebar-mode-picker action=${t?`open`:`close`} mode=${L} via=shortcut`),t}))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L]);let Z=(0,A.useCallback)(async()=>{if(u){We(!0),Be(null);try{let e=await fetch(`/api/admin/sidebar-artefacts?session_key=${encodeURIComponent(u)}`);if(!e.ok)throw Error(`status ${e.status}`);Pe((await e.json()).artefacts??[]),Re(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Be(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{We(!1)}}},[u]),Qe=()=>{Ne(`chat`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${je}`)},$e=()=>{Ne(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${Fe?q.length:0} collapsed=${ce}`),Fe||Z()},Q=1.5,et=K===`chat`?`Sessions`:`Artefacts`,tt=K===`chat`?x?`…`:String(je):Ve?`…`:String(q.length),nt=K===`chat`?x:Ve,rt=()=>{console.info(`[admin-ui] sidebar-refresh surface=${K}`),K===`chat`?E().then(e=>{e!==null&&W.reconcileFromList(e.map(e=>e.sessionId))}):Z()},it=(0,A.useCallback)(()=>{if(I||!u){console.info(`[admin-ui] sidebar-new-session-click-ignored startingSession=${I} cacheKey=${u?`set`:`missing`}`);return}B(null),V.current=Date.now(),console.info(`[admin-ui] sidebar-new-session-modal-open seedMode=${L} cacheKey-prefix=${u.slice(0,8)}`),Te(!0)},[u,I,L]),at=(0,A.useCallback)(e=>{let t=V.current?Date.now()-V.current:0;console.info(`[admin-ui] sidebar-new-session-modal-cancel reason=${e} dwell-ms=${t}`),B(null),Te(!1)},[]),ot=(0,A.useCallback)(async e=>{if(I||!u)return;let t=V.current?Date.now()-V.current:0,n=Date.now();console.info(`[admin-ui] sidebar-new-session-modal-submit permissionMode=${e.permissionMode} model=${e.model??`default`} messageChars=${e.message.length} dwell-ms=${t}`),be(!0),B(null);try{console.info(`[admin-ui] sidebar-new-session-fetch-start permissionMode=${e.permissionMode} model=${e.model??`default`} messageChars=${e.message.length}`);let t={channel:`browser`,permissionMode:e.permissionMode,initialMessage:e.message};e.model!==void 0&&(t.model=e.model);let r=await fetch(`/api/admin/claude-sessions?session_key=${encodeURIComponent(u)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),i=Date.now()-n;console.info(`[admin-ui] sidebar-new-session-fetch-done status=${r.status} ok=${r.ok} ms=${i}`);let a=await r.json();if(!r.ok||!(`sessionId`in a)){let e=a,t=e.error??`POST returned ${r.status}`,i=e.reason?`${t}: ${e.reason}`:t;console.error(`[admin-ui] sidebar-new-session-failed status=${r.status} ms=${Date.now()-n} error=${t} reason=${e.reason??`none`} tail=${JSON.stringify(e.stderrTail??``)}`),B(i);return}console.info(`[admin-ui] sidebar-new-session-ok pid=${a.pid} sessionId=${a.sessionId.slice(0,8)} permissionMode=${e.permissionMode} model=${e.model??`default`} ms=${Date.now()-n}`),ue.setSessions(e=>[a,...e]),Te(!1);let o=a.sessionId,s=o.slice(0,8);if(e.placeholder===null)console.info(`[admin-ui] new-session-auto-open outcome=fallback sessionId=${s}`),P(o);else{let t=setTimeout(()=>{let e=H.current.get(o);e&&(H.current.delete(o),e.placeholder.closed||e.placeholder.close(),console.info(`[admin-ui] new-session-auto-open outcome=timeout sessionId=${s}`))},Ue);H.current.set(o,{placeholder:e.placeholder,timeoutId:t})}}catch(e){let t=e instanceof Error?e.message:String(e);B(t),console.error(`[admin-ui] sidebar-new-session-threw ms=${Date.now()-n} message=${t}`)}finally{be(!1)}},[u,I,ue,P]),$=ge(u,ue,`sidebar`),st=(0,A.useCallback)(async e=>{let t=await $.resume(e);t.ok||console.error(`[admin-ui] sidebar-resume failed: ${t.error}`)},[$]),ct=(0,A.useCallback)(async e=>{_e(!0),me(null);let t=await $.purge(e);t.ok?F(null):me(t.error??`purge failed`),_e(!1)},[$]),lt=(0,A.useCallback)(async e=>{let t=await $.end(e);t.ok||console.error(`[admin-ui] sidebar-end-session failed: ${t.error}`)},[$]),ut=(0,A.useCallback)(async e=>{let t=await $.archive(e);t.ok||console.error(`[admin-ui] sidebar-archive failed: ${t.error}`)},[$]),dt=(0,A.useCallback)(async e=>{let t=await $.unarchive(e);t.ok||console.error(`[admin-ui] sidebar-unarchive failed: ${t.error}`)},[$]),[ft,pt]=(0,A.useState)(null),[mt,ht]=(0,A.useState)(``),gt=(0,A.useCallback)(async(e,t)=>{let n=mt.trim();if(n.length===0||!fe(n)){pt(null);return}if(n===(t??``)){pt(null);return}let r=await $.rename(e,n);r.ok||console.error(`[admin-ui] sidebar-rename failed: ${r.error}`),pt(null)},[mt,$]),_t=(0,A.useCallback)(()=>{pt(null)},[]),[vt,yt]=(0,A.useState)(null),bt=(0,A.useCallback)(async(e,t)=>{try{await l(t),yt(e),window.setTimeout(()=>{yt(t=>t===e?null:t)},1200)}catch(e){console.error(`[admin-ui] sidebar-copy-label failed: ${String(e)}`)}},[]);return(0,j.jsxs)(`aside`,{className:`side`,children:[K===`chat`&&(0,j.jsxs)(`div`,{className:`side-new-session-row`,ref:Ye,children:[(0,j.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:it,disabled:I||!u,children:[I?(0,j.jsx)(C,{size:14,className:`spinning`}):(0,j.jsx)(O,{size:14}),(0,j.jsx)(`span`,{children:`New session`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`side-mode-trigger`,onClick:()=>{let e=!J;console.info(`[admin-ui] sidebar-mode-picker action=${e?`open`:`close`} mode=${L}`),Y(e)},disabled:I,"aria-haspopup":`menu`,"aria-expanded":J,"aria-label":`Permission mode for the next session`,title:`Shift+Cmd+M`,children:[Xe[L],(0,j.jsx)(o,{size:12,"aria-hidden":`true`})]}),J&&(0,j.jsxs)(`div`,{className:`side-mode-popover`,role:`menu`,"aria-label":`Mode`,children:[(0,j.jsxs)(`div`,{className:`side-mode-popover-head`,children:[(0,j.jsx)(`span`,{children:`Mode`}),(0,j.jsx)(`span`,{className:`side-mode-popover-shortcut`,"aria-hidden":`true`,children:`⇧⌘M`})]}),Ze.map((e,t)=>(0,j.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`side-mode-popover-item`,onClick:()=>{console.info(`[admin-ui] sidebar-mode-picker action=select mode=${e}`),R(e),Y(!1),X({permissionMode:e,model:xe},`sidebar`)},children:[(0,j.jsx)(`span`,{children:Xe[e]}),(0,j.jsxs)(`span`,{className:`side-mode-popover-shortcut`,children:[e===L&&(0,j.jsx)(_,{size:12}),(0,j.jsx)(`span`,{children:t+1})]})]},e))]})]}),(0,j.jsxs)(`nav`,{className:`side-nav`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`nav-row${K===`chat`?` active`:``}`,onClick:Qe,children:[(0,j.jsx)(ie,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,j.jsx)(`span`,{className:`kbd`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),ne(),N()},children:[(0,j.jsx)(ae,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`People`}),(0,j.jsx)(`span`,{className:`kbd`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),M(),N()},children:[(0,j.jsx)(h,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`Agents`}),(0,j.jsx)(`span`,{className:`kbd`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),te(),N()},children:[(0,j.jsx)(g,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`Projects`}),(0,j.jsx)(`span`,{className:`kbd`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),oe(),N()},children:[(0,j.jsx)(S,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,j.jsx)(`span`,{className:`kbd`})]}),(0,j.jsxs)(`button`,{type:`button`,className:`nav-row${K===`artefacts`?` active`:``}`,onClick:$e,children:[(0,j.jsx)(c,{size:20,strokeWidth:Q}),(0,j.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,j.jsx)(`span`,{className:`kbd`})]})]}),(0,j.jsxs)(`div`,{className:`side-list`,ref:ve,children:[(0,j.jsxs)(`div`,{className:`group-head`,children:[(0,j.jsx)(`span`,{children:et}),(0,j.jsxs)(`span`,{className:`group-head-meta`,children:[(0,j.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh ${et.toLowerCase()}`,"aria-label":`Refresh ${et.toLowerCase()}`,onClick:rt,disabled:nt,children:(0,j.jsx)(k,{size:12,className:nt?`spinning`:void 0})}),(0,j.jsx)(`span`,{children:tt})]})]}),K===`chat`&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(Ke,{view:W.view,setView:e=>{console.info(`[admin-ui] sidebar-view-change view=${e}`),W.setView(e)},connected:W.connected,reconnectNow:W.reconnectNow}),w&&(0,j.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:w}),G.map(e=>{let t=se===e.sessionId,n=ft===e.sessionId;return(0,j.jsxs)(`div`,{className:`conv${t?` active`:``}`,children:[n?(0,j.jsxs)(`span`,{className:`conv-name-line`,style:{flex:1,minWidth:0},children:[(0,j.jsx)(ie,{size:12,className:`conv-channel-icon`,"aria-label":`claude session`}),(0,j.jsx)(qe,{live:e.live,status:e.status}),(0,j.jsx)(`input`,{type:`text`,value:mt,autoFocus:!0,maxLength:200,onChange:e=>ht(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),gt(e.sessionId,e.firstPrompt)):t.key===`Escape`&&(t.preventDefault(),_t())},onBlur:()=>{gt(e.sessionId,e.firstPrompt)},className:`conv-name`,"aria-label":`Rename session`,style:{flex:1,minWidth:0,background:`transparent`,border:`none`,outline:`none`,color:`inherit`,font:`inherit`}})]}):(0,j.jsxs)(`button`,{type:`button`,className:`conv-name-button`,onClick:()=>{P(e.sessionId),N()},title:`Show metadata`,children:[(0,j.jsxs)(`span`,{className:`conv-name-line`,children:[(0,j.jsx)(ie,{size:12,className:`conv-channel-icon`,"aria-label":`claude session`}),(0,j.jsx)(qe,{live:e.live,status:e.status}),e.firstPrompt?(0,j.jsx)(`span`,{className:`conv-name`,children:e.firstPrompt}):(0,j.jsxs)(`span`,{className:`conv-name`,style:{fontStyle:`italic`,opacity:.6},children:[`(unnamed · `,e.sessionId.slice(0,8),`)`]})]}),(0,j.jsx)(`span`,{className:`conv-timestamp`,children:Ie(e.updatedAt,Me)})]}),!n&&(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Rename`,"aria-label":`Rename session`,onClick:()=>{ht(e.firstPrompt??``),pt(e.sessionId)},children:(0,j.jsx)(D,{size:13})}),!n&&(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Copy label`,"aria-label":`Copy session label`,onClick:()=>void bt(e.sessionId,e.firstPrompt??`(unnamed · ${e.sessionId.slice(0,8)})`),children:vt===e.sessionId?(0,j.jsx)(_,{size:13}):(0,j.jsx)(s,{size:13})}),e.url!==null&&(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Open in new tab`,"aria-label":`Open in new tab`,onClick:()=>Je(e.url,e.sessionId),children:(0,j.jsx)(b,{size:13})}),e.live?(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`End session`,"aria-label":`End session`,onClick:()=>void lt(e.sessionId),disabled:$.inFlight===`end`,children:$.inFlight===`end`?(0,j.jsx)(C,{size:13,className:`spinning`}):(0,j.jsx)(re,{size:13})}):e.archived?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Unarchive session`,"aria-label":`Unarchive session`,onClick:()=>void dt(e.sessionId),disabled:$.inFlight===`unarchive`,children:$.inFlight===`unarchive`?(0,j.jsx)(C,{size:13,className:`spinning`}):(0,j.jsx)(p,{size:13})}),(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Purge JSONL`,"aria-label":`Purge JSONL`,onClick:()=>{me(null),F({sessionId:e.sessionId,displayName:e.firstPrompt})},children:(0,j.jsx)(r,{size:13})})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Resume session`,"aria-label":`Resume session`,onClick:()=>void st(e.sessionId),disabled:$.inFlight===`resume`,children:$.inFlight===`resume`?(0,j.jsx)(C,{size:13,className:`spinning`}):(0,j.jsx)(i,{size:13})}),(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Archive session`,"aria-label":`Archive session`,onClick:()=>void ut(e.sessionId),disabled:$.inFlight===`archive`,children:$.inFlight===`archive`?(0,j.jsx)(C,{size:13,className:`spinning`}):(0,j.jsx)(m,{size:13})}),(0,j.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Purge JSONL`,"aria-label":`Purge JSONL`,onClick:()=>{me(null),F({sessionId:e.sessionId,displayName:e.firstPrompt})},children:(0,j.jsx)(r,{size:13})})]})]},e.sessionId)})]}),K===`artefacts`&&(0,j.jsxs)(j.Fragment,{children:[ze&&(0,j.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:ze}),Fe&&!ze&&q.length===0&&(0,j.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),q.map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>{ee({docId:e.id,name:e.name,content:e.content,editable:e.editable,mimeType:e.mimeType,skipReason:e.skipReason},`sidebar-artefacts`),N()},children:[(0,j.jsx)(`span`,{className:`conv-name`,children:e.name}),(0,j.jsx)(`span`,{className:`conv-kind`,"data-kind":e.kind===`agent-template`?`agent`:`doc`,children:e.kind===`agent-template`?`agent`:`doc`})]},e.id))]})]}),(0,j.jsx)(Ge,{}),(0,j.jsxs)(`div`,{className:`side-foot`,children:[(0,j.jsx)(`div`,{className:`avatar`,children:v?(0,j.jsx)(`img`,{src:v,alt:U}):De}),(0,j.jsxs)(`div`,{className:`who`,children:[(0,j.jsx)(`span`,{className:`name`,children:U}),(0,j.jsx)(`span`,{className:`role`,children:d??`operator`})]})]}),we&&(0,j.jsx)(He,{seedMode:L,seedModel:xe,submitting:I,error:Ce,onSubmit:e=>void ot(e),onCancel:at,onErrorClear:()=>B(null)}),de&&(0,j.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`purge-confirm-title`,className:`modal-overlay`,onClick:e=>{e.target===e.currentTarget&&!he&&F(null)},children:(0,j.jsxs)(`div`,{className:`modal-card`,children:[(0,j.jsx)(`h3`,{id:`purge-confirm-title`,style:{margin:0,marginBottom:8,fontSize:16,fontWeight:600},children:`Purge session JSONL?`}),(0,j.jsxs)(`p`,{style:{margin:0,marginBottom:8,fontSize:13},children:[`This hard-deletes the transcript for `,(0,j.jsx)(`strong`,{children:de.displayName??de.sessionId.slice(0,8)}),`. The action cannot be undone.`]}),pe&&(0,j.jsx)(`p`,{style:{margin:0,marginBottom:8,fontSize:12,color:`var(--text-tertiary)`},children:pe}),(0,j.jsxs)(`div`,{className:`modal-action-row`,children:[(0,j.jsx)(`button`,{type:`button`,className:`modal-action-btn`,disabled:he,onClick:()=>F(null),children:`Cancel`}),(0,j.jsx)(`button`,{type:`button`,className:`modal-action-btn`,"data-variant":`danger`,disabled:he,onClick:()=>void ct(de.sessionId),children:he?(0,j.jsx)(C,{size:13,className:`spinning`}):`Purge`})]})]})})]})}),J=5e3;function Ge(){let[e,t]=(0,A.useState)(null);if((0,A.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()},J))}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)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,j.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,j.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,j.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,j.jsx)(`div`,{className:`system-stats__bar`,children:(0,j.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,j.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,j.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,j.jsx)(`div`,{className:`system-stats__bar`,children:(0,j.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var Y=[{value:`active`,label:`Active`},{value:`archived`,label:`Archived`},{value:`all`,label:`All`}];function Ke(e){let{view:t,setView:n,connected:r,reconnectNow:i}=e;return(0,j.jsx)(`div`,{className:`session-view-controls`,children:(0,j.jsxs)(`div`,{className:`session-view-segmented`,role:`tablist`,"aria-label":`Session view`,children:[Y.map(e=>(0,j.jsx)(`button`,{type:`button`,role:`tab`,className:`session-view-tab${t===e.value?` active`:``}`,"aria-selected":t===e.value,onClick:()=>n(e.value),children:e.label},e.value)),r?(0,j.jsx)(`span`,{className:`session-view-connection connected`,"aria-label":`Live updates connected.`,title:`Live updates connected.`}):(0,j.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:i})]})})}function qe({live:e,status:t}){return e?t===`busy`?(0,j.jsxs)(`span`,{className:`session-status session-status-busy`,"aria-label":`session busy`,children:[(0,j.jsx)(`span`,{className:`session-status-dot`}),(0,j.jsx)(`span`,{className:`session-status-dot`}),(0,j.jsx)(`span`,{className:`session-status-dot`})]}):t===`detached`?(0,j.jsx)(`span`,{className:`session-status session-status-detached`,"aria-label":`session detached — manager restart survivor`}):(0,j.jsx)(`span`,{className:`session-status session-status-idle`,"aria-label":`session idle`}):(0,j.jsx)(`span`,{className:`session-status session-status-archived`,"aria-label":`session archived`})}function Je(e,t){let n=t.slice(0,8),r=window.open(e,`_blank`,`noopener,noreferrer`)===null?`blocked`:`ok`;console.info(`[admin-ui] sidebar-open-in-new-tab outcome=${r} sessionId=${n}`)}function Ye(e){return e.map(e=>[e.sessionId,e.displayName,e.lastMessageAt,e.status])}function Xe(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])return!1}return!0}function Ze(e){let[t,n]=(0,A.useState)([]),[r,i]=(0,A.useState)(!1),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(null),l=(0,A.useRef)([]),u=(0,A.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=Ye(i),o=Xe(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,A.useEffect)(()=>{e||(c(null),n([]),o(null),l.current=[])},[e]);let d=(0,A.useCallback)(()=>u(!1),[u]),f=(0,A.useCallback)(()=>u(!0),[u]);return{sessions:t,setSessions:n,loading:r,loaded:s!==null&&s===e,error:a,ensureLoaded:d,refetch:f}}var X=`admin-sidebar-collapsed`,Z=`admin-sidebar-drawer-open`;function Qe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(X)===`1`}catch{return!1}}function $e(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(X,`1`):window.sessionStorage.removeItem(X)}catch{}}function Q(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Z)===`1`}catch{return!1}}function et(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Z,`1`):window.sessionStorage.removeItem(Z)}catch{}}var tt=720;function nt(e){let{cacheKey:t,businessName:n,onLogout:r,userName:i,userAvatar:a,role:o,selectedSessionId:s,onSelectSession:c,onSelectArtefact:l,dataArtefact:u=`closed`,children:d,footer:f}=e,[p,m]=(0,A.useState)(()=>Qe()),[h,g]=(0,A.useState)(()=>Q()),[_,v]=(0,A.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${tt}px)`).matches);(0,A.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${tt}px)`),t=e=>v(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let y=(0,A.useCallback)(e=>{$e(e),m(e)},[]),b=(0,A.useCallback)(e=>{et(e),g(e)},[]);(0,A.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} collapsed=${p} drawer=${h}`)},[]);let x=_?h:!p,S=(0,A.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${tt}px)`).matches){let e=h;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),b(!e)}else{let e=p;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),y(!e)}},[p,h,y,b]),C=(0,A.useCallback)(e=>{console.info(`[admin-ui] header-menu-nav target=${e}`),window.location.href=e===`data`?`/data`:`/graph`},[]),w=Ze(t),T=ke(t),E=(0,A.useMemo)(()=>T.rows.map(e=>e.sessionId),[T.rows]),ee=(0,A.useCallback)(e=>{if(c){c(e);return}window.location.assign(`/?sessionId=${encodeURIComponent(e)}`)},[c]),D=(0,A.useCallback)(e=>{l&&l(e)},[l]),O={collapsed:p,mobileDrawerOpen:h,sidebarOpen:x,onToggleSidebar:S,setMobileDrawerOpen:b,sessionsState:w,sessionRowIds:E,sessionRowsConnected:T.connected};return(0,j.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,j.jsx)(be,{businessName:n,onNavigate:C,onToggleSidebar:S,sidebarOpen:x,onLogout:r}),(0,j.jsxs)(`div`,{className:`platform${h?` menu-open`:``}${p?` sidebar-collapsed`:``}`,"data-artefact":u,children:[(0,j.jsx)(We,{businessName:n,cacheKey:t,role:o??null,userName:i,userAvatar:a??null,sessions:w.sessions,sessionsLoading:w.loading,sessionsError:w.error,ensureSessionsLoaded:w.ensureLoaded,refetchSessions:w.refetch,onSelectArtefact:D,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:()=>b(!1),onSelectSession:ee,selectedSessionId:s??null,collapsed:p,mobileDrawerOpen:h,recentsActions:{setSessions:w.setSessions,refetch:w.refetch}}),typeof d==`function`?d(O):d]}),h&&(0,j.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>b(!1)}),f]})}var rt={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Listing:`#3F5670`,Property:`#5C7A99`,Viewing:`#D4A574`,Offer:`#B08850`,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`},it=`#94A3B8`;Object.freeze(Object.keys(rt)),Object.freeze(new Set([`Chunk`,`GraphPreference`]));var at=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.Listing.Property.Viewing.Offer.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 ot(e){for(let t=1;t<e.length;t++)if(Object.prototype.hasOwnProperty.call(rt,e[t]))return e[t];return e[0]??null}function $(e){return rt[e]??`#94A3B8`}function st(e){let t=ot(e),n=t?$(t):it,r=0;for(let t=1;t<e.length;t++)Object.prototype.hasOwnProperty.call(rt,e[t])&&r++;return{displayLabel:t,colour:n,driftCandidates:r}}export{p as C,m as S,D as _,nt as a,y as b,fe as c,oe as d,re as f,O as g,k as h,st as i,ge as l,te as m,$ as n,Te as o,ne as p,ot as r,ye as s,at as t,ce as u,C as v,_ as x,b as y};