@rubytech/create-maxy-code 0.1.355 → 0.1.357

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 (56) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/admin-access-password/__tests__/index.test.ts +25 -0
  3. package/payload/platform/lib/admin-access-password/dist/index.d.ts +7 -1
  4. package/payload/platform/lib/admin-access-password/dist/index.d.ts.map +1 -1
  5. package/payload/platform/lib/admin-access-password/dist/index.js +12 -1
  6. package/payload/platform/lib/admin-access-password/dist/index.js.map +1 -1
  7. package/payload/platform/lib/admin-access-password/src/index.ts +12 -1
  8. package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.d.ts +2 -0
  9. package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.d.ts.map +1 -0
  10. package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.js +109 -0
  11. package/payload/platform/plugins/email/mcp/dist/__tests__/credentials.test.js.map +1 -0
  12. package/payload/platform/plugins/email/mcp/dist/__tests__/email-setup.test.js +22 -0
  13. package/payload/platform/plugins/email/mcp/dist/__tests__/email-setup.test.js.map +1 -1
  14. package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts +14 -7
  15. package/payload/platform/plugins/email/mcp/dist/lib/credentials.d.ts.map +1 -1
  16. package/payload/platform/plugins/email/mcp/dist/lib/credentials.js +87 -31
  17. package/payload/platform/plugins/email/mcp/dist/lib/credentials.js.map +1 -1
  18. package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js +1 -1
  19. package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js.map +1 -1
  20. package/payload/platform/plugins/email/mcp/dist/tools/email-status.d.ts.map +1 -1
  21. package/payload/platform/plugins/email/mcp/dist/tools/email-status.js +2 -1
  22. package/payload/platform/plugins/email/mcp/dist/tools/email-status.js.map +1 -1
  23. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.d.ts +2 -0
  24. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.d.ts.map +1 -0
  25. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.js +60 -0
  26. package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-bootstrap.test.js.map +1 -0
  27. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js +11 -1
  28. package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js.map +1 -1
  29. package/payload/server/{chunk-7GNXBVGY.js → chunk-CXEC5RWB.js} +29 -3
  30. package/payload/server/maxy-edge.js +1 -1
  31. package/payload/server/public/assets/{AdminLoginScreens-4I5CdIWl.js → AdminLoginScreens-BW1UgfoI.js} +1 -1
  32. package/payload/server/public/assets/{AdminShell-Bc9F7X_N.js → AdminShell-CDQDkT1R.js} +1 -1
  33. package/payload/server/public/assets/{Checkbox-DoQV18Ow.js → Checkbox-O1qvMk_u.js} +1 -1
  34. package/payload/server/public/assets/{OperatorConversations-C1I78hON.css → OperatorConversations-CVH-FoJo.css} +1 -1
  35. package/payload/server/public/assets/{admin-DLsMA09F.js → admin-BkYc54bi.js} +1 -1
  36. package/payload/server/public/assets/{browser-w6rY_KAO.js → browser-CySvj140.js} +1 -1
  37. package/payload/server/public/assets/{calendar-CvEdDFYd.js → calendar-DgP7lal2.js} +1 -1
  38. package/payload/server/public/assets/chat-gls5aV50.js +1 -0
  39. package/payload/server/public/assets/{data-p3T_EZFq.js → data-CbI8-CX3.js} +1 -1
  40. package/payload/server/public/assets/{graph-labels-BNZ8u8TE.js → graph-labels-BNnhRQqM.js} +1 -1
  41. package/payload/server/public/assets/{graph-BrwfYOr3.js → graph-uFhGyOZR.js} +1 -1
  42. package/payload/server/public/assets/{operator-BNY1P_mH.js → operator-DeCk_qYw.js} +1 -1
  43. package/payload/server/public/assets/{page-CtygoIXt.js → page-jGwq-DpW.js} +2 -2
  44. package/payload/server/public/assets/{public-CDzw6yjH.js → public-DgltXhnD.js} +1 -1
  45. package/payload/server/public/browser.html +4 -4
  46. package/payload/server/public/calendar.html +4 -4
  47. package/payload/server/public/chat.html +5 -5
  48. package/payload/server/public/data.html +4 -4
  49. package/payload/server/public/graph.html +6 -6
  50. package/payload/server/public/index.html +6 -6
  51. package/payload/server/public/operator.html +7 -7
  52. package/payload/server/public/public.html +5 -5
  53. package/payload/server/server.js +11 -2
  54. package/payload/server/userprofile-reconcile-GLGKDVQQ.js +48 -0
  55. package/payload/server/public/assets/chat-BlOWMUVI.js +0 -1
  56. /package/payload/server/public/assets/{OperatorConversations-BJY9FZbr.js → OperatorConversations-jqaPCHwB.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{C as t,U as n,V as r,i,v as a}from"./OperatorConversations-BJY9FZbr.js";import{n as o,t as s}from"./AdminLoginScreens-4I5CdIWl.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-Bc9F7X_N.js";import"./Checkbox-DoQV18Ow.js";var u=r(),d=e(n(),1),f=t();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=o(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,f.jsx)(a,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:r}),(0,f.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(i,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(s,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{C as t,U as n,V as r,i,v as a}from"./OperatorConversations-jqaPCHwB.js";import{n as o,t as s}from"./AdminLoginScreens-BW1UgfoI.js";import"./admin-types-DJoj6VJv.js";import{r as c,t as l}from"./AdminShell-CDQDkT1R.js";import"./Checkbox-O1qvMk_u.js";var u=r(),d=e(n(),1),f=t();function p({onOpen:e}){return(0,f.jsx)(`footer`,{className:`admin-footer`,children:(0,f.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,f.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,f.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function m(){let e=o(),[t,n]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,d.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),u=(0,d.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,f.jsx)(a,{cacheKey:e.cacheKey,onSessionExpired:u,surface:`chat`,children:(0,f.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(p,{onOpen:r}),(0,f.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,f.jsx)(f.Fragment,{children:t.selectedWhatsapp&&e.cacheKey?(0,f.jsx)(i,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,cleanViewToggle:!0},t.selectedWhatsapp.sessionId):(0,f.jsx)(`main`,{})})})}):(0,f.jsx)(s,{auth:e})}(0,u.createRoot)(document.getElementById(`root`)).render((0,f.jsx)(m,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,N as r,R as i,U as a,V as o,b as s,j as c,v as l,y as u}from"./OperatorConversations-BJY9FZbr.js";import{_ as d,t as f}from"./AdminShell-Bc9F7X_N.js";var p=i(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=o(),h=e(a(),1),g=n(),_=`maxy-vnc-popout`;function v(){let[e,n]=(0,h.useState)(null),[i,a]=(0,h.useState)(!1),[o,l]=(0,h.useState)(null),d=u(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(t=>{e||(console.info(`[browser-page] op=viewer-probe available=${t.ok}`),n(t.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),n(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(s.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{a(!0),l(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:i,children:[i?(0,g.jsx)(t,{size:14,className:`spin`}):(0,g.jsx)(c,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(r,{size:14}),` Pop out`]}),o&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:o})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,g.jsx)(l,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,C as n,N as r,R as i,U as a,V as o,b as s,j as c,v as l,y as u}from"./OperatorConversations-jqaPCHwB.js";import{_ as d,t as f}from"./AdminShell-CDQDkT1R.js";var p=i(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=o(),h=e(a(),1),g=n(),_=`maxy-vnc-popout`;function v(){let[e,n]=(0,h.useState)(null),[i,a]=(0,h.useState)(!1),[o,l]=(0,h.useState)(null),d=u(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(t=>{e||(console.info(`[browser-page] op=viewer-probe available=${t.ok}`),n(t.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),n(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(s.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{a(!0),l(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:i,children:[i?(0,g.jsx)(t,{size:14,className:`spin`}):(0,g.jsx)(c,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(r,{size:14}),` Pop out`]}),o&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:o})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await d();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,g.jsx)(l,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(c,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,F as i,I as a,N as o,O as s,R as c,T as l,U as u,V as d,v as f,w as p}from"./OperatorConversations-BJY9FZbr.js";import{_ as m,d as h,t as g}from"./AdminShell-Bc9F7X_N.js";var _=c(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=c(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=c(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=c(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=c(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),ee=c(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=d(),C=e(u(),1);function w(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function T(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function E(e){let t=w(e),n=t.getDay();return T(t,n===0?-6:1-n)}function D(e){let t=E(e);return Array.from({length:7},(e,n)=>T(t,n))}function O(e){let t=E(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>T(t,n))}function k(){return Array.from({length:24},(e,t)=>t)}function A(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=w(t);return{from:e,to:T(e,1)}}case`week`:{let e=E(t);return{from:e,to:T(e,7)}}case`month`:{let e=E(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:T(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return T(t,n);case`week`:return T(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=r(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function z({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var B=1440,V=1.8;function H(e){return e.getHours()*60+e.getMinutes()}function U(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function W({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=H(n),o=N(i,e)?H(i):B,s=a/B*100,c=Math.max((o-a)/B*100,V);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:U(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var G=44;function K(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function q({anchor:e,meetings:t,onSelect:n}){let r=D(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${G}px`},children:e===0?``:K(e)},e))}),r.map(e=>(0,F.jsx)(W,{day:e,meetings:t,hourHeight:G,onSelect:n},e.toISOString()))]})]})}var J=52;function Y(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function X({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${J}px`},children:e===0?``:Y(e)},e))}),(0,F.jsx)(W,{day:e,meetings:t,hourHeight:J,onSelect:n})]})]})}var Z=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:A(e).map(e=>{let t=O(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:Z.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(te(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:r,onSaved:a,onDeleted:o}){let c=e.kind===`meeting`,[u,d]=(0,C.useState)(!1),[f,m]=(0,C.useState)(!1),[g,v]=(0,C.useState)(!1),[S,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(e),[k,A]=(0,C.useState)(e.title??``),[j,M]=(0,C.useState)(ie(e.startsAt)),[N,P]=(0,C.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,C.useState)(e.location??``),[R,z]=(0,C.useState)(e.privateNote??``),[B,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``);(0,C.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!S&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,r]);let W=(0,C.useCallback)(()=>{let e={},t=k.trim();t!==(D.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(D.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?D.endsAt!==null:D.endsAt===null||Q(r)!==Q(D.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(D.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(D.privateNote??null)&&(e.privateNote=a),e},[k,j,N,I,R,D]),G=(0,C.useCallback)(async()=>{let t=W();if(Object.keys(t).length===0){d(!1);return}w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();O(i.meeting),a(i.meeting),d(!1)}catch(e){E(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[n,W,e.meetingId,a]),K=(0,C.useCallback)(async()=>{let t=B.trim(),r=H.trim();if(!(!t&&!r)){w(!0),E(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();O(o.meeting),a(o.meeting),V(``),U(``)}catch(e){E(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[n,B,H,e.meetingId,a]),q=(0,C.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();O(i.meeting),a(i.meeting)}catch(e){E(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[n,e.meetingId,a]),J=(0,C.useCallback)(async()=>{w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);o(e.meetingId)}catch(e){E(e instanceof Error?e.message:`Delete failed`),w(!1)}},[n,e.meetingId,o]),Y=(0,C.useCallback)(async t=>{v(!1),w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){E(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[n,e.meetingId]),X=re[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{S||r()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:X}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:S,children:(0,F.jsx)(p,{size:16})})]}),!u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:D.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(D)})]}),D.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:D.location})]}),D.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(h,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:D.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),D.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:D.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:X})]})]}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:S})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[D.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),D.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:S,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(p,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:S,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:S,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:S||!Z,"aria-label":`Add attendee`,children:S?(0,F.jsx)(t,{size:13,className:`spin`}):(0,F.jsx)(ee,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>z(e.target.value),disabled:S,rows:3,placeholder:`Only you and your team can see this.`})]})]}),T&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:T}),c&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&!f&&!g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:S,children:[(0,F.jsx)(s,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:S,children:[(0,F.jsx)(l,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{D.attendees.length>0?v(!0):Y(!1)},disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):(0,F.jsx)(i,{size:14}),` Download`]})]}),g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:S,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:S,children:`Cancel`})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),E(null)},disabled:S,children:`Cancel`})]}),f&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:J,disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:S,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(void 0),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(void 0),[d,p]=(0,C.useState)(null),[h,_]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem($)}catch{}if(!t){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let v=(0,C.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,C.useState)(!1),x=(0,C.useCallback)(async()=>{b(!0);try{let e=await m();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return r?e?(0,F.jsx)(f,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(g,{cacheKey:e,businessName:a,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:d,role:h,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`calendar`}),[s,c]=(0,C.useState)(`month`),[l,u]=(0,C.useState)(()=>new Date),[d,f]=(0,C.useState)([]),[p,m]=(0,C.useState)(!1),[h,g]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,ee]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return r(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&ee(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[r]),(0,C.useEffect)(()=>{let e=!1,{from:t,to:n}=j(s,l);return m(!0),g(null),r(`/api/admin/calendar/meetings?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(n.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();f(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),f([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s,l,i,r]);let S=(0,C.useCallback)(()=>u(new Date),[]),w=(0,C.useCallback)(()=>u(e=>M(s,e,-1)),[s]),T=(0,C.useCallback)(()=>u(e=>M(s,e,1)),[s]),E=(0,C.useCallback)(e=>{u(e),c(`month`)},[]);(0,C.useEffect)(()=>{b(null)},[s,l]);let D=(0,C.useCallback)(e=>{f(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),O=(0,C.useCallback)(e=>{f(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:w,"aria-label":`Previous`,children:(0,F.jsx)(a,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(s,l)}),p&&(0,F.jsx)(t,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===s?` cal-view-btn-active`:``}`,onClick:()=>c(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(o,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),s===`day`&&(0,F.jsx)(X,{anchor:l,meetings:d,onSelect:b}),s===`week`&&(0,F.jsx)(q,{anchor:l,meetings:d,onSelect:b}),s===`month`&&(0,F.jsx)(z,{anchor:l,meetings:d,onSelect:b}),s===`year`&&(0,F.jsx)(ne,{anchor:l,meetings:d,onPickMonth:E})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:r,onClose:()=>b(null),onSaved:D,onDeleted:O})]})}(0,S.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,F as i,I as a,N as o,O as s,R as c,T as l,U as u,V as d,v as f,w as p}from"./OperatorConversations-jqaPCHwB.js";import{_ as m,d as h,t as g}from"./AdminShell-CDQDkT1R.js";var _=c(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=c(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=c(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=c(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=c(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),ee=c(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=d(),C=e(u(),1);function w(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function T(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function E(e){let t=w(e),n=t.getDay();return T(t,n===0?-6:1-n)}function D(e){let t=E(e);return Array.from({length:7},(e,n)=>T(t,n))}function O(e){let t=E(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>T(t,n))}function k(){return Array.from({length:24},(e,t)=>t)}function A(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=w(t);return{from:e,to:T(e,1)}}case`week`:{let e=E(t);return{from:e,to:T(e,7)}}case`month`:{let e=E(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:T(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return T(t,n);case`week`:return T(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=r(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function z({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var B=1440,V=1.8;function H(e){return e.getHours()*60+e.getMinutes()}function U(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function W({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=H(n),o=N(i,e)?H(i):B,s=a/B*100,c=Math.max((o-a)/B*100,V);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:U(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var G=44;function K(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function q({anchor:e,meetings:t,onSelect:n}){let r=D(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${G}px`},children:e===0?``:K(e)},e))}),r.map(e=>(0,F.jsx)(W,{day:e,meetings:t,hourHeight:G,onSelect:n},e.toISOString()))]})]})}var J=52;function Y(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function X({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:k().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${J}px`},children:e===0?``:Y(e)},e))}),(0,F.jsx)(W,{day:e,meetings:t,hourHeight:J,onSelect:n})]})]})}var Z=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:A(e).map(e=>{let t=O(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:Z.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(te(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:r,onSaved:a,onDeleted:o}){let c=e.kind===`meeting`,[u,d]=(0,C.useState)(!1),[f,m]=(0,C.useState)(!1),[g,v]=(0,C.useState)(!1),[S,w]=(0,C.useState)(!1),[T,E]=(0,C.useState)(null),[D,O]=(0,C.useState)(e),[k,A]=(0,C.useState)(e.title??``),[j,M]=(0,C.useState)(ie(e.startsAt)),[N,P]=(0,C.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,C.useState)(e.location??``),[R,z]=(0,C.useState)(e.privateNote??``),[B,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``);(0,C.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!S&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,r]);let W=(0,C.useCallback)(()=>{let e={},t=k.trim();t!==(D.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(D.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?D.endsAt!==null:D.endsAt===null||Q(r)!==Q(D.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(D.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(D.privateNote??null)&&(e.privateNote=a),e},[k,j,N,I,R,D]),G=(0,C.useCallback)(async()=>{let t=W();if(Object.keys(t).length===0){d(!1);return}w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();O(i.meeting),a(i.meeting),d(!1)}catch(e){E(e instanceof Error?e.message:`Save failed`)}finally{w(!1)}},[n,W,e.meetingId,a]),K=(0,C.useCallback)(async()=>{let t=B.trim(),r=H.trim();if(!(!t&&!r)){w(!0),E(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let o=await i.json();O(o.meeting),a(o.meeting),V(``),U(``)}catch(e){E(e instanceof Error?e.message:`Add failed`)}finally{w(!1)}}},[n,B,H,e.meetingId,a]),q=(0,C.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();O(i.meeting),a(i.meeting)}catch(e){E(e instanceof Error?e.message:`Remove failed`)}finally{w(!1)}},[n,e.meetingId,a]),J=(0,C.useCallback)(async()=>{w(!0),E(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);o(e.meetingId)}catch(e){E(e instanceof Error?e.message:`Delete failed`),w(!1)}},[n,e.meetingId,o]),Y=(0,C.useCallback)(async t=>{v(!1),w(!0),E(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){E(e instanceof Error?e.message:`Download failed`)}finally{w(!1)}},[n,e.meetingId]),X=re[e.kind??`meeting`],Z=B.trim().length>0||H.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{S||r()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:X}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:S,children:(0,F.jsx)(p,{size:16})})]}),!u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:D.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(D)})]}),D.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:D.location})]}),D.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(h,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:D.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),D.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:D.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:X})]})]}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:S})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:S})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[D.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),D.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>q(e),disabled:S,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(p,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:B,onChange:e=>V(e.target.value),disabled:S,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:H,onChange:e=>U(e.target.value),disabled:S,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:K,disabled:S||!Z,"aria-label":`Add attendee`,children:S?(0,F.jsx)(t,{size:13,className:`spin`}):(0,F.jsx)(ee,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>z(e.target.value),disabled:S,rows:3,placeholder:`Only you and your team can see this.`})]})]}),T&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:T}),c&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&!f&&!g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:S,children:[(0,F.jsx)(s,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:S,children:[(0,F.jsx)(l,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{D.attendees.length>0?v(!0):Y(!1)},disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):(0,F.jsx)(i,{size:14}),` Download`]})]}),g&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>Y(!0),disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>Y(!1),disabled:S,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:S,children:`Cancel`})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:G,disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),E(null)},disabled:S,children:`Cancel`})]}),f&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:J,disabled:S,children:[S?(0,F.jsx)(t,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:S,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(void 0),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(void 0),[d,p]=(0,C.useState)(null),[h,_]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem($)}catch{}if(!t){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]);let v=(0,C.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,C.useState)(!1),x=(0,C.useCallback)(async()=>{b(!0);try{let e=await m();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return r?e?(0,F.jsx)(f,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(g,{cacheKey:e,businessName:a,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:d,role:h,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`calendar`}),[s,c]=(0,C.useState)(`month`),[l,u]=(0,C.useState)(()=>new Date),[d,f]=(0,C.useState)([]),[p,m]=(0,C.useState)(!1),[h,g]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,ee]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=!1;return r(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&ee(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[r]),(0,C.useEffect)(()=>{let e=!1,{from:t,to:n}=j(s,l);return m(!0),g(null),r(`/api/admin/calendar/meetings?from=${encodeURIComponent(t.toISOString())}&to=${encodeURIComponent(n.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();f(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),f([]))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[s,l,i,r]);let S=(0,C.useCallback)(()=>u(new Date),[]),w=(0,C.useCallback)(()=>u(e=>M(s,e,-1)),[s]),T=(0,C.useCallback)(()=>u(e=>M(s,e,1)),[s]),E=(0,C.useCallback)(e=>{u(e),c(`month`)},[]);(0,C.useEffect)(()=>{b(null)},[s,l]);let D=(0,C.useCallback)(e=>{f(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),O=(0,C.useCallback)(e=>{f(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:w,"aria-label":`Previous`,children:(0,F.jsx)(a,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(s,l)}),p&&(0,F.jsx)(t,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===s?` cal-view-btn-active`:``}`,onClick:()=>c(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(o,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[h&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,h]}),s===`day`&&(0,F.jsx)(X,{anchor:l,meetings:d,onSelect:b}),s===`week`&&(0,F.jsx)(q,{anchor:l,meetings:d,onSelect:b}),s===`month`&&(0,F.jsx)(z,{anchor:l,meetings:d,onSelect:b}),s===`year`&&(0,F.jsx)(ne,{anchor:l,meetings:d,onPickMonth:E})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:r,onClose:()=>b(null),onSaved:D,onDeleted:O})]})}(0,S.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
@@ -0,0 +1 @@
1
+ import{C as e,V as t}from"./OperatorConversations-jqaPCHwB.js";import"./admin-types-DJoj6VJv.js";import"./AdminShell-CDQDkT1R.js";import{n}from"./page-jGwq-DpW.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,D as i,E as a,F as o,M as s,O as c,P as ee,R as l,T as te,U as u,V as d,_ as f,d as ne,f as re,p as ie,t as ae,v as p,w as oe}from"./OperatorConversations-BJY9FZbr.js";import{i as se,t as ce}from"./graph-labels-BNZ8u8TE.js";var le=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ue=l(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),de=l(`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`}]]),fe=l(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),pe=l(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),me=l(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),he=l(`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`}]]),m=d(),h=e(u(),1);function ge(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||ce.has(e)&&(t.add(e),n.push(e)));return n}var g=r(),_e=/\.(png|jpe?g|gif|webp|svg)$/i;function ve(e){return _e.test(e)}var ye=`maxy-data-view`;function be(){return typeof window>`u`?`list`:window.localStorage.getItem(ye)===`grid`?`grid`:`list`}function xe(){let[e,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]),r?e?(0,g.jsx)(p,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(`div`,{className:`data-page data-page-full`,children:(0,g.jsx)(Se,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}function Se({cacheKey:e}){let{adminFetch:t,cacheKey:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`data`});return(0,g.jsx)(y,{adminFetch:t,cacheKey:r,sessionRefetchNonce:i})}function Ce(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function we(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function _(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function v(e){return new Promise((t,n)=>e.file(t,n))}async function Te(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await v(r),relpath:e});else if(r.isDirectory){let t=await _(r.createReader());n.push(...await Te(t,e))}}return n}function Ee(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function y({adminFetch:e,cacheKey:n,sessionRefetchNonce:r}){let[l,u]=(0,h.useState)(``),d=(0,h.useRef)(null),[p,ce]=(0,h.useState)(``),[m,_e]=(0,h.useState)(null),[xe,Se]=(0,h.useState)(`hybrid`),[_,v]=(0,h.useState)(!1),[y,b]=(0,h.useState)(null),[ke,Ae]=(0,h.useState)(null),[Ne,Pe]=(0,h.useState)(0),[Fe,Ie]=(0,h.useState)(!1),[x,Le]=(0,h.useState)(()=>Ce()),[S,Re]=(0,h.useState)(null),[C,ze]=(0,h.useState)(()=>be()),[w,Be]=(0,h.useState)(null),[T,Ve]=(0,h.useState)([]),[E,He]=(0,h.useState)(!1),[Ue,We]=(0,h.useState)(null),[Ge,Ke]=(0,h.useState)(!1),[D,O]=(0,h.useState)(null),[qe,k]=(0,h.useState)(null),[Je,Ye]=(0,h.useState)(null),[Xe,Ze]=(0,h.useState)(!1),[Qe,$e]=(0,h.useState)(null),A=(0,h.useRef)(null),[et,j]=(0,h.useState)(0),[tt,M]=(0,h.useState)(!1),[nt,rt]=(0,h.useState)(``),[N,P]=(0,h.useState)(null),[it,at]=(0,h.useState)(``),[ot,F]=(0,h.useState)(null),I=(()=>{let e=x===`.`?[]:x.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})();(0,h.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let st=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),ct=(0,h.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[L,lt]=(0,h.useState)([]),[ut,dt]=(0,h.useState)(`files`);(0,h.useEffect)(()=>{if(!n)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(n)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||lt(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[n]);let ft=(0,h.useMemo)(()=>[...new Set(L.map(e=>e.channel))],[L]),[R,z]=(0,h.useState)(!1),pt=(0,h.useRef)(null),[B,V]=(0,h.useState)(!1),mt=(0,h.useRef)(null);(0,h.useEffect)(()=>{let e=l.trim();if(!e){ce(``),_e(null),b(null);return}Ie(!1);let t=setTimeout(()=>ce(e),300);return()=>clearTimeout(t)},[l]),(0,h.useEffect)(()=>{if(!p){v(!1);return}let t=!1;return v(!0),b(null),e(`/api/admin/graph-search?q=${encodeURIComponent(p)}&labels=FileArtifact&limit=20${Fe?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(_e(e.results),Se(e.mode??`hybrid`),Pe(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||b(e instanceof Error?e.message:String(e))}).finally(()=>{t||v(!1)}),()=>{t=!0}},[p,e,r,Fe]);let ht=(0,h.useMemo)(()=>m?ge(m):[],[m]),H=ke&&ht.includes(ke)?ke:null,U=(0,h.useMemo)(()=>m?H?m.filter(e=>e.labels.includes(H)):m:null,[m,H]),gt=(0,h.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[n]);(0,h.useEffect)(()=>{if(!m)return;let e=m.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[m]),(0,h.useEffect)(()=>{let t=!1;return He(!0),We(null),e(`/api/admin/files?path=${encodeURIComponent(x===`.`?``:x)}`).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||(Re(e.entries),Ve(e.displayPath??[]))}).catch(e=>{t||(Re([]),Ve([]),We(e instanceof Error?e.message:String(e)))}).finally(()=>{t||He(!1)}),()=>{t=!0}},[e,x,et,r]),(0,h.useEffect)(()=>{we(x)},[x]);let _t=(0,h.useCallback)(()=>{j(e=>e+1)},[]),W=(0,h.useCallback)(e=>{z(!1),Le(e)},[]),vt=(0,h.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),u(``),b(null),Ae(null),W(r)},[W]),yt=(0,h.useCallback)(()=>{if(x===`.`||x===``)return;let e=x.split(`/`).filter(Boolean);e.pop(),Le(e.length===0?`.`:e.join(`/`))},[x]),G=(0,h.useCallback)(e=>{re(n,x===`.`?e.name:`${x}/${e.name}`)},[x,n]),[K,bt]=(0,h.useState)(!1),[q,xt]=(0,h.useState)(new Set),St=(0,h.useRef)(null),J=(0,h.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,Ct=(0,h.useCallback)(e=>{bt(!0),xt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,h.useCallback)(e=>{bt(!1),xt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,h.useCallback)(e=>{xt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),wt=(0,h.useCallback)(e=>{J.current=!1,St.current=setTimeout(()=>{J.current=!0,Ct(e)},500)},[Ct]),Q=(0,h.useCallback)(()=>{St.current&&=(clearTimeout(St.current),null)},[]),Tt=(0,h.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(e)},[K,Z,G]),Et=(0,h.useCallback)(e=>{ze(e),typeof window<`u`&&window.localStorage.setItem(ye,e),console.info(`[data] op=view-mode mode=${e}`)},[]),Dt=(0,h.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Be({src:ne(n,x===`.`?e.name:`${x}/${e.name}`),alt:e.displayName??e.name})},[K,Z,x,n]),Ot=(0,h.useCallback)(()=>(S??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[S,q]),kt=(0,h.useCallback)(()=>(S??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[S,q]),At=(0,h.useCallback)(()=>{let e=kt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?G(e[0]):e.length>=1&&ie(n,e.map(e=>x===`.`?e.name:`${x}/${e.name}`)),X(`action`)},[kt,G,x,n,X]),jt=(0,h.useCallback)(async()=>{let t=Ot(),n=t.filter(e=>!e.protected),r=t.length-n.length;$e(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=x===`.`?t.name:`${x}/${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}`)}catch(e){$e(e instanceof Error?e.message:String(e))}}j(e=>e+1),X(`action`)},[Ot,x,e,X]),Mt=(0,h.useCallback)(async()=>{let e=Ot();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=x===`.`?e.name:`${x}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=await(await fetch(r)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[Ot,Y,x,n]),Nt=(0,h.useCallback)(()=>{A.current?.click()},[]),Pt=(0,h.useCallback)((e,t={})=>{let r=new URLSearchParams({session_key:n,path:x===`.`?``:x,filename:e.name});return t.relpath&&r.set(`relpath`,t.relpath),t.token&&r.set(`token`,t.token),new Promise(n=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/admin/files/upload?${r.toString()}`),i.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),t.onProgress&&(i.upload.onprogress=e=>{e.lengthComputable&&t.onProgress(e.loaded,e.total)}),i.onload=()=>{let e={};try{e=JSON.parse(i.responseText)}catch{}n({status:i.status,data:e})},i.onerror=()=>n({status:0,data:{}}),i.onabort=()=>n({status:0,data:{error:`aborted`}}),i.send(e)})},[n,x]),Ft=(0,h.useCallback)(async e=>{k(null),Ke(!0),O({loaded:0,total:e.size});try{let{status:t,data:n}=await Pt(e,{onProgress:(e,t)=>O({loaded:e,total:t})});t>=200&&t<300&&n.path?(Le(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),j(e=>e+1)):k(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ke(!1),O(null),A.current&&(A.current.value=``)}},[Pt]),It=(0,h.useCallback)(e=>{I&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ze(!0))},[I]),Lt=(0,h.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ze(!1)},[]),Rt=(0,h.useCallback)(async e=>{e.preventDefault(),Ze(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!I){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),k(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ke(!0),k(null),Ye(null);let i=performance.now();try{let e=await Te(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),O({loaded:0,total:r.size});let{status:a,data:c}=await Pt(r,{relpath:i,token:t,onProgress:(e,t)=>O({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ee(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ye(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),j(e=>e+1)}catch(e){k(e instanceof Error?e.message:String(e))}finally{Ke(!1),O(null)}},[I,Pt]),zt=(0,h.useCallback)(async()=>{let t=nt.trim();if(t){F(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:x===`.`?``:x,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);M(!1),rt(``),j(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}}},[e,nt,x]),Bt=(0,h.useCallback)(async()=>{if(!N)return;let t=it.trim();if(!t)return;F(null);let n=x===`.`?N:`${x}/${N}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);P(null),at(``),X(`action`),j(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}},[e,it,N,x,X]);(0,h.useEffect)(()=>{if(!R)return;let e=e=>{pt.current&&!pt.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[R]),(0,h.useEffect)(()=>{if(!B)return;let e=e=>{mt.current&&!mt.current.contains(e.target)&&V(!1)},t=e=>{e.key===`Escape`&&V(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[B]);let $=(0,h.useCallback)(e=>T.slice(0,e+1).map(e=>e.name).join(`/`),[T]),Vt=T.length>=2,Ht=Vt?[{name:`.`,label:`data`},...T.slice(0,T.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,g.jsxs)(`main`,{className:`data-main`,children:[(0,g.jsx)(f,{variant:`operator`,onNavigate:ct,conversationsCount:L.length,conversationsChannels:ft,onOpenConversations:()=>dt(`conversations`),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:st,onDisconnect:async()=>!0,disconnecting:!1}),ut===`conversations`?(0,g.jsx)(ae,{conversations:L,sessionKey:n,onBack:()=>dt(`files`)}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,g.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,g.jsx)(oe,{size:14}),` Cancel`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`data-search-input`,children:[l===``&&(0,g.jsx)(se,{size:14}),(0,g.jsx)(`input`,{ref:d,type:`text`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),_&&(0,g.jsx)(t,{size:14,className:`spin`}),l!==``&&(0,g.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{u(``),d.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,g.jsx)(oe,{size:14})})]}),(0,g.jsxs)(`div`,{className:`data-toolbar-actions`,ref:mt,children:[(0,g.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>V(e=>!e),"aria-haspopup":`menu`,"aria-expanded":B,"aria-label":`File actions`,title:`File actions`,children:(0,g.jsx)(ee,{size:16})}),(0,g.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":B?`true`:void 0,children:[(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{_t(),V(!1)},disabled:E,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[E?(0,g.jsx)(t,{size:16,className:`spin`}):(0,g.jsx)(i,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Nt(),V(!1)},disabled:Ge||!I,title:I?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ge?D&&D.total>0?(0,g.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(D.loaded/D.total*100),`%`]}):(0,g.jsx)(t,{size:16,className:`spin`}):(0,g.jsx)(he,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{M(e=>!e),rt(``),F(null),V(!1)},disabled:Ge||!I,title:I?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,g.jsx)(ue,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(C===`grid`?`list`:`grid`),V(!1)},title:C===`grid`?`List view`:`Grid view`,"aria-label":C===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":C===`grid`,children:[C===`grid`?(0,g.jsx)(pe,{size:16}):(0,g.jsx)(fe,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:C===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,g.jsxs)(`div`,{className:`data-breadcrumbs`,children:[x!==`.`&&(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:yt,title:`Up one level`,"aria-label":`Up one level`,children:(0,g.jsx)(le,{size:14})}),Vt?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,ref:pt,children:[(0,g.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>z(e=>!e),"aria-haspopup":`menu`,"aria-expanded":R,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),R&&(0,g.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ht.map(e=>(0,g.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>W(e.name),title:e.label,children:e.label},e.name))})]}),[T.length-2,T.length-1].map(e=>{let t=T[e];return(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,g.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W(`.`),children:`data`}),T.map((e,t)=>(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,g.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),tt&&(0,g.jsxs)(`div`,{className:`data-inline-form`,children:[(0,g.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:nt,autoFocus:!0,onChange:e=>rt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&zt(),e.key===`Escape`&&M(!1)}}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:zt,children:`Create`}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>M(!1),children:`Cancel`})]}),N&&(0,g.jsxs)(`div`,{className:`data-inline-form`,children:[(0,g.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:it,autoFocus:!0,onChange:e=>at(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Bt(),e.key===`Escape`&&P(null)}}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Bt,children:`Rename`}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>P(null),children:`Cancel`})]}),ot&&(0,g.jsx)(`div`,{className:`data-error`,children:ot}),(0,g.jsx)(`input`,{type:`file`,ref:A,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ft(t)}})]}),(0,g.jsxs)(`div`,{className:`data-body`,"data-drag-active":Xe?`true`:void 0,onDragEnter:It,onDragOver:It,onDragLeave:Lt,onDrop:Rt,children:[(y!==null||m!==null)&&(0,g.jsxs)(`section`,{className:`data-panel`,children:[y&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,y]}),ht.length>0&&(0,g.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ht.map(e=>{let t=e===H;return(0,g.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>Ae(t?null:e),children:Oe([e])??e},e)})}),m&&!_&&(0,g.jsxs)(`div`,{className:`data-results-meta`,children:[U.length,` of `,m.length,` result`,m.length===1?``:`s`]}),m&&!_&&!H&&Ne>0&&!Fe&&(0,g.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ie(!0),children:[Ne,` low-confidence result`,Ne===1?``:`s`,` hidden — show all`]}),m&&!_&&!H&&Fe&&(0,g.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ie(!1),children:`Showing all results — hide low-confidence`}),m&&m.length===0&&!_&&(0,g.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),U&&U.length>0&&(0,g.jsx)(`ul`,{className:`data-results`,children:U.map(e=>(0,g.jsx)(De,{hit:e,mode:xe,onDownload:gt,onLocate:vt},e.nodeId))})]}),(0,g.jsxs)(`section`,{className:`data-panel`,children:[D&&(0,g.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":D.total>0?Math.round(D.loaded/D.total*100):void 0,children:[(0,g.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,g.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${D.total>0?Math.round(D.loaded/D.total*100):0}%`}})}),(0,g.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,D.total>0?`${Math.round(D.loaded/D.total*100)}%`:``]})]}),qe&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,qe]}),Je&&(0,g.jsx)(`div`,{className:`data-status`,children:Je}),Qe&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Qe]}),Ue&&(0,g.jsx)(`div`,{className:`data-error`,children:Ue}),E&&(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:14,className:`spin`}),` Loading…`]}),!K&&!E&&S&&S.length>0&&(0,g.jsxs)(`div`,{className:`data-select-hint`,children:[(0,g.jsx)(me,{size:13}),(0,g.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!E&&S&&S.length===0&&!Ue&&(0,g.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!E&&S&&S.length>0&&C===`grid`&&(0,g.jsx)(`ul`,{className:`data-grid`,children:S.map(e=>{let t=e.displayName??e.name,r=K&&q.has(e.name);if(e.kind===`directory`)return(0,g.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(x===`.`?e.name:`${x}/${e.name}`)},children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsx)(de,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=ve(e.name),a=x===`.`?e.name:`${x}/${e.name}`;return(0,g.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?Dt(e):Tt(e),title:K?void 0:i?`Preview ${t}`:`Download ${t}`,children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,g.jsx)(`img`,{className:`data-grid-thumb`,src:ne(n,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,g.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,g.jsx)(`span`,{className:`data-grid-sub`,children:je(e.sizeBytes)})]})},e.name)}return(0,g.jsx)(`li`,{className:`data-grid-cell`,children:(0,g.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,g.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,g.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!E&&S&&S.length>0&&C===`list`&&(0,g.jsx)(`ul`,{className:`data-entries`,children:S.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,g.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(x===`.`?e.name:`${x}/${e.name}`)},children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsx)(de,{size:14}),(0,g.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,g.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>Tt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsxs)(`span`,{className:`data-entry-text`,children:[(0,g.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,g.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Me(e.modifiedAt)}`,children:[je(e.sizeBytes),` · `,Me(e.modifiedAt)]})]})]})},e.name)}return(0,g.jsx)(`li`,{className:`data-entry`,children:(0,g.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,g.jsxs)(`span`,{className:`data-entry-text`,children:[(0,g.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,g.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,g.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,g.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Mt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,g.jsx)(a,{size:16}),` Share`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:At,disabled:q.size===0,children:[(0,g.jsx)(o,{size:16}),` Download`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(P(e),at(e))},disabled:q.size!==1,children:[(0,g.jsx)(c,{size:16}),` Rename`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:jt,disabled:q.size===0,children:[(0,g.jsx)(te,{size:16}),` Delete`]})]})})]}),w&&(0,g.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":w.alt,onClick:()=>Be(null),children:(0,g.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:w.src,alt:w.alt})})]})}function De({hit:e,mode:t,onDownload:n,onLocate:r}){let i=b(e.properties),a=ke(e.properties),o=Oe(e.labels),s=Ae(e.properties),[c,ee]=(0,h.useState)(!1),l=a&&a.length>280,te=c||!l?a:a?.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)}`,d=e.properties.relativePath,f=typeof d==`string`&&d.length>0,ne=f?d.lastIndexOf(`/`):-1,re=f?ne===-1?`data`:d.slice(0,ne):null;return(0,g.jsxs)(`li`,{className:`data-result`,children:[(0,g.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":`Download ${i??o??`file`}`,children:[o&&(0,g.jsx)(`div`,{className:`data-result-header`,children:(0,g.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,g.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,g.jsx)(`pre`,{className:`data-result-body`,children:te}),(0,g.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,g.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Me(s),` · `]}),u]})]}),f&&(0,g.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${re}`,"aria-label":`Locate in ${re}`,children:[(0,g.jsx)(de,{size:12}),re]}),l&&(0,g.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>ee(e=>!e),children:c?`Show less`:`Show more`})]})}function Oe(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 b(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 ke(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 Ae(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function je(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 Me(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`—`}}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(xe,{}));
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,B as n,C as r,D as i,E as a,F as o,M as s,O as c,P as ee,R as l,T as te,U as u,V as d,_ as f,d as ne,f as re,p as ie,t as ae,v as p,w as oe}from"./OperatorConversations-jqaPCHwB.js";import{i as se,t as ce}from"./graph-labels-BNnhRQqM.js";var le=l(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),ue=l(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),de=l(`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`}]]),fe=l(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),pe=l(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),me=l(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),he=l(`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`}]]),m=d(),h=e(u(),1);function ge(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||ce.has(e)&&(t.add(e),n.push(e)));return n}var g=r(),_e=/\.(png|jpe?g|gif|webp|svg)$/i;function ve(e){return _e.test(e)}var ye=`maxy-data-view`;function be(){return typeof window>`u`?`list`:window.localStorage.getItem(ye)===`grid`?`grid`:`list`}function xe(){let[e,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){n(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}n(t),i(!0)}}).catch(()=>{e||(n(t),i(!0))}),()=>{e=!0}},[]),r?e?(0,g.jsx)(p,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(`div`,{className:`data-page data-page-full`,children:(0,g.jsx)(Se,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:18,className:`spin`}),` Loading…`]})})}function Se({cacheKey:e}){let{adminFetch:t,cacheKey:r,sessionRefetchNonce:i}=n({initialCacheKey:e,surface:`data`});return(0,g.jsx)(y,{adminFetch:t,cacheKey:r,sessionRefetchNonce:i})}function Ce(){if(typeof window>`u`)return`.`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`.`}function we(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function _(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function v(e){return new Promise((t,n)=>e.file(t,n))}async function Te(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await v(r),relpath:e});else if(r.isDirectory){let t=await _(r.createReader());n.push(...await Te(t,e))}}return n}function Ee(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function y({adminFetch:e,cacheKey:n,sessionRefetchNonce:r}){let[l,u]=(0,h.useState)(``),d=(0,h.useRef)(null),[p,ce]=(0,h.useState)(``),[m,_e]=(0,h.useState)(null),[xe,Se]=(0,h.useState)(`hybrid`),[_,v]=(0,h.useState)(!1),[y,b]=(0,h.useState)(null),[ke,Ae]=(0,h.useState)(null),[Ne,Pe]=(0,h.useState)(0),[Fe,Ie]=(0,h.useState)(!1),[x,Le]=(0,h.useState)(()=>Ce()),[S,Re]=(0,h.useState)(null),[C,ze]=(0,h.useState)(()=>be()),[w,Be]=(0,h.useState)(null),[T,Ve]=(0,h.useState)([]),[E,He]=(0,h.useState)(!1),[Ue,We]=(0,h.useState)(null),[Ge,Ke]=(0,h.useState)(!1),[D,O]=(0,h.useState)(null),[qe,k]=(0,h.useState)(null),[Je,Ye]=(0,h.useState)(null),[Xe,Ze]=(0,h.useState)(!1),[Qe,$e]=(0,h.useState)(null),A=(0,h.useRef)(null),[et,j]=(0,h.useState)(0),[tt,M]=(0,h.useState)(!1),[nt,rt]=(0,h.useState)(``),[N,P]=(0,h.useState)(null),[it,at]=(0,h.useState)(``),[ot,F]=(0,h.useState)(null),I=(()=>{let e=x===`.`?[]:x.split(`/`).filter(Boolean);return e.length>=2&&e[0]===`accounts`})();(0,h.useEffect)(()=>{console.info(`[data-ui] op=mount header=operator home=absent`)},[]);let st=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),ct=(0,h.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[L,lt]=(0,h.useState)([]),[ut,dt]=(0,h.useState)(`files`);(0,h.useEffect)(()=>{if(!n)return;let e=!1;return fetch(`/api/whatsapp-reader/conversations?session_key=${encodeURIComponent(n)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||lt(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[n]);let ft=(0,h.useMemo)(()=>[...new Set(L.map(e=>e.channel))],[L]),[R,z]=(0,h.useState)(!1),pt=(0,h.useRef)(null),[B,V]=(0,h.useState)(!1),mt=(0,h.useRef)(null);(0,h.useEffect)(()=>{let e=l.trim();if(!e){ce(``),_e(null),b(null);return}Ie(!1);let t=setTimeout(()=>ce(e),300);return()=>clearTimeout(t)},[l]),(0,h.useEffect)(()=>{if(!p){v(!1);return}let t=!1;return v(!0),b(null),e(`/api/admin/graph-search?q=${encodeURIComponent(p)}&labels=FileArtifact&limit=20${Fe?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(_e(e.results),Se(e.mode??`hybrid`),Pe(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||b(e instanceof Error?e.message:String(e))}).finally(()=>{t||v(!1)}),()=>{t=!0}},[p,e,r,Fe]);let ht=(0,h.useMemo)(()=>m?ge(m):[],[m]),H=ke&&ht.includes(ke)?ke:null,U=(0,h.useMemo)(()=>m?H?m.filter(e=>e.labels.includes(H)):m:null,[m,H]),gt=(0,h.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[n]);(0,h.useEffect)(()=>{if(!m)return;let e=m.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[m]),(0,h.useEffect)(()=>{let t=!1;return He(!0),We(null),e(`/api/admin/files?path=${encodeURIComponent(x===`.`?``:x)}`).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||(Re(e.entries),Ve(e.displayPath??[]))}).catch(e=>{t||(Re([]),Ve([]),We(e instanceof Error?e.message:String(e)))}).finally(()=>{t||He(!1)}),()=>{t=!0}},[e,x,et,r]),(0,h.useEffect)(()=>{we(x)},[x]);let _t=(0,h.useCallback)(()=>{j(e=>e+1)},[]),W=(0,h.useCallback)(e=>{z(!1),Le(e)},[]),vt=(0,h.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);console.log(`[data-search] op=locate nodeId=${e.nodeId} folder=${r}`),u(``),b(null),Ae(null),W(r)},[W]),yt=(0,h.useCallback)(()=>{if(x===`.`||x===``)return;let e=x.split(`/`).filter(Boolean);e.pop(),Le(e.length===0?`.`:e.join(`/`))},[x]),G=(0,h.useCallback)(e=>{re(n,x===`.`?e.name:`${x}/${e.name}`)},[x,n]),[K,bt]=(0,h.useState)(!1),[q,xt]=(0,h.useState)(new Set),St=(0,h.useRef)(null),J=(0,h.useRef)(!1),Y=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,Ct=(0,h.useCallback)(e=>{bt(!0),xt(new Set([e])),console.info(`[data-ui] op=select-enter count=1`)},[]),X=(0,h.useCallback)(e=>{bt(!1),xt(new Set),console.info(`[data-ui] op=select-exit reason=${e}`)},[]),Z=(0,h.useCallback)(e=>{xt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),wt=(0,h.useCallback)(e=>{J.current=!1,St.current=setTimeout(()=>{J.current=!0,Ct(e)},500)},[Ct]),Q=(0,h.useCallback)(()=>{St.current&&=(clearTimeout(St.current),null)},[]),Tt=(0,h.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}G(e)},[K,Z,G]),Et=(0,h.useCallback)(e=>{ze(e),typeof window<`u`&&window.localStorage.setItem(ye,e),console.info(`[data] op=view-mode mode=${e}`)},[]),Dt=(0,h.useCallback)(e=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}Be({src:ne(n,x===`.`?e.name:`${x}/${e.name}`),alt:e.displayName??e.name})},[K,Z,x,n]),Ot=(0,h.useCallback)(()=>(S??[]).filter(e=>e.kind===`file`&&q.has(e.name)),[S,q]),kt=(0,h.useCallback)(()=>(S??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&q.has(e.name)),[S,q]),At=(0,h.useCallback)(()=>{let e=kt(),t=e.some(e=>e.kind===`directory`);e.length===1&&!t?G(e[0]):e.length>=1&&ie(n,e.map(e=>x===`.`?e.name:`${x}/${e.name}`)),X(`action`)},[kt,G,x,n,X]),jt=(0,h.useCallback)(async()=>{let t=Ot(),n=t.filter(e=>!e.protected),r=t.length-n.length;$e(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=x===`.`?t.name:`${x}/${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}`)}catch(e){$e(e instanceof Error?e.message:String(e))}}j(e=>e+1),X(`action`)},[Ot,x,e,X]),Mt=(0,h.useCallback)(async()=>{let e=Ot();if(console.info(`[data-ui] op=share supported=${Y} count=${e.length}`),Y)try{let t=await Promise.all(e.map(async e=>{let t=x===`.`?e.name:`${x}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`,i=await(await fetch(r)).blob();return new File([i],e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:t})&&await navigator.share({files:t})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[Ot,Y,x,n]),Nt=(0,h.useCallback)(()=>{A.current?.click()},[]),Pt=(0,h.useCallback)((e,t={})=>{let r=new URLSearchParams({session_key:n,path:x===`.`?``:x,filename:e.name});return t.relpath&&r.set(`relpath`,t.relpath),t.token&&r.set(`token`,t.token),new Promise(n=>{let i=new XMLHttpRequest;i.open(`POST`,`/api/admin/files/upload?${r.toString()}`),i.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),t.onProgress&&(i.upload.onprogress=e=>{e.lengthComputable&&t.onProgress(e.loaded,e.total)}),i.onload=()=>{let e={};try{e=JSON.parse(i.responseText)}catch{}n({status:i.status,data:e})},i.onerror=()=>n({status:0,data:{}}),i.onabort=()=>n({status:0,data:{error:`aborted`}}),i.send(e)})},[n,x]),Ft=(0,h.useCallback)(async e=>{k(null),Ke(!0),O({loaded:0,total:e.size});try{let{status:t,data:n}=await Pt(e,{onProgress:(e,t)=>O({loaded:e,total:t})});t>=200&&t<300&&n.path?(Le(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),j(e=>e+1)):k(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{Ke(!1),O(null),A.current&&(A.current.value=``)}},[Pt]),It=(0,h.useCallback)(e=>{I&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ze(!0))},[I]),Lt=(0,h.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ze(!1)},[]),Rt=(0,h.useCallback)(async e=>{e.preventDefault(),Ze(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(console.info(`[data-ui] op=drop-received token=${t} items=${n.length}`),n.length===0)return;if(!I){console.info(`[data-ui] op=drop-rejected token=${t} reason=no-write`),k(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);Ke(!0),k(null),Ye(null);let i=performance.now();try{let e=await Te(r),n=e.reduce((e,t)=>e+t.file.size,0),a=new Set(e.map(e=>e.relpath.split(`/`).slice(0,-1).join(`/`)).filter(Boolean)).size;console.info(`[data-ui] op=drop-walk token=${t} files=${e.length} dirs=${a} bytes=${n}`);let o=0,s=[];for(let n=0;n<e.length;n++){let{file:r,relpath:i}=e[n];console.info(`[data-ui] op=drop-file token=${t} rel="${i}" i=${n+1}/${e.length}`),O({loaded:0,total:r.size});let{status:a,data:c}=await Pt(r,{relpath:i,token:t,onProgress:(e,t)=>O({loaded:e,total:t})});if(a>=200&&a<300)o++,console.info(`[data-ui] op=drop-file-ok token=${t} rel="${i}"`);else{let e=a===0?`http=0`:Ee(a,c.error);s.push(`${i} (${e})`),console.info(`[data-ui] op=drop-file-skip token=${t} rel="${i}" reason=${e}`)}}let c=Math.round(performance.now()-i);console.info(`[data-ui] op=drop-done token=${t} uploaded=${o} skipped=${s.length} ms=${c}`),Ye(`Uploaded ${o}, skipped ${s.length}${s.length?`: ${s.join(`, `)}`:``}`),j(e=>e+1)}catch(e){k(e instanceof Error?e.message:String(e))}finally{Ke(!1),O(null)}},[I,Pt]),zt=(0,h.useCallback)(async()=>{let t=nt.trim();if(t){F(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:x===`.`?``:x,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);M(!1),rt(``),j(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}}},[e,nt,x]),Bt=(0,h.useCallback)(async()=>{if(!N)return;let t=it.trim();if(!t)return;F(null);let n=x===`.`?N:`${x}/${N}`;try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);P(null),at(``),X(`action`),j(e=>e+1)}catch(e){F(e instanceof Error?e.message:String(e))}},[e,it,N,x,X]);(0,h.useEffect)(()=>{if(!R)return;let e=e=>{pt.current&&!pt.current.contains(e.target)&&z(!1)},t=e=>{e.key===`Escape`&&z(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[R]),(0,h.useEffect)(()=>{if(!B)return;let e=e=>{mt.current&&!mt.current.contains(e.target)&&V(!1)},t=e=>{e.key===`Escape`&&V(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[B]);let $=(0,h.useCallback)(e=>T.slice(0,e+1).map(e=>e.name).join(`/`),[T]),Vt=T.length>=2,Ht=Vt?[{name:`.`,label:`data`},...T.slice(0,T.length-2).map((e,t)=>({name:$(t),label:e.displayName??e.name}))]:[];return(0,g.jsxs)(`main`,{className:`data-main`,children:[(0,g.jsx)(f,{variant:`operator`,onNavigate:ct,conversationsCount:L.length,conversationsChannels:ft,onOpenConversations:()=>dt(`conversations`),onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:st,onDisconnect:async()=>!0,disconnecting:!1}),ut===`conversations`?(0,g.jsx)(ae,{conversations:L,sessionKey:n,onBack:()=>dt(`files`)}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`data-toolbar`,children:[K?(0,g.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>X(`cancel`),"aria-label":`Cancel selection`,children:[(0,g.jsx)(oe,{size:14}),` Cancel`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`data-search-input`,children:[l===``&&(0,g.jsx)(se,{size:14}),(0,g.jsx)(`input`,{ref:d,type:`text`,value:l,onChange:e=>u(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),_&&(0,g.jsx)(t,{size:14,className:`spin`}),l!==``&&(0,g.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{u(``),d.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,g.jsx)(oe,{size:14})})]}),(0,g.jsxs)(`div`,{className:`data-toolbar-actions`,ref:mt,children:[(0,g.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>V(e=>!e),"aria-haspopup":`menu`,"aria-expanded":B,"aria-label":`File actions`,title:`File actions`,children:(0,g.jsx)(ee,{size:16})}),(0,g.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":B?`true`:void 0,children:[(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{_t(),V(!1)},disabled:E,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[E?(0,g.jsx)(t,{size:16,className:`spin`}):(0,g.jsx)(i,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Nt(),V(!1)},disabled:Ge||!I,title:I?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[Ge?D&&D.total>0?(0,g.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(D.loaded/D.total*100),`%`]}):(0,g.jsx)(t,{size:16,className:`spin`}):(0,g.jsx)(he,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{M(e=>!e),rt(``),F(null),V(!1)},disabled:Ge||!I,title:I?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,g.jsx)(ue,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Et(C===`grid`?`list`:`grid`),V(!1)},title:C===`grid`?`List view`:`Grid view`,"aria-label":C===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":C===`grid`,children:[C===`grid`?(0,g.jsx)(pe,{size:16}):(0,g.jsx)(fe,{size:16}),(0,g.jsx)(`span`,{className:`data-action-label`,children:C===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,g.jsxs)(`div`,{className:`data-breadcrumbs`,children:[x!==`.`&&(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:yt,title:`Up one level`,"aria-label":`Up one level`,children:(0,g.jsx)(le,{size:14})}),Vt?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,ref:pt,children:[(0,g.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>z(e=>!e),"aria-haspopup":`menu`,"aria-expanded":R,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),R&&(0,g.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Ht.map(e=>(0,g.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>W(e.name),title:e.label,children:e.label},e.name))})]}),[T.length-2,T.length-1].map(e=>{let t=T[e];return(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,g.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(e)),title:t.name,children:t.displayName??t.name})]},$(e))})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W(`.`),children:`data`}),T.map((e,t)=>(0,g.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,g.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,g.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>W($(t)),title:e.name,children:e.displayName??e.name})]},$(t)))]})]}),tt&&(0,g.jsxs)(`div`,{className:`data-inline-form`,children:[(0,g.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:nt,autoFocus:!0,onChange:e=>rt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&zt(),e.key===`Escape`&&M(!1)}}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:zt,children:`Create`}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>M(!1),children:`Cancel`})]}),N&&(0,g.jsxs)(`div`,{className:`data-inline-form`,children:[(0,g.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:it,autoFocus:!0,onChange:e=>at(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Bt(),e.key===`Escape`&&P(null)}}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Bt,children:`Rename`}),(0,g.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>P(null),children:`Cancel`})]}),ot&&(0,g.jsx)(`div`,{className:`data-error`,children:ot}),(0,g.jsx)(`input`,{type:`file`,ref:A,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Ft(t)}})]}),(0,g.jsxs)(`div`,{className:`data-body`,"data-drag-active":Xe?`true`:void 0,onDragEnter:It,onDragOver:It,onDragLeave:Lt,onDrop:Rt,children:[(y!==null||m!==null)&&(0,g.jsxs)(`section`,{className:`data-panel`,children:[y&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,y]}),ht.length>0&&(0,g.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:ht.map(e=>{let t=e===H;return(0,g.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>Ae(t?null:e),children:Oe([e])??e},e)})}),m&&!_&&(0,g.jsxs)(`div`,{className:`data-results-meta`,children:[U.length,` of `,m.length,` result`,m.length===1?``:`s`]}),m&&!_&&!H&&Ne>0&&!Fe&&(0,g.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ie(!0),children:[Ne,` low-confidence result`,Ne===1?``:`s`,` hidden — show all`]}),m&&!_&&!H&&Fe&&(0,g.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>Ie(!1),children:`Showing all results — hide low-confidence`}),m&&m.length===0&&!_&&(0,g.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),U&&U.length>0&&(0,g.jsx)(`ul`,{className:`data-results`,children:U.map(e=>(0,g.jsx)(De,{hit:e,mode:xe,onDownload:gt,onLocate:vt},e.nodeId))})]}),(0,g.jsxs)(`section`,{className:`data-panel`,children:[D&&(0,g.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":D.total>0?Math.round(D.loaded/D.total*100):void 0,children:[(0,g.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,g.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${D.total>0?Math.round(D.loaded/D.total*100):0}%`}})}),(0,g.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,D.total>0?`${Math.round(D.loaded/D.total*100)}%`:``]})]}),qe&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,qe]}),Je&&(0,g.jsx)(`div`,{className:`data-status`,children:Je}),Qe&&(0,g.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Qe]}),Ue&&(0,g.jsx)(`div`,{className:`data-error`,children:Ue}),E&&(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(t,{size:14,className:`spin`}),` Loading…`]}),!K&&!E&&S&&S.length>0&&(0,g.jsxs)(`div`,{className:`data-select-hint`,children:[(0,g.jsx)(me,{size:13}),(0,g.jsx)(`span`,{children:`Press and hold a file to select, rename, or delete it.`})]}),!E&&S&&S.length===0&&!Ue&&(0,g.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!E&&S&&S.length>0&&C===`grid`&&(0,g.jsx)(`ul`,{className:`data-grid`,children:S.map(e=>{let t=e.displayName??e.name,r=K&&q.has(e.name);if(e.kind===`directory`)return(0,g.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(x===`.`?e.name:`${x}/${e.name}`)},children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsx)(de,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t})]})},e.name);if(e.kind===`file`){let i=ve(e.name),a=x===`.`?e.name:`${x}/${e.name}`;return(0,g.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>i?Dt(e):Tt(e),title:K?void 0:i?`Preview ${t}`:`Download ${t}`,children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,g.jsx)(`img`,{className:`data-grid-thumb`,src:ne(n,a),alt:t,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,g.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:t}),!i&&(0,g.jsx)(`span`,{className:`data-grid-sub`,children:je(e.sizeBytes)})]})},e.name)}return(0,g.jsx)(`li`,{className:`data-grid-cell`,children:(0,g.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,g.jsx)(s,{size:28,className:`data-grid-glyph`}),(0,g.jsx)(`span`,{className:`data-grid-label`,children:t}),(0,g.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!E&&S&&S.length>0&&C===`list`&&(0,g.jsx)(`ul`,{className:`data-entries`,children:S.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=K&&q.has(e.name);return(0,g.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>{if(J.current){J.current=!1;return}if(K){Z(e.name);return}W(x===`.`?e.name:`${x}/${e.name}`)},children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsx)(de,{size:14}),(0,g.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=K&&q.has(e.name);return(0,g.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,g.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>wt(e.name),onPointerUp:Q,onPointerMove:Q,onPointerLeave:Q,onPointerCancel:Q,onClick:()=>Tt(e),title:K?void 0:`Download ${t}`,children:[K&&(0,g.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,g.jsxs)(`span`,{className:`data-entry-text`,children:[(0,g.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,g.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Me(e.modifiedAt)}`,children:[je(e.sizeBytes),` · `,Me(e.modifiedAt)]})]})]})},e.name)}return(0,g.jsx)(`li`,{className:`data-entry`,children:(0,g.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,g.jsxs)(`span`,{className:`data-entry-text`,children:[(0,g.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,g.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]}),K&&(0,g.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,g.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Mt,disabled:!Y||q.size===0,title:Y?`Share selected files`:`Sharing is not supported on this device`,children:[(0,g.jsx)(a,{size:16}),` Share`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:At,disabled:q.size===0,children:[(0,g.jsx)(o,{size:16}),` Download`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=[...q][0];e&&(P(e),at(e))},disabled:q.size!==1,children:[(0,g.jsx)(c,{size:16}),` Rename`]}),(0,g.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:jt,disabled:q.size===0,children:[(0,g.jsx)(te,{size:16}),` Delete`]})]})})]}),w&&(0,g.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":w.alt,onClick:()=>Be(null),children:(0,g.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:w.src,alt:w.alt})})]})}function De({hit:e,mode:t,onDownload:n,onLocate:r}){let i=b(e.properties),a=ke(e.properties),o=Oe(e.labels),s=Ae(e.properties),[c,ee]=(0,h.useState)(!1),l=a&&a.length>280,te=c||!l?a:a?.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)}`,d=e.properties.relativePath,f=typeof d==`string`&&d.length>0,ne=f?d.lastIndexOf(`/`):-1,re=f?ne===-1?`data`:d.slice(0,ne):null;return(0,g.jsxs)(`li`,{className:`data-result`,children:[(0,g.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":`Download ${i??o??`file`}`,children:[o&&(0,g.jsx)(`div`,{className:`data-result-header`,children:(0,g.jsx)(`span`,{className:`data-result-labels`,children:o})}),i&&(0,g.jsx)(`div`,{className:`data-result-title`,children:i}),a&&(0,g.jsx)(`pre`,{className:`data-result-body`,children:te}),(0,g.jsxs)(`div`,{className:`data-result-scores`,children:[s&&(0,g.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Me(s),` · `]}),u]})]}),f&&(0,g.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${re}`,"aria-label":`Locate in ${re}`,children:[(0,g.jsx)(de,{size:12}),re]}),l&&(0,g.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>ee(e=>!e),children:c?`Show less`:`Show more`})]})}function Oe(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 b(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 ke(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 Ae(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function je(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 Me(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`—`}}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(xe,{}));
@@ -1 +1 @@
1
- import{t as e}from"./chunk-CAM3fms7.js";import{R as t}from"./OperatorConversations-BJY9FZbr.js";var n=t(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),r=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ALL_GRAPH_LABELS=e.FALLBACK_LABEL_COLOUR=e.GRAPH_LABEL_COLOURS=void 0,e.pickDisplayLabel=t,e.colourForLabel=n,e.resolveNodeColour=r,e.formatRunTimestamp=o,e.formatMessageTimestamp=s,e.pickShortLabel=c,e.pickDisplayName=l,e.GRAPH_LABEL_COLOURS={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Listing:`#3F5670`,Property:`#5C7A99`,Viewing:`#D4A574`,Offer:`#B08850`,Job:`#8C3B2E`,Quote:`#A65A4A`,Invoice:`#6E4A1F`,InboundInvoice:`#6B2A20`,WhatsAppGroup:`#D4A096`,Customer:`#B5503C`,Site:`#C56B4A`,Asset:`#9E4A35`,Visit:`#C77A4E`,Part:`#7A3326`,PurchaseOrder:`#B07050`,PpmContract:`#8A4A3A`,Organization:`#8A6B47`,Person:`#B86E4A`,UserProfile:`#D08960`,Preference:`#DFA67A`,AdminUser:`#8C5230`,AccessGrant:`#66381F`,KnowledgeDocument:`#6E8A5A`,ConversationArchive:`#4F6B3E`,Section:`#8AA876`,Chunk:`#A6C194`,DigitalDocument:`#5A7548`,CreativeWork:`#B5C9A2`,Question:`#C7D6B5`,FAQPage:`#95B385`,DefinedTerm:`#76906A`,Review:`#3F5A2E`,ImageObject:`#A0BB8C`,Conversation:`#6B5A85`,AdminConversation:`#4F4070`,PublicConversation:`#8A75A8`,Message:`#6B7280`,UserMessage:`#DFA67A`,AssistantMessage:`#C9A876`,ToolCall:`#B5ABCB`,Task:`#B0617A`,Project:`#8E4A60`,Event:`#C68095`,Workflow:`#3A6F77`,WorkflowStep:`#5A8E96`,WorkflowRun:`#7AAAB2`,StepResult:`#9CC4CB`,Email:`#6F7F4A`,EmailAccount:`#91A063`,Agent:`#B8893D`,Objective:`#3D5A98`,KeyResult:`#5E7BC4`,Decision:`#7E60B0`,Risk:`#C15B57`,Source:`#2F8FA6`,Finding:`#4FA389`,Hypothesis:`#9A8C3E`},e.FALLBACK_LABEL_COLOUR=`#94A3B8`,e.ALL_GRAPH_LABELS=Object.freeze(Object.keys(e.GRAPH_LABEL_COLOURS));function t(t){for(let n=1;n<t.length;n++)if(Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,t[n]))return t[n];return t[0]??null}function n(t){return e.GRAPH_LABEL_COLOURS[t]??e.FALLBACK_LABEL_COLOUR}function r(r){let i=t(r),a=i?n(i):e.FALLBACK_LABEL_COLOUR,o=0;for(let t=1;t<r.length;t++)Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,r[t])&&o++;return{displayLabel:i,colour:a,driftCandidates:o}}var i=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/,a=/^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/;function o(e){let t=e.match(i);return t?`${t[1]} ${t[2]}`:null}function s(e){let t=e.match(a);return t?t[1]:null}function c(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=o(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Message`){let e=typeof t.role==`string`?t.role:``,n=e===`user`?`user`:e===`assistant`?`asst`:e===`system`?`sys`:e===`tool`?`tool`:null,r=typeof t.createdAt==`string`?t.createdAt:``;if(n&&r){let e=s(r);if(e)return`${n} ${e}`}}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.length>24?n.slice(0,24)+`…`:n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function l(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=o(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}})),i=r();Object.freeze(new Set([`Chunk`,`GraphPreference`]));var a=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.Listing.Property.Viewing.Offer.Job.Quote.Invoice.InboundInvoice.WhatsAppGroup.Customer.Site.Asset.Visit.Part.PurchaseOrder.PpmContract.AdminConversation.PublicConversation.Task.Project.Event.Workflow.Email.EmailAccount.Agent.Objective.KeyResult.Decision.Risk.Source.Finding.Hypothesis`.split(`.`)));Object.freeze(new Set([`ToolCall`,`StepResult`,`WorkflowStep`,`WorkflowRun`])),Object.freeze(new Set([`HAS_TOOL_CALL`,`RUN_OF`,`HAS_STEP`,`HAS_RESULT`]));export{n as i,i as n,r,a as t};
1
+ import{t as e}from"./chunk-CAM3fms7.js";import{R as t}from"./OperatorConversations-jqaPCHwB.js";var n=t(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),r=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ALL_GRAPH_LABELS=e.FALLBACK_LABEL_COLOUR=e.GRAPH_LABEL_COLOURS=void 0,e.pickDisplayLabel=t,e.colourForLabel=n,e.resolveNodeColour=r,e.formatRunTimestamp=o,e.formatMessageTimestamp=s,e.pickShortLabel=c,e.pickDisplayName=l,e.GRAPH_LABEL_COLOURS={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Listing:`#3F5670`,Property:`#5C7A99`,Viewing:`#D4A574`,Offer:`#B08850`,Job:`#8C3B2E`,Quote:`#A65A4A`,Invoice:`#6E4A1F`,InboundInvoice:`#6B2A20`,WhatsAppGroup:`#D4A096`,Customer:`#B5503C`,Site:`#C56B4A`,Asset:`#9E4A35`,Visit:`#C77A4E`,Part:`#7A3326`,PurchaseOrder:`#B07050`,PpmContract:`#8A4A3A`,Organization:`#8A6B47`,Person:`#B86E4A`,UserProfile:`#D08960`,Preference:`#DFA67A`,AdminUser:`#8C5230`,AccessGrant:`#66381F`,KnowledgeDocument:`#6E8A5A`,ConversationArchive:`#4F6B3E`,Section:`#8AA876`,Chunk:`#A6C194`,DigitalDocument:`#5A7548`,CreativeWork:`#B5C9A2`,Question:`#C7D6B5`,FAQPage:`#95B385`,DefinedTerm:`#76906A`,Review:`#3F5A2E`,ImageObject:`#A0BB8C`,Conversation:`#6B5A85`,AdminConversation:`#4F4070`,PublicConversation:`#8A75A8`,Message:`#6B7280`,UserMessage:`#DFA67A`,AssistantMessage:`#C9A876`,ToolCall:`#B5ABCB`,Task:`#B0617A`,Project:`#8E4A60`,Event:`#C68095`,Workflow:`#3A6F77`,WorkflowStep:`#5A8E96`,WorkflowRun:`#7AAAB2`,StepResult:`#9CC4CB`,Email:`#6F7F4A`,EmailAccount:`#91A063`,Agent:`#B8893D`,Objective:`#3D5A98`,KeyResult:`#5E7BC4`,Decision:`#7E60B0`,Risk:`#C15B57`,Source:`#2F8FA6`,Finding:`#4FA389`,Hypothesis:`#9A8C3E`},e.FALLBACK_LABEL_COLOUR=`#94A3B8`,e.ALL_GRAPH_LABELS=Object.freeze(Object.keys(e.GRAPH_LABEL_COLOURS));function t(t){for(let n=1;n<t.length;n++)if(Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,t[n]))return t[n];return t[0]??null}function n(t){return e.GRAPH_LABEL_COLOURS[t]??e.FALLBACK_LABEL_COLOUR}function r(r){let i=t(r),a=i?n(i):e.FALLBACK_LABEL_COLOUR,o=0;for(let t=1;t<r.length;t++)Object.prototype.hasOwnProperty.call(e.GRAPH_LABEL_COLOURS,r[t])&&o++;return{displayLabel:i,colour:a,driftCandidates:o}}var i=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/,a=/^\d{4}-\d{2}-\d{2}T(\d{2}:\d{2}:\d{2})/;function o(e){let t=e.match(i);return t?`${t[1]} ${t[2]}`:null}function s(e){let t=e.match(a);return t?t[1]:null}function c(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=o(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r.length>24?r.slice(0,24)+`…`:r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e.length>24?e.slice(0,24)+`…`:e}else if(n===`Message`){let e=typeof t.role==`string`?t.role:``,n=e===`user`?`user`:e===`assistant`?`asst`:e===`system`?`sys`:e===`tool`?`tool`:null,r=typeof t.createdAt==`string`?t.createdAt:``;if(n&&r){let e=s(r);if(e)return`${n} ${e}`}}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n.length>24?n.slice(0,24)+`…`:n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}function l(e){let t=e.properties,n=e.labels[0];if(n===`ToolCall`){let e=t.toolName;if(typeof e==`string`&&e.length>0)return e}else if(n===`WorkflowRun`){let e=t.startedAt;if(typeof e==`string`&&e.length>0){let t=o(e);if(t)return t}}else if(n===`WorkflowStep`){let e=t.label;if(typeof e==`string`&&e.length>0)return e}else if(n===`Person`){let e=[typeof t.givenName==`string`?t.givenName:``,typeof t.familyName==`string`?t.familyName:``].filter(e=>e.length>0).join(` `);if(e.length>0)return e}else if(n===`Agent`){let e=typeof t.displayName==`string`?t.displayName:``,n=typeof t.slug==`string`?t.slug:``,r=e.length>0?e:n;if(r.length>0)return r}else if(n===`Job`){let e=typeof t.client==`string`?t.client:``,n=typeof t.jobId==`string`?t.jobId:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`Quote`){let e=typeof t.ref==`string`?t.ref:``;if(e.length>0)return e}else if(n===`InboundInvoice`){let e=typeof t.supplier==`string`?t.supplier:``,n=typeof t.confirmationNumber==`string`?t.confirmationNumber:``,r=[e,n.length>0?`#${n}`:``].filter(e=>e.length>0).join(` `);if(r.length>0)return r}else if(n===`WhatsAppGroup`){let e=typeof t.clientName==`string`?t.clientName:``;if(e.length>0)return e}for(let e of[`name`,`title`,`summary`,`givenName`,`subject`,`text`]){let n=t[e];if(typeof n==`string`&&n.length>0)return n}if(n===`Conversation`){let e=typeof t.sessionId==`string`?t.sessionId:null;if(e)return`Conv ${e.slice(0,8)}`}return n??`…`}})),i=r();Object.freeze(new Set([`Chunk`,`GraphPreference`]));var a=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.Listing.Property.Viewing.Offer.Job.Quote.Invoice.InboundInvoice.WhatsAppGroup.Customer.Site.Asset.Visit.Part.PurchaseOrder.PpmContract.AdminConversation.PublicConversation.Task.Project.Event.Workflow.Email.EmailAccount.Agent.Objective.KeyResult.Decision.Risk.Source.Finding.Hypothesis`.split(`.`)));Object.freeze(new Set([`ToolCall`,`StepResult`,`WorkflowStep`,`WorkflowRun`])),Object.freeze(new Set([`HAS_TOOL_CALL`,`RUN_OF`,`HAS_STEP`,`HAS_RESULT`]));export{n as i,i as n,r,a as t};