@rubytech/create-realagent 1.0.833 → 1.0.835

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 (44) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/publish-site/SKILL.md +71 -0
  3. package/payload/platform/plugins/admin/skills/unzip-attachment/SKILL.md +4 -0
  4. package/payload/platform/plugins/docs/references/internals.md +3 -1
  5. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest.test.js +9 -0
  6. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-ingest.test.js.map +1 -1
  7. package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js +24 -6
  8. package/payload/platform/plugins/memory/mcp/dist/tools/memory-ingest.js.map +1 -1
  9. package/payload/platform/plugins/memory/skills/conversation-archive/SKILL.md +17 -0
  10. package/payload/server/chunk-B43O764H.js +654 -0
  11. package/payload/server/chunk-BYPWJ4Z6.js +1116 -0
  12. package/payload/server/chunk-GK4WHM3H.js +9961 -0
  13. package/payload/server/chunk-KKGGT5RH.js +654 -0
  14. package/payload/server/chunk-MRJGG6CS.js +2124 -0
  15. package/payload/server/chunk-TQ6L56KS.js +2126 -0
  16. package/payload/server/chunk-UXN47TX2.js +9961 -0
  17. package/payload/server/chunk-ZVW5XKPU.js +1116 -0
  18. package/payload/server/client-pool-FM3YJWV5.js +32 -0
  19. package/payload/server/client-pool-HC6PMV2X.js +32 -0
  20. package/payload/server/cloudflare-task-tracker-FSPEJOTH.js +19 -0
  21. package/payload/server/cloudflare-task-tracker-R35AJT27.js +19 -0
  22. package/payload/server/maxy-edge.js +3 -3
  23. package/payload/server/neo4j-migrations-JG2AK3UV.js +664 -0
  24. package/payload/server/neo4j-migrations-XP7XDVPX.js +664 -0
  25. package/payload/server/public/assets/{Checkbox-CTGhpDKq.js → Checkbox-Bq6ORjz2.js} +1 -1
  26. package/payload/server/public/assets/admin-CstEkw-G.js +352 -0
  27. package/payload/server/public/assets/data-DwZZ7qbH.js +1 -0
  28. package/payload/server/public/assets/graph-DceEv42K.js +1 -0
  29. package/payload/server/public/assets/{jsx-runtime-D4WovFYk.css → jsx-runtime-DidQeNoZ.css} +1 -1
  30. package/payload/server/public/assets/page-Bpi_jPw6.js +50 -0
  31. package/payload/server/public/assets/{page-DkBfWy4C.js → page-CFWoVkgV.js} +1 -1
  32. package/payload/server/public/assets/{public-BdVIVpv8.js → public-BWMwq5Jj.js} +1 -1
  33. package/payload/server/public/assets/{useAdminFetch-DmHu0oCx.js → useAdminFetch-B93ig7ef.js} +1 -1
  34. package/payload/server/public/assets/{useVoiceRecorder-CSc_hxjV.js → useVoiceRecorder-Cb0nAtOo.js} +1 -1
  35. package/payload/server/public/data.html +5 -5
  36. package/payload/server/public/graph.html +6 -6
  37. package/payload/server/public/index.html +8 -8
  38. package/payload/server/public/public.html +5 -5
  39. package/payload/server/server.js +17 -9
  40. package/payload/server/public/assets/admin-CgGQafDG.js +0 -352
  41. package/payload/server/public/assets/data-Y77FLKjs.js +0 -1
  42. package/payload/server/public/assets/graph-BlrcvwWP.js +0 -1
  43. package/payload/server/public/assets/page-ClTUYMK8.js +0 -50
  44. /package/payload/server/public/assets/{jsx-runtime-DkaAusaX.js → jsx-runtime-DH5S-MwB.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{n as t,o as n,r,t as i}from"./jsx-runtime-DkaAusaX.js";import{a,c as o,i as s,l as c,o as l,r as u,s as d,t as f}from"./useAdminFetch-DmHu0oCx.js";var p=r(`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`}]]),m=r(`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`}]]),h=r(`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`}]]),g=r(`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`}]]),_=r(`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 v(e){let t=new Set,n=[];for(let r of e){let e=r.labels[0];e&&(t.has(e)||(t.add(e),n.push(e)))}return n}var y=80;function b(e){let t=x(e.properties)??e.labels[0]??``,n=t.length>y?t.slice(0,y):t;return`/graph?${new URLSearchParams({nodeId:e.nodeId,label:n}).toString()}`}function x(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 S=e(n(),1),C=i();function w(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!1);return(0,S.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(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,C.jsxs)(`div`,{className:`data-page`,children:[(0,C.jsxs)(`header`,{className:`data-header`,children:[(0,C.jsxs)(`h1`,{className:`data-title`,children:[(0,C.jsx)(c,{size:18}),` Data`]}),(0,C.jsx)(E,{})]}),(0,C.jsx)(T,{sessionKey:e})]}):(0,C.jsxs)(`div`,{className:`data-page`,children:[(0,C.jsx)(`header`,{className:`data-header`,children:(0,C.jsxs)(`h1`,{className:`data-title`,children:[(0,C.jsx)(c,{size:18}),` Data`]})}),(0,C.jsxs)(`div`,{className:`data-empty`,children:[(0,C.jsx)(`p`,{children:`You are not signed in.`}),(0,C.jsxs)(`p`,{children:[`Open the `,(0,C.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,C.jsx)(`div`,{className:`data-page`,children:(0,C.jsxs)(`div`,{className:`data-loading`,children:[(0,C.jsx)(d,{size:18,className:`spin`}),` Loading…`]})})}function T({sessionKey:e,onOpenInGraph:t}){let{adminFetch:n,sessionKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=f({initialSessionKey:e,surface:`data`});return(0,C.jsxs)(`main`,{className:`data-main`,children:[a&&(0,C.jsx)(`button`,{type:`button`,className:`data-session-banner`,onClick:o,"data-reason":a.reason,children:a.message}),(0,C.jsx)(D,{adminFetch:n,sessionRefetchNonce:i,onOpenInGraph:t}),(0,C.jsx)(M,{adminFetch:n,sessionKey:r,sessionRefetchNonce:i})]})}function E(){let[e,t]=(0,S.useState)(!1),n=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&(n.current.contains(e.target)||t(!1))},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]);let r=(0,S.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,C.jsxs)(`div`,{className:`chat-burger-wrap`,ref:n,children:[(0,C.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>t(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":e,children:(0,C.jsx)(a,{size:20})}),e&&(0,C.jsxs)(`div`,{className:`chat-menu`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/`},children:[(0,C.jsx)(o,{size:14}),` Chat`]}),(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/graph`},children:[(0,C.jsx)(u,{size:14}),` Graph`]}),(0,C.jsx)(`div`,{className:`chat-menu-divider`}),(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),r()},children:[(0,C.jsx)(l,{size:14}),` Log out`]})]})]})}function D({adminFetch:e,sessionRefetchNonce:t,onOpenInGraph:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[c,l]=(0,S.useState)(null),[u,f]=(0,S.useState)(`hybrid`),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(null),[_,y]=(0,S.useState)(null);(0,S.useEffect)(()=>{let e=r.trim();if(!e){o(``),l(null);return}let t=setTimeout(()=>o(e),300);return()=>clearTimeout(t)},[r]),(0,S.useEffect)(()=>{if(!a)return;let t=!1;return m(!0),g(null),e(`/api/admin/graph-search?q=${encodeURIComponent(a)}&labels=*&limit=20`).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||(l(e.results),f(e.mode??`hybrid`))}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[a,e,t]);let x=(0,S.useMemo)(()=>c?v(c):[],[c]),w=_&&x.includes(_)?_:null,T=(0,S.useMemo)(()=>c?w?c.filter(e=>e.labels[0]===w):c:null,[c,w]),E=(0,S.useCallback)(e=>{if(n){n(e);return}window.location.href=b(e)},[n]);return(0,C.jsxs)(`section`,{className:`data-panel`,children:[(0,C.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,C.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,C.jsxs)(`div`,{className:`data-search-input`,children:[(0,C.jsx)(s,{size:14}),(0,C.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),p&&(0,C.jsx)(d,{size:14,className:`spin`})]}),h&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,h]}),x.length>0&&(0,C.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:x.map(e=>{let t=e===w;return(0,C.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>y(t?null:e),children:k([e])??e},e)})}),c&&!p&&(0,C.jsxs)(`div`,{className:`data-results-meta`,children:[T.length,` of `,c.length,` result`,c.length===1?``:`s`]}),c&&c.length===0&&!p&&(0,C.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),T&&T.length>0&&(0,C.jsx)(`ul`,{className:`data-results`,children:T.map(e=>(0,C.jsx)(O,{hit:e,mode:u,onOpenInGraph:E},e.nodeId))})]})}function O({hit:e,mode:t,onOpenInGraph:n}){let r=A(e.properties),i=j(e.properties),a=k(e.labels),[o,s]=(0,S.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,C.jsxs)(`li`,{className:`data-result`,children:[(0,C.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,C.jsx)(`div`,{className:`data-result-header`,children:(0,C.jsx)(`span`,{className:`data-result-labels`,children:a})}),r&&(0,C.jsx)(`div`,{className:`data-result-title`,children:r}),i&&(0,C.jsx)(`pre`,{className:`data-result-body`,children:l}),(0,C.jsx)(`div`,{className:`data-result-scores`,children:u})]}),c&&(0,C.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`Show more`})]})}function k(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 A(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 j(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 M({adminFetch:e,sessionKey:n,sessionRefetchNonce:r}){let[i,a]=(0,S.useState)(`.`),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)([]),[u,f]=(0,S.useState)(!1),[v,y]=(0,S.useState)(null),[b,x]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),[E,D]=(0,S.useState)(null),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)(null),M=(0,S.useRef)(null),[F,I]=(0,S.useState)(0);(0,S.useEffect)(()=>{let t=!1;return f(!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||(s(e.entries),l(e.displayPath??[]))}).catch(e=>{t||(s([]),l([]),y(e instanceof Error?e.message:String(e)))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,i,F,r]);let L=(0,S.useCallback)(e=>{a(e)},[]),R=(0,S.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),a(e.length===0?`.`:e.join(`/`))},[i]),z=(0,S.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,S.useCallback)(()=>{M.current?.click()},[]),V=(0,S.useCallback)(e=>{D(null),j(e.name)},[]),H=(0,S.useCallback)(()=>{j(null)},[]),U=(0,S.useCallback)(async t=>{let n=i===`.`?t.name:`${i}/${t.name}`;D(null),j(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,S.useEffect)(()=>{if(!A)return;let e=e=>{e.key===`Escape`&&j(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A]);let W=(0,S.useCallback)(async e=>{T(null),x(!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}`);a(i.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1),M.current&&(M.current.value=``)}},[n]);return(0,C.jsxs)(`section`,{className:`data-panel`,children:[(0,C.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,C.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,C.jsxs)(`div`,{className:`data-file-actions`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:B,disabled:b,children:[b?(0,C.jsx)(d,{size:14,className:`spin`}):(0,C.jsx)(_,{size:14}),` Upload`]}),(0,C.jsx)(`input`,{type:`file`,ref:M,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&W(t)}})]})]}),(0,C.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,C.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,C.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,C.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,C.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(`.`),children:`data`}),c.map((e,t)=>{let n=c.slice(0,t+1).map(e=>e.name).join(`/`);return(0,C.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,C.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,C.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(n),title:e.name,children:e.displayName??e.name})]},n)}),i!==`.`&&(0,C.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:R,children:[(0,C.jsx)(p,{size:14}),` Up`]})]}),w&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,w]}),E&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,E]}),v&&(0,C.jsx)(`div`,{className:`data-error`,children:v}),u&&(0,C.jsxs)(`div`,{className:`data-loading`,children:[(0,C.jsx)(d,{size:14,className:`spin`}),` Loading…`]}),!u&&o&&o.length===0&&!v&&(0,C.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!u&&o&&o.length>0&&(0,C.jsx)(`ul`,{className:`data-entries`,children:o.map(e=>{let n=e.displayName??e.name,r=O===e.name,a=A===e.name;return(0,C.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,C.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(i===`.`?e.name:`${i}/${e.name}`),children:[(0,C.jsx)(g,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n})]}):e.kind===`file`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>z(e),title:`Download ${n}`,disabled:a,children:[(0,C.jsx)(h,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n}),(0,C.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${P(e.modifiedAt)}`,children:[N(e.sizeBytes),` · `,P(e.modifiedAt)]}),(0,C.jsx)(m,{size:12,className:`data-entry-download-icon`})]}),a?(0,C.jsxs)(`div`,{className:`data-entry-confirm`,role:`group`,"aria-label":`Confirm delete ${n}`,children:[(0,C.jsx)(`span`,{className:`data-entry-confirm-label`,children:`Delete?`}),(0,C.jsx)(`button`,{type:`button`,className:`data-entry-confirm-yes`,onClick:()=>U(e),autoFocus:!0,children:`Yes`}),(0,C.jsx)(`button`,{type:`button`,className:`data-entry-confirm-no`,onClick:H,children:`No`})]}):(0,C.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>V(e),disabled:r,title:`Delete ${n}`,"aria-label":`Delete ${n}`,children:r?(0,C.jsx)(d,{size:14,className:`spin`}):(0,C.jsx)(t,{size:14})})]}):(0,C.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,C.jsx)(h,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,children:n}),(0,C.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function N(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 P(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{m as a,h as i,T as n,x as r,w as t};
1
+ import{o as e}from"./chunk-DD-I1_y5.js";import{n as t,o as n,r,t as i}from"./jsx-runtime-DH5S-MwB.js";import{a,c as o,i as s,l as c,o as l,r as u,s as d,t as f}from"./useAdminFetch-B93ig7ef.js";var p=r(`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`}]]),m=r(`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`}]]),h=r(`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`}]]),g=r(`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`}]]),_=r(`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 v(e){let t=new Set,n=[];for(let r of e){let e=r.labels[0];e&&(t.has(e)||(t.add(e),n.push(e)))}return n}var y=80;function b(e){let t=x(e.properties)??e.labels[0]??``,n=t.length>y?t.slice(0,y):t;return`/graph?${new URLSearchParams({nodeId:e.nodeId,label:n}).toString()}`}function x(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 S=e(n(),1),C=i();function w(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!1);return(0,S.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(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,C.jsxs)(`div`,{className:`data-page`,children:[(0,C.jsxs)(`header`,{className:`data-header`,children:[(0,C.jsxs)(`h1`,{className:`data-title`,children:[(0,C.jsx)(c,{size:18}),` Data`]}),(0,C.jsx)(E,{})]}),(0,C.jsx)(T,{sessionKey:e})]}):(0,C.jsxs)(`div`,{className:`data-page`,children:[(0,C.jsx)(`header`,{className:`data-header`,children:(0,C.jsxs)(`h1`,{className:`data-title`,children:[(0,C.jsx)(c,{size:18}),` Data`]})}),(0,C.jsxs)(`div`,{className:`data-empty`,children:[(0,C.jsx)(`p`,{children:`You are not signed in.`}),(0,C.jsxs)(`p`,{children:[`Open the `,(0,C.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,C.jsx)(`div`,{className:`data-page`,children:(0,C.jsxs)(`div`,{className:`data-loading`,children:[(0,C.jsx)(d,{size:18,className:`spin`}),` Loading…`]})})}function T({sessionKey:e,onOpenInGraph:t}){let{adminFetch:n,sessionKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=f({initialSessionKey:e,surface:`data`});return(0,C.jsxs)(`main`,{className:`data-main`,children:[a&&(0,C.jsx)(`button`,{type:`button`,className:`data-session-banner`,onClick:o,"data-reason":a.reason,children:a.message}),(0,C.jsx)(D,{adminFetch:n,sessionRefetchNonce:i,onOpenInGraph:t}),(0,C.jsx)(M,{adminFetch:n,sessionKey:r,sessionRefetchNonce:i})]})}function E(){let[e,t]=(0,S.useState)(!1),n=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&(n.current.contains(e.target)||t(!1))},i=e=>{e.key===`Escape`&&t(!1)};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]);let r=(0,S.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return(0,C.jsxs)(`div`,{className:`chat-burger-wrap`,ref:n,children:[(0,C.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>t(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":e,children:(0,C.jsx)(a,{size:20})}),e&&(0,C.jsxs)(`div`,{className:`chat-menu`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/`},children:[(0,C.jsx)(o,{size:14}),` Chat`]}),(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),window.location.href=`/graph`},children:[(0,C.jsx)(u,{size:14}),` Graph`]}),(0,C.jsx)(`div`,{className:`chat-menu-divider`}),(0,C.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{t(!1),r()},children:[(0,C.jsx)(l,{size:14}),` Log out`]})]})]})}function D({adminFetch:e,sessionRefetchNonce:t,onOpenInGraph:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[c,l]=(0,S.useState)(null),[u,f]=(0,S.useState)(`hybrid`),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(null),[_,y]=(0,S.useState)(null);(0,S.useEffect)(()=>{let e=r.trim();if(!e){o(``),l(null);return}let t=setTimeout(()=>o(e),300);return()=>clearTimeout(t)},[r]),(0,S.useEffect)(()=>{if(!a)return;let t=!1;return m(!0),g(null),e(`/api/admin/graph-search?q=${encodeURIComponent(a)}&labels=*&limit=20`).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||(l(e.results),f(e.mode??`hybrid`))}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[a,e,t]);let x=(0,S.useMemo)(()=>c?v(c):[],[c]),w=_&&x.includes(_)?_:null,T=(0,S.useMemo)(()=>c?w?c.filter(e=>e.labels[0]===w):c:null,[c,w]),E=(0,S.useCallback)(e=>{if(n){n(e);return}window.location.href=b(e)},[n]);return(0,C.jsxs)(`section`,{className:`data-panel`,children:[(0,C.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,C.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,C.jsxs)(`div`,{className:`data-search-input`,children:[(0,C.jsx)(s,{size:14}),(0,C.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),p&&(0,C.jsx)(d,{size:14,className:`spin`})]}),h&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,h]}),x.length>0&&(0,C.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:x.map(e=>{let t=e===w;return(0,C.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>y(t?null:e),children:k([e])??e},e)})}),c&&!p&&(0,C.jsxs)(`div`,{className:`data-results-meta`,children:[T.length,` of `,c.length,` result`,c.length===1?``:`s`]}),c&&c.length===0&&!p&&(0,C.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),T&&T.length>0&&(0,C.jsx)(`ul`,{className:`data-results`,children:T.map(e=>(0,C.jsx)(O,{hit:e,mode:u,onOpenInGraph:E},e.nodeId))})]})}function O({hit:e,mode:t,onOpenInGraph:n}){let r=A(e.properties),i=j(e.properties),a=k(e.labels),[o,s]=(0,S.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,C.jsxs)(`li`,{className:`data-result`,children:[(0,C.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,C.jsx)(`div`,{className:`data-result-header`,children:(0,C.jsx)(`span`,{className:`data-result-labels`,children:a})}),r&&(0,C.jsx)(`div`,{className:`data-result-title`,children:r}),i&&(0,C.jsx)(`pre`,{className:`data-result-body`,children:l}),(0,C.jsx)(`div`,{className:`data-result-scores`,children:u})]}),c&&(0,C.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`Show more`})]})}function k(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 A(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 j(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 M({adminFetch:e,sessionKey:n,sessionRefetchNonce:r}){let[i,a]=(0,S.useState)(`.`),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)([]),[u,f]=(0,S.useState)(!1),[v,y]=(0,S.useState)(null),[b,x]=(0,S.useState)(!1),[w,T]=(0,S.useState)(null),[E,D]=(0,S.useState)(null),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)(null),M=(0,S.useRef)(null),[F,I]=(0,S.useState)(0);(0,S.useEffect)(()=>{let t=!1;return f(!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||(s(e.entries),l(e.displayPath??[]))}).catch(e=>{t||(s([]),l([]),y(e instanceof Error?e.message:String(e)))}).finally(()=>{t||f(!1)}),()=>{t=!0}},[e,i,F,r]);let L=(0,S.useCallback)(e=>{a(e)},[]),R=(0,S.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),a(e.length===0?`.`:e.join(`/`))},[i]),z=(0,S.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,S.useCallback)(()=>{M.current?.click()},[]),V=(0,S.useCallback)(e=>{D(null),j(e.name)},[]),H=(0,S.useCallback)(()=>{j(null)},[]),U=(0,S.useCallback)(async t=>{let n=i===`.`?t.name:`${i}/${t.name}`;D(null),j(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,S.useEffect)(()=>{if(!A)return;let e=e=>{e.key===`Escape`&&j(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A]);let W=(0,S.useCallback)(async e=>{T(null),x(!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}`);a(i.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{x(!1),M.current&&(M.current.value=``)}},[n]);return(0,C.jsxs)(`section`,{className:`data-panel`,children:[(0,C.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,C.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,C.jsxs)(`div`,{className:`data-file-actions`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:B,disabled:b,children:[b?(0,C.jsx)(d,{size:14,className:`spin`}):(0,C.jsx)(_,{size:14}),` Upload`]}),(0,C.jsx)(`input`,{type:`file`,ref:M,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&W(t)}})]})]}),(0,C.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,C.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,C.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,C.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,C.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(`.`),children:`data`}),c.map((e,t)=>{let n=c.slice(0,t+1).map(e=>e.name).join(`/`);return(0,C.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,C.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,C.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(n),title:e.name,children:e.displayName??e.name})]},n)}),i!==`.`&&(0,C.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:R,children:[(0,C.jsx)(p,{size:14}),` Up`]})]}),w&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,w]}),E&&(0,C.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,E]}),v&&(0,C.jsx)(`div`,{className:`data-error`,children:v}),u&&(0,C.jsxs)(`div`,{className:`data-loading`,children:[(0,C.jsx)(d,{size:14,className:`spin`}),` Loading…`]}),!u&&o&&o.length===0&&!v&&(0,C.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!u&&o&&o.length>0&&(0,C.jsx)(`ul`,{className:`data-entries`,children:o.map(e=>{let n=e.displayName??e.name,r=O===e.name,a=A===e.name;return(0,C.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,C.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(i===`.`?e.name:`${i}/${e.name}`),children:[(0,C.jsx)(g,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n})]}):e.kind===`file`?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>z(e),title:`Download ${n}`,disabled:a,children:[(0,C.jsx)(h,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:n}),(0,C.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${P(e.modifiedAt)}`,children:[N(e.sizeBytes),` · `,P(e.modifiedAt)]}),(0,C.jsx)(m,{size:12,className:`data-entry-download-icon`})]}),a?(0,C.jsxs)(`div`,{className:`data-entry-confirm`,role:`group`,"aria-label":`Confirm delete ${n}`,children:[(0,C.jsx)(`span`,{className:`data-entry-confirm-label`,children:`Delete?`}),(0,C.jsx)(`button`,{type:`button`,className:`data-entry-confirm-yes`,onClick:()=>U(e),autoFocus:!0,children:`Yes`}),(0,C.jsx)(`button`,{type:`button`,className:`data-entry-confirm-no`,onClick:H,children:`No`})]}):(0,C.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>V(e),disabled:r,title:`Delete ${n}`,"aria-label":`Delete ${n}`,children:r?(0,C.jsx)(d,{size:14,className:`spin`}):(0,C.jsx)(t,{size:14})})]}):(0,C.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,C.jsx)(h,{size:14}),(0,C.jsx)(`span`,{className:`data-entry-name`,children:n}),(0,C.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function N(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 P(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{m as a,h as i,T as n,x as r,w as t};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{i as t,o as n,r,t as i}from"./jsx-runtime-DkaAusaX.js";import{A as a,D as o,M as s,N as c,O as l,S as u,_ as d,a as f,b as p,c as m,g as h,h as g,i as _,j as v,n as y,o as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D}from"./useVoiceRecorder-CSc_hxjV.js";import{t as O}from"./Checkbox-CTGhpDKq.js";var k=r(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),A=t(),j=e(n(),1),M=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,N=new Set(M.split(`,`)),P=20*1024*1024,F=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function I(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(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 L(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function R(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function z(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function B(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function ee(e){let[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`loading`),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),_=(0,j.useMemo)(()=>L(),[]),v=(0,j.useMemo)(()=>R(),[]),[y,b]=(0,j.useState)(null),x=(0,j.useRef)(_||``),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(!1),T=(0,j.useRef)(null),[E,D]=(0,j.useState)(`sign-in`),[O,k]=(0,j.useState)(null),A=(0,j.useRef)(null),M=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(M.current=e)}catch{}},[]);let N=(0,j.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),P=(0,j.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),z=(0,j.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(A.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),B=(0,j.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=M.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:I(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return F&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?z(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return F&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,z]);return{sessionId:t,sessionKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:B,startNewSession:(0,j.useCallback)(async()=>{S.current=null,C.current=null,M.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await B();t&&e(t)},[B,e]),enterChat:N,enterGate:P,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateSessionKeyRef:A,groupContext:y,groupSlug:v}}function te({sessionKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,j.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of p(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(F&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,j.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),m={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},h;o(e=>{let t=[...e,m,{role:`maxy`,content:``,timestamp:Date.now()}];return h=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[h]={...t[h],content:l},t}))},m=setInterval(f,60);try{for await(let e of p(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[h]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[h]={...r,components:i},n}))}}finally{clearInterval(m),f()}}catch(e){if(F&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[h]={...r[h],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,j.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({sessionKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,j.useRef)(new Date().toISOString()),a=(0,j.useRef)(!0);(0,j.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,j.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));if(r.length===0)return e;let i=[...e,...r];return i.sort((e,t)=>e.timestamp-t.timestamp),i})}catch(e){console.error(`[group-poll] failed: ${e instanceof Error?e.message:String(e)}`)}},[e,t,r]);(0,j.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var V=i();function H({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,j.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,V.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,V.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function U({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateSessionKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(``),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(null),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(!1);async function k(e){if(e.preventDefault(),!E){C(null),D(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),C(null)):C(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?C(i.error||`Too many attempts. Please try again later.`):C(i.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function A(e){if(!E){C(null),D(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:v,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(C(s.error||`Invalid code`),_(``))}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function M(e){if(e.preventDefault(),!E){if(C(null),l!==d){C(`Passwords do not match`);return}if(!z(l).every(e=>e.met)){C(`Password does not meet requirements`);return}D(!0);try{let e=i.current;if(!e){C(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?C(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):C(n.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function N(e){if(e.preventDefault(),!(E||!s)){C(null),D(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?C((await t.json()).error||`Too many attempts. Please try again later.`):(T(`If an account exists, a reset link has been sent.`),setTimeout(()=>{x(!1),T(null)},4e3))}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}switch(e){case`set-password`:{let e=z(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,V.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,V.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:M,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,V.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(O,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,V.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,V.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,V.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,V.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||E,loading:E,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,B(v,`phone`)]}),(0,V.jsx)(H,{value:h,onChange:_,onComplete:A,disabled:E}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),E&&(0,V.jsxs)(`div`,{className:`gate-loading`,children:[(0,V.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,V.jsx)(`div`,{className:`gate-resend`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),_(``),C(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),b?(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),w&&(0,V.jsx)(`div`,{className:`gate-success`,children:w}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||E,loading:E,children:`Send reset link`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!1),C(null),T(null)},children:`Back to sign in`})})]}):(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(O,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||E,loading:E,children:`Sign in`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!0),C(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,V.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`primary`,onClick:()=>{t(`sign-in`),C(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),_(``)},children:`Back to sign in`})})]})})}}var W={"single-select":m,"multi-select":S,"action-buttons":b};function G({name:e,data:t,onSubmit:n,submitted:r}){let i=W[e];return i?(0,V.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(W).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function re({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:o,onComponentSubmit:s,remainingSuggestions:l,onSuggestionClick:u,isAtBottom:d,setIsAtBottom:p,isGroup:m,sessionId:h}){let[_,y]=(0,j.useState)(new Set),[b,x]=(0,j.useState)(new Set),S=(0,j.useRef)(null),C=(0,j.useRef)(null),T=(0,j.useRef)(null),E=(0,j.useRef)(!1),D=(0,j.useRef)(!1),k=(0,j.useRef)(!1),A=(0,j.useRef)(0),M=(0,j.useRef)(!1),N=(0,j.useRef)(new Map);M.current=t,(0,j.useEffect)(()=>{t&&!E.current&&d&&(D.current=!0)},[t,d]),(0,j.useEffect)(()=>{if(!D.current&&!d){E.current=t,k.current=!1;return}if(E.current&&!t&&T.current&&C.current){let e=T.current;if(e.offsetHeight>C.current.clientHeight){D.current=!1,k.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),E.current=t;return}}(d||D.current)&&!k.current&&S.current?.scrollIntoView({behavior:`smooth`}),E.current&&!t&&(D.current=!1),E.current=t},[e,d,t]),(0,j.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.scrollTop;M.current&&t<A.current&&(D.current=!1),A.current=t,p(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[p]),(0,j.useEffect)(()=>{function e(){x(e=>{let t=new Set;return N.current.forEach((n,r)=>{n.isConnected&&(_.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return N.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,_]);let P=[...e].sort((e,t)=>e.timestamp-t.timestamp);(0,j.useEffect)(()=>{r&&console.log(`[selection] entered`,{conversationId:h??`unknown`,order:P.map(e=>({ts:e.timestamp,role:e.role,id:e.messageId}))})},[r]);let F=P.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:C,children:[n&&e.length===0&&(0,V.jsx)(`div`,{className:`session-error`,children:(0,V.jsx)(`p`,{children:n})}),P.map((e,n)=>{if(e.hidden)return null;let l=t&&n===P.length-1,u=`${e.timestamp}_${e.role}`,d=i.has(u);return(0,V.jsxs)(`div`,{ref:n===F?T:void 0,className:`message ${e.role}${d?` selected`:``}`,children:[r&&!l&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(O,{checked:d,onChange:()=>o(u)})}),(0,V.jsxs)(`div`,{className:`bubble`,children:[m&&e.role===`visitor`&&e.senderName&&(0,V.jsx)(`span`,{className:`bubble-sender`,children:e.senderName}),e.role===`visitor`&&e.content?(()=>{let t=_.has(n),r=b.has(n);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:e=>{e?N.current.set(n,e):N.current.delete(n)},className:t?`bubble-content`:`bubble-content clamped${r?` overflowing`:``}`,children:e.content}),r&&(0,V.jsx)(`div`,{className:`bubble-expand`,children:(0,V.jsx)(g,{variant:`icon`,className:t?`expanded`:``,onClick:()=>y(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),"aria-label":t?`Collapse message`:`Expand message`,children:(0,V.jsx)(c,{size:14})})})]})})():e.content?(0,V.jsx)(w,{content:e.content,timestamp:f(e.timestamp)}):(0,V.jsxs)(`span`,{className:`typing-indicator`,children:[(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`})]}),e.attachments&&e.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,V.jsx)(a,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(v,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),e.role===`visitor`&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:f(e.timestamp)})]}),e.role===`maxy`&&e.components&&e.components.length>0&&(0,V.jsx)(`div`,{className:`public-components`,children:e.components.map((e,t)=>(0,V.jsx)(`div`,{className:`public-component-enter`,children:(0,V.jsx)(G,{name:e.name,data:e.data,onSubmit:e=>s(n,t,e),submitted:e.submitted})},t))})]},n)}),!t&&l.length>0&&(0,V.jsx)(`div`,{className:`chat-suggestions`,children:l.map(e=>(0,V.jsx)(g,{variant:`suggestion`,onClick:()=>u(e),children:e},e))}),(0,V.jsx)(`div`,{ref:S})]}),!d&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>S.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(c,{size:18})})]})}function ie({selectedItems:e,messages:t,isStreaming:n,copySelected:r,selectAll:i,exitSelection:a,showCopyToast:o}){let[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(!1);function f(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function p(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function m(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
1
+ import{o as e}from"./chunk-DD-I1_y5.js";import{i as t,o as n,r,t as i}from"./jsx-runtime-DH5S-MwB.js";import{A as a,D as o,M as s,N as c,O as l,S as u,_ as d,a as f,b as p,c as m,g as h,h as g,i as _,j as v,n as y,o as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D}from"./useVoiceRecorder-Cb0nAtOo.js";import{t as O}from"./Checkbox-Bq6ORjz2.js";var k=r(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),A=t(),j=e(n(),1),M=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar`,N=new Set(M.split(`,`)),P=20*1024*1024,F=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function I(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(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 L(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function R(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function z(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function B(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function ee(e){let[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(`loading`),[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(null),_=(0,j.useMemo)(()=>L(),[]),v=(0,j.useMemo)(()=>R(),[]),[y,b]=(0,j.useState)(null),x=(0,j.useRef)(_||``),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(!1),T=(0,j.useRef)(null),[E,D]=(0,j.useState)(`sign-in`),[O,k]=(0,j.useState)(null),A=(0,j.useRef)(null),M=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(M.current=e)}catch{}},[]);let N=(0,j.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),P=(0,j.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),z=(0,j.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(A.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),B=(0,j.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=M.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:I(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return F&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?z(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return F&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,z]);return{sessionId:t,sessionKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:B,startNewSession:(0,j.useCallback)(async()=>{S.current=null,C.current=null,M.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await B();t&&e(t)},[B,e]),enterChat:N,enterGate:P,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateSessionKeyRef:A,groupContext:y,groupSlug:v}}function te({sessionKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,j.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of p(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(F&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,j.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),m={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},h;o(e=>{let t=[...e,m,{role:`maxy`,content:``,timestamp:Date.now()}];return h=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}F&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[h]={...t[h],content:l},t}))},m=setInterval(f,60);try{for await(let e of p(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[h]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[h]={...r,components:i},n}))}}finally{clearInterval(m),f()}}catch(e){if(F&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[h]={...r[h],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,j.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({sessionKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,j.useRef)(new Date().toISOString()),a=(0,j.useRef)(!0);(0,j.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,j.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));if(r.length===0)return e;let i=[...e,...r];return i.sort((e,t)=>e.timestamp-t.timestamp),i})}catch(e){console.error(`[group-poll] failed: ${e instanceof Error?e.message:String(e)}`)}},[e,t,r]);(0,j.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var V=i();function H({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,j.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,V.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,V.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function U({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateSessionKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,j.useState)(``),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(``),[p,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(``),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(null),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(!1);async function k(e){if(e.preventDefault(),!E){C(null),D(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),C(null)):C(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?C(i.error||`Too many attempts. Please try again later.`):C(i.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function A(e){if(!E){C(null),D(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:v,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(C(s.error||`Invalid code`),_(``))}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function M(e){if(e.preventDefault(),!E){if(C(null),l!==d){C(`Passwords do not match`);return}if(!z(l).every(e=>e.met)){C(`Password does not meet requirements`);return}D(!0);try{let e=i.current;if(!e){C(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?C(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):C(n.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}async function N(e){if(e.preventDefault(),!(E||!s)){C(null),D(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?C((await t.json()).error||`Too many attempts. Please try again later.`):(T(`If an account exists, a reset link has been sent.`),setTimeout(()=>{x(!1),T(null)},4e3))}catch{C(`Unable to connect. Please try again.`)}finally{D(!1)}}}switch(e){case`set-password`:{let e=z(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,V.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,V.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:M,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,V.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(O,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,V.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,V.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,V.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,V.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||E,loading:E,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,B(v,`phone`)]}),(0,V.jsx)(H,{value:h,onChange:_,onComplete:A,disabled:E}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),E&&(0,V.jsxs)(`div`,{className:`gate-loading`,children:[(0,V.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,V.jsx)(`div`,{className:`gate-resend`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),_(``),C(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),b?(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),w&&(0,V.jsx)(`div`,{className:`gate-success`,children:w}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||E,loading:E,children:`Send reset link`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!1),C(null),T(null)},children:`Back to sign in`})})]}):(0,V.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,V.jsxs)(`div`,{className:`gate-field`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,V.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,V.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,V.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,V.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,V.jsx)(O,{checked:p,onChange:m,label:`Show`})}),(0,V.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),S&&(0,V.jsx)(`div`,{className:`gate-error`,children:S}),(0,V.jsx)(`div`,{className:`gate-submit`,children:(0,V.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||E,loading:E,children:`Sign in`})}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!0),C(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,V.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,V.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`primary`,onClick:()=>{t(`sign-in`),C(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,V.jsx)(`div`,{className:`gate-wrap`,children:(0,V.jsxs)(`div`,{className:`gate-card`,children:[(0,V.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,V.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,V.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,V.jsx)(`div`,{className:`gate-actions`,children:(0,V.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),_(``)},children:`Back to sign in`})})]})})}}var W={"single-select":m,"multi-select":S,"action-buttons":b};function G({name:e,data:t,onSubmit:n,submitted:r}){let i=W[e];return i?(0,V.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(W).join(`, `)}`),(0,V.jsx)(`div`,{className:`component-card component-card--error`,children:(0,V.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function re({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:o,onComponentSubmit:s,remainingSuggestions:l,onSuggestionClick:u,isAtBottom:d,setIsAtBottom:p,isGroup:m,sessionId:h}){let[_,y]=(0,j.useState)(new Set),[b,x]=(0,j.useState)(new Set),S=(0,j.useRef)(null),C=(0,j.useRef)(null),T=(0,j.useRef)(null),E=(0,j.useRef)(!1),D=(0,j.useRef)(!1),k=(0,j.useRef)(!1),A=(0,j.useRef)(0),M=(0,j.useRef)(!1),N=(0,j.useRef)(new Map);M.current=t,(0,j.useEffect)(()=>{t&&!E.current&&d&&(D.current=!0)},[t,d]),(0,j.useEffect)(()=>{if(!D.current&&!d){E.current=t,k.current=!1;return}if(E.current&&!t&&T.current&&C.current){let e=T.current;if(e.offsetHeight>C.current.clientHeight){D.current=!1,k.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),E.current=t;return}}(d||D.current)&&!k.current&&S.current?.scrollIntoView({behavior:`smooth`}),E.current&&!t&&(D.current=!1),E.current=t},[e,d,t]),(0,j.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{let t=e.scrollTop;M.current&&t<A.current&&(D.current=!1),A.current=t,p(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[p]),(0,j.useEffect)(()=>{function e(){x(e=>{let t=new Set;return N.current.forEach((n,r)=>{n.isConnected&&(_.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return N.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,_]);let P=[...e].sort((e,t)=>e.timestamp-t.timestamp);(0,j.useEffect)(()=>{r&&console.log(`[selection] entered`,{conversationId:h??`unknown`,order:P.map(e=>({ts:e.timestamp,role:e.role,id:e.messageId}))})},[r]);let F=P.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,V.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,V.jsx)(`div`,{className:`selection-overlay-band`}),(0,V.jsxs)(`div`,{className:`chat-messages`,ref:C,children:[n&&e.length===0&&(0,V.jsx)(`div`,{className:`session-error`,children:(0,V.jsx)(`p`,{children:n})}),P.map((e,n)=>{if(e.hidden)return null;let l=t&&n===P.length-1,u=`${e.timestamp}_${e.role}`,d=i.has(u);return(0,V.jsxs)(`div`,{ref:n===F?T:void 0,className:`message ${e.role}${d?` selected`:``}`,children:[r&&!l&&(0,V.jsx)(`div`,{className:`message-select-check`,children:(0,V.jsx)(O,{checked:d,onChange:()=>o(u)})}),(0,V.jsxs)(`div`,{className:`bubble`,children:[m&&e.role===`visitor`&&e.senderName&&(0,V.jsx)(`span`,{className:`bubble-sender`,children:e.senderName}),e.role===`visitor`&&e.content?(()=>{let t=_.has(n),r=b.has(n);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{ref:e=>{e?N.current.set(n,e):N.current.delete(n)},className:t?`bubble-content`:`bubble-content clamped${r?` overflowing`:``}`,children:e.content}),r&&(0,V.jsx)(`div`,{className:`bubble-expand`,children:(0,V.jsx)(g,{variant:`icon`,className:t?`expanded`:``,onClick:()=>y(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),"aria-label":t?`Collapse message`:`Expand message`,children:(0,V.jsx)(c,{size:14})})})]})})():e.content?(0,V.jsx)(w,{content:e.content,timestamp:f(e.timestamp)}):(0,V.jsxs)(`span`,{className:`typing-indicator`,children:[(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`}),(0,V.jsx)(`span`,{className:`typing-dot`})]}),e.attachments&&e.attachments.length>0&&(0,V.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,V.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,V.jsx)(a,{size:12}):e.mimeType.startsWith(`text/`)?(0,V.jsx)(v,{size:12}):null,(0,V.jsx)(`span`,{children:e.filename})]},t))}),e.role===`visitor`&&(0,V.jsx)(`span`,{className:`message-timestamp`,children:f(e.timestamp)})]}),e.role===`maxy`&&e.components&&e.components.length>0&&(0,V.jsx)(`div`,{className:`public-components`,children:e.components.map((e,t)=>(0,V.jsx)(`div`,{className:`public-component-enter`,children:(0,V.jsx)(G,{name:e.name,data:e.data,onSubmit:e=>s(n,t,e),submitted:e.submitted})},t))})]},n)}),!t&&l.length>0&&(0,V.jsx)(`div`,{className:`chat-suggestions`,children:l.map(e=>(0,V.jsx)(g,{variant:`suggestion`,onClick:()=>u(e),children:e},e))}),(0,V.jsx)(`div`,{ref:S})]}),!d&&(0,V.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>S.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,V.jsx)(c,{size:18})})]})}function ie({selectedItems:e,messages:t,isStreaming:n,copySelected:r,selectAll:i,exitSelection:a,showCopyToast:o}){let[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(!1);function f(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function p(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function m(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
2
2
 
3
3
  ---
4
4
 
@@ -1 +1 @@
1
- import{o as e}from"./chunk-DD-I1_y5.js";import{o as t,r as n}from"./jsx-runtime-DkaAusaX.js";var r=n(`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`}]]),i=n(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),a=n(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),o=n(`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`}]]),s=n(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),c=n(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),l=n(`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`}]]),u=`maxy-admin-session`,d=typeof BroadcastChannel<`u`;function f(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`)&&typeof t.ts==`number`}function p(e,t){if(!d){console.log(`[admin-session-broadcast] outcome=skipped reason=broadcastchannel-unavailable surface=${t}`);return}let n=new BroadcastChannel(u);try{let r={type:`rotation`,newKey:e,surface:t,ts:Date.now()};n.postMessage(r),console.log(`[admin-session-broadcast] outcome=sent newKey=${e.slice(0,8)} surface=${t}`)}finally{n.close()}}function m(e){if(!d)return()=>{};let t=new BroadcastChannel(u),n=t=>{if(!f(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 h=e(t(),1),g=`maxy-admin-session-key`;function _(e,t){return`${e}${e.includes(`?`)?`&`:`?`}session_key=${encodeURIComponent(t)}`}async function v(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 y(){try{return sessionStorage.getItem(g)}catch{return null}}function b(e){let{initialSessionKey:t,surface:n}=e,[r,i]=(0,h.useState)(t),a=(0,h.useRef)(t);(0,h.useEffect)(()=>{a.current=r},[r]),(0,h.useEffect)(()=>{t!==a.current&&(i(t),a.current=t,s(e=>e+1))},[t]);let[o,s]=(0,h.useState)(0),[c,l]=(0,h.useState)(null);(0,h.useEffect)(()=>m(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,h.useCallback)(()=>{try{sessionStorage.removeItem(g)}catch{}window.location.href=`/`},[]);return{adminFetch:(0,h.useCallback)(async(e,t)=>{let r=a.current,o=_(e,r),c=await fetch(o,t);if(c.status!==401)return c;let d=await v(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=y();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=_(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]),sessionKey:r,sessionRefetchNonce:o,banner:c,reloadToLogin:u}}export{s as a,i as c,c as i,r as l,p as n,o,l as r,a as s,b as t};
1
+ import{o as e}from"./chunk-DD-I1_y5.js";import{o as t,r as n}from"./jsx-runtime-DH5S-MwB.js";var r=n(`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`}]]),i=n(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),a=n(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),o=n(`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`}]]),s=n(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),c=n(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),l=n(`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`}]]),u=`maxy-admin-session`,d=typeof BroadcastChannel<`u`;function f(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`)&&typeof t.ts==`number`}function p(e,t){if(!d){console.log(`[admin-session-broadcast] outcome=skipped reason=broadcastchannel-unavailable surface=${t}`);return}let n=new BroadcastChannel(u);try{let r={type:`rotation`,newKey:e,surface:t,ts:Date.now()};n.postMessage(r),console.log(`[admin-session-broadcast] outcome=sent newKey=${e.slice(0,8)} surface=${t}`)}finally{n.close()}}function m(e){if(!d)return()=>{};let t=new BroadcastChannel(u),n=t=>{if(!f(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 h=e(t(),1),g=`maxy-admin-session-key`;function _(e,t){return`${e}${e.includes(`?`)?`&`:`?`}session_key=${encodeURIComponent(t)}`}async function v(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 y(){try{return sessionStorage.getItem(g)}catch{return null}}function b(e){let{initialSessionKey:t,surface:n}=e,[r,i]=(0,h.useState)(t),a=(0,h.useRef)(t);(0,h.useEffect)(()=>{a.current=r},[r]),(0,h.useEffect)(()=>{t!==a.current&&(i(t),a.current=t,s(e=>e+1))},[t]);let[o,s]=(0,h.useState)(0),[c,l]=(0,h.useState)(null);(0,h.useEffect)(()=>m(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,h.useCallback)(()=>{try{sessionStorage.removeItem(g)}catch{}window.location.href=`/`},[]);return{adminFetch:(0,h.useCallback)(async(e,t)=>{let r=a.current,o=_(e,r),c=await fetch(o,t);if(c.status!==401)return c;let d=await v(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=y();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=_(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]),sessionKey:r,sessionRefetchNonce:o,banner:c,reloadToLogin:u}}export{s as a,i as c,c as i,r as l,p as n,o,l as r,a as s,b as t};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CCUSwZB_.js","assets/preload-helper-qlgyTAkD.js","assets/dist-CrzV1W3-.js","assets/chunk-DD-I1_y5.js","assets/chunk-U2HBQHQK-BZnA7c4T.js","assets/src-Bo15iQ7w.js","assets/chunk-5PVQY5BW-RhIfPCRB.js","assets/chunk-ICPOFSXX-Di63NBur.js","assets/_baseFor-Dn4GSmI6.js","assets/isEmpty-h-wRi_o9.js","assets/chunk-336JU56O-BpATJiGl.js","assets/chunk-5FUZZQ4R-BoTfWHuW.js","assets/chunk-X2U36JSP-DpQ2OA_c.js","assets/chunk-ZZ45TVLE-DBSm41oP.js","assets/rough.esm-NLRoWnq-.js","assets/chunk-ENJZ2VHE-CNHjq5xK.js","assets/line-DlKKhwkO.js","assets/path-7vUsG-o2.js","assets/array-DJN9YAVf.js","assets/chunk-BSJP7CBP-CTsYuARh.js","assets/chunk-426QAEUC-Wz6Bpsil.js","assets/chunk-XPW4576I-BccP1mlQ.js"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-DkaAusaX.js";import{t as s}from"./Checkbox-CTGhpDKq.js";import{t as c}from"./preload-helper-qlgyTAkD.js";var l=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),u=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),d=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),f=a(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),p=a(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),m=a(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),h=a(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),g=a(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),_=a(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),v=a(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),y=a(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),b=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),x=e(i(),1);async function S(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function C(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(new Set),[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=(0,x.useCallback)(()=>{t(!0),r(new Set)},[]),c=(0,x.useCallback)(()=>{t(!1),r(new Set)},[]),l=(0,x.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,x.useCallback)(e=>{e.length!==0&&r(t=>e.every(e=>t.has(e))?new Set:new Set(e))},[]),d=(0,x.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),f=(0,x.useCallback)(e=>({onPointerDown:()=>{o.current=setTimeout(()=>{t(!0),r(new Set([e])),o.current=null},500)},onPointerUp:d,onPointerLeave:d,onPointerCancel:d}),[d]),p=(0,x.useCallback)(e=>{a(e?`copied`:`failed`),setTimeout(()=>a(!1),1500)},[]);return{selectionMode:e,selectedItems:n,copyToast:i,longPressProps:f,enterSelection:s,exitSelection:c,toggleSelectItem:l,selectAll:u,copySelected:(0,x.useCallback)(async(e,t)=>{let r=[...n].sort(t).map(t=>e(t)).filter(Boolean);r.length>0&&p(await S(r.join(`
2
+ import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-DH5S-MwB.js";import{t as s}from"./Checkbox-Bq6ORjz2.js";import{t as c}from"./preload-helper-qlgyTAkD.js";var l=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),u=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),d=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),f=a(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),p=a(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),m=a(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),h=a(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),g=a(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),_=a(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),v=a(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),y=a(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),b=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),x=e(i(),1);async function S(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function C(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(new Set),[i,a]=(0,x.useState)(!1),o=(0,x.useRef)(null);(0,x.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=(0,x.useCallback)(()=>{t(!0),r(new Set)},[]),c=(0,x.useCallback)(()=>{t(!1),r(new Set)},[]),l=(0,x.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,x.useCallback)(e=>{e.length!==0&&r(t=>e.every(e=>t.has(e))?new Set:new Set(e))},[]),d=(0,x.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),f=(0,x.useCallback)(e=>({onPointerDown:()=>{o.current=setTimeout(()=>{t(!0),r(new Set([e])),o.current=null},500)},onPointerUp:d,onPointerLeave:d,onPointerCancel:d}),[d]),p=(0,x.useCallback)(e=>{a(e?`copied`:`failed`),setTimeout(()=>a(!1),1500)},[]);return{selectionMode:e,selectedItems:n,copyToast:i,longPressProps:f,enterSelection:s,exitSelection:c,toggleSelectItem:l,selectAll:u,copySelected:(0,x.useCallback)(async(e,t)=>{let r=[...n].sort(t).map(t=>e(t)).filter(Boolean);r.length>0&&p(await S(r.join(`
3
3
 
4
4
  ---
5
5
 
@@ -5,12 +5,12 @@
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-Y77FLKjs.js"></script>
8
+ <script type="module" crossorigin src="/assets/data-DwZZ7qbH.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DkaAusaX.js">
11
- <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-DmHu0oCx.js">
12
- <link rel="modulepreload" crossorigin href="/assets/page-DkBfWy4C.js">
13
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-D4WovFYk.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DH5S-MwB.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-B93ig7ef.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/page-CFWoVkgV.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-DidQeNoZ.css">
14
14
  </head>
15
15
  <body>
16
16
  <div id="root"></div>
@@ -5,13 +5,13 @@
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-BlrcvwWP.js"></script>
8
+ <script type="module" crossorigin src="/assets/graph-DceEv42K.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DkaAusaX.js">
11
- <link rel="modulepreload" crossorigin href="/assets/Checkbox-CTGhpDKq.js">
12
- <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-DmHu0oCx.js">
13
- <link rel="modulepreload" crossorigin href="/assets/page-ClTUYMK8.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-D4WovFYk.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DH5S-MwB.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/Checkbox-Bq6ORjz2.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-B93ig7ef.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/page-Bpi_jPw6.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-DidQeNoZ.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -5,16 +5,16 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Real Agent</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-CgGQafDG.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-CstEkw-G.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DkaAusaX.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DH5S-MwB.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
12
- <link rel="modulepreload" crossorigin href="/assets/Checkbox-CTGhpDKq.js">
13
- <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CSc_hxjV.js">
14
- <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-DmHu0oCx.js">
15
- <link rel="modulepreload" crossorigin href="/assets/page-DkBfWy4C.js">
16
- <link rel="modulepreload" crossorigin href="/assets/page-ClTUYMK8.js">
17
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-D4WovFYk.css">
12
+ <link rel="modulepreload" crossorigin href="/assets/Checkbox-Bq6ORjz2.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-Cb0nAtOo.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/useAdminFetch-B93ig7ef.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/page-CFWoVkgV.js">
16
+ <link rel="modulepreload" crossorigin href="/assets/page-Bpi_jPw6.js">
17
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-DidQeNoZ.css">
18
18
  <link rel="stylesheet" crossorigin href="/assets/admin-CWMpccrR.css">
19
19
  <link rel="stylesheet" href="/brand-defaults.css">
20
20
  </head>
@@ -5,13 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Real Agent</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-BdVIVpv8.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-BWMwq5Jj.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DkaAusaX.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DH5S-MwB.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
12
- <link rel="modulepreload" crossorigin href="/assets/Checkbox-CTGhpDKq.js">
13
- <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CSc_hxjV.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-D4WovFYk.css">
12
+ <link rel="modulepreload" crossorigin href="/assets/Checkbox-Bq6ORjz2.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-Cb0nAtOo.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-DidQeNoZ.css">
15
15
  <link rel="stylesheet" href="/brand-defaults.css">
16
16
  </head>
17
17
  <body>
@@ -45,7 +45,7 @@ import {
45
45
  vncLog,
46
46
  waitForExit,
47
47
  writeChromiumWrapper
48
- } from "./chunk-IVTESKFR.js";
48
+ } from "./chunk-UXN47TX2.js";
49
49
  import {
50
50
  agentLogStream,
51
51
  clearSessionHistory,
@@ -73,7 +73,7 @@ import {
73
73
  sigtermFlushStreamLogs,
74
74
  unregisterSession,
75
75
  validateSession
76
- } from "./chunk-KD3XP4IK.js";
76
+ } from "./chunk-BYPWJ4Z6.js";
77
77
  import {
78
78
  ACCOUNTS_DIR,
79
79
  COMMERCIAL_MODE,
@@ -98,7 +98,7 @@ import {
98
98
  openCloudflareTask,
99
99
  readTunnelState,
100
100
  resolveUnitGoneVerdict
101
- } from "./chunk-CRAIGEXY.js";
101
+ } from "./chunk-B43O764H.js";
102
102
  import {
103
103
  GREETING_DIRECTIVE,
104
104
  HAIKU_MODEL,
@@ -130,7 +130,7 @@ import {
130
130
  verifyAndGetConversationUpdatedAt,
131
131
  verifyConversationOwnership,
132
132
  writeAdminUserAndPerson
133
- } from "./chunk-I2NOLBQA.js";
133
+ } from "./chunk-TQ6L56KS.js";
134
134
 
135
135
  // ../lib/graph-trash/dist/index.js
136
136
  var require_dist = __commonJS({
@@ -7493,7 +7493,7 @@ var app11 = new Hono();
7493
7493
  app11.post("/cancel", requireAdminSession, async (c) => {
7494
7494
  const session_key = c.var.sessionKey;
7495
7495
  try {
7496
- const { interruptClient: interruptClient2 } = await import("./client-pool-J5BCVVI2.js");
7496
+ const { interruptClient: interruptClient2 } = await import("./client-pool-HC6PMV2X.js");
7497
7497
  await interruptClient2(session_key);
7498
7498
  return c.json({ ok: true });
7499
7499
  } catch (err) {
@@ -12140,7 +12140,6 @@ app36.get("/:rel{.*}", (c) => {
12140
12140
  const reqPath = c.req.path;
12141
12141
  const rawRel = c.req.param("rel") ?? "";
12142
12142
  const trimmed = rawRel.replace(/^\/+/, "").replace(/\/+$/, "");
12143
- const isDirRequest = rawRel === "" || rawRel.endsWith("/") || reqPath.endsWith("/");
12144
12143
  const account = resolveAccount();
12145
12144
  if (!account) {
12146
12145
  console.error(`[sites] no-account path=${reqPath} status=404`);
@@ -12174,10 +12173,16 @@ app36.get("/:rel{.*}", (c) => {
12174
12173
  } catch {
12175
12174
  stat7 = null;
12176
12175
  }
12176
+ if (stat7?.isDirectory() && !reqPath.endsWith("/")) {
12177
+ const search = new URL(c.req.url).search;
12178
+ const target = `${reqPath}/${search}`;
12179
+ console.log(
12180
+ `[sites] redirect-trailing-slash from=${reqPath} to=${reqPath}/ status=301`
12181
+ );
12182
+ return c.redirect(target, 301);
12183
+ }
12177
12184
  if (stat7?.isDirectory()) {
12178
12185
  filePath = resolve21(filePath, "index.html");
12179
- } else if (stat7 === null && isDirRequest) {
12180
- filePath = resolve21(filePath, "index.html");
12181
12186
  }
12182
12187
  if (!filePath.startsWith(rootDir + "/")) {
12183
12188
  console.error(`[sites] path-traversal-rejected path=${reqPath} reason=escape status=403`);
@@ -12980,6 +12985,9 @@ app37.get("/:slug", async (c, next) => {
12980
12985
  }
12981
12986
  await next();
12982
12987
  });
12988
+ if (brandFaviconPath !== "/favicon.ico") {
12989
+ app37.get("/favicon.ico", (c) => c.redirect(brandFaviconPath, 302));
12990
+ }
12983
12991
  app37.use("/*", serveStatic({ root: "./public" }));
12984
12992
  var port = parseInt(process.env.MAXY_UI_INTERNAL_PORT ?? process.env.PORT ?? "19199", 10);
12985
12993
  var hostname = process.env.HOSTNAME ?? "127.0.0.1";
@@ -13061,7 +13069,7 @@ autoDeliverPremiumPlugins(bootEntitlement?.purchasedPlugins ?? void 0);
13061
13069
  (async () => {
13062
13070
  if (!bootAccount) return;
13063
13071
  try {
13064
- const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-XCUO4N74.js");
13072
+ const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-R35AJT27.js");
13065
13073
  const result = await recoverRunningCloudflareTasks(
13066
13074
  bootAccount.accountId,
13067
13075
  configDirForWhatsApp,