@rubytech/create-sitedesk-code 0.1.404 → 0.1.406

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 (72) hide show
  1. package/dist/__tests__/launchd-plist.test.js +13 -1
  2. package/dist/__tests__/neo4j-darwin-dedicated.test.js +52 -0
  3. package/dist/__tests__/neo4j-datadir.test.js +8 -7
  4. package/dist/__tests__/neo4j-teardown.test.js +17 -1
  5. package/dist/index.js +183 -9
  6. package/dist/launchd-plist.js +21 -0
  7. package/dist/neo4j-darwin-dedicated.js +39 -0
  8. package/dist/neo4j-datadir.js +9 -5
  9. package/dist/neo4j-teardown.js +15 -0
  10. package/dist/uninstall.js +34 -8
  11. package/package.json +1 -1
  12. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +2 -2
  13. package/payload/platform/plugins/scheduling/PLUGIN.md +2 -0
  14. package/payload/platform/plugins/scheduling/mcp/dist/__tests__/agent-dispatch-manager-grounding.test.d.ts +2 -0
  15. package/payload/platform/plugins/scheduling/mcp/dist/__tests__/agent-dispatch-manager-grounding.test.d.ts.map +1 -0
  16. package/payload/platform/plugins/scheduling/mcp/dist/__tests__/agent-dispatch-manager-grounding.test.js +19 -0
  17. package/payload/platform/plugins/scheduling/mcp/dist/__tests__/agent-dispatch-manager-grounding.test.js.map +1 -0
  18. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/deliverability-grounding.test.d.ts +2 -0
  19. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/deliverability-grounding.test.d.ts.map +1 -0
  20. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/deliverability-grounding.test.js +33 -0
  21. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/deliverability-grounding.test.js.map +1 -0
  22. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +2 -0
  23. package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +5 -1
  24. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.d.ts +8 -7
  25. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.d.ts.map +1 -1
  26. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js +63 -40
  27. package/payload/platform/services/claude-session-manager/dist/claude-host-creds.js.map +1 -1
  28. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.d.ts +40 -0
  29. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.d.ts.map +1 -0
  30. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.js +159 -0
  31. package/payload/platform/services/claude-session-manager/dist/claude-keychain-write.js.map +1 -0
  32. package/payload/platform/services/claude-session-manager/dist/connector-availability.d.ts +36 -0
  33. package/payload/platform/services/claude-session-manager/dist/connector-availability.d.ts.map +1 -0
  34. package/payload/platform/services/claude-session-manager/dist/connector-availability.js +76 -0
  35. package/payload/platform/services/claude-session-manager/dist/connector-availability.js.map +1 -0
  36. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts +2 -1
  37. package/payload/platform/services/claude-session-manager/dist/rc-daemon.d.ts.map +1 -1
  38. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js +2 -2
  39. package/payload/platform/services/claude-session-manager/dist/rc-daemon.js.map +1 -1
  40. package/payload/server/public/assets/{AdminLoginScreens-BzErD9Zo.js → AdminLoginScreens-D36zz_SY.js} +1 -1
  41. package/payload/server/public/assets/{AdminShell-BihejKg_.js → AdminShell-DH6Lcj-d.js} +1 -1
  42. package/payload/server/public/assets/{Checkbox-Ds004CBE.js → Checkbox-54KtArF3.js} +1 -1
  43. package/payload/server/public/assets/{Transcript-CgaMQKgY.js → Transcript-BCpiXt4J.js} +1 -1
  44. package/payload/server/public/assets/{admin-BSuRtMws.js → admin-C0FCHcJj.js} +1 -1
  45. package/payload/server/public/assets/{browser-BO2eR_YY.js → browser-bKeZ5iLx.js} +1 -1
  46. package/payload/server/public/assets/{calendar-12QuR_oh.js → calendar-BDPBArFA.js} +1 -1
  47. package/payload/server/public/assets/chat-Cp_1ebzU.js +1 -0
  48. package/payload/server/public/assets/chevron-left-S7Nk-se6.js +1 -0
  49. package/payload/server/public/assets/data-BshlTgIW.js +1 -0
  50. package/payload/server/public/assets/{graph-CDOJZepc.js → graph-Dvru9CW9.js} +1 -1
  51. package/payload/server/public/assets/{graph-labels-6HKBjyXX.js → graph-labels-DLhR6Rit.js} +1 -1
  52. package/payload/server/public/assets/{maximize-2-DWmyXX8h.js → maximize-2-CyPKq7HZ.js} +1 -1
  53. package/payload/server/public/assets/{operator-D-s7jVnf.js → operator-Ql5iQXB-.js} +1 -1
  54. package/payload/server/public/assets/page-ClJOW2fk.js +32 -0
  55. package/payload/server/public/assets/{page-rDhp8G9q.js → page-YsTtZsn6.js} +1 -1
  56. package/payload/server/public/assets/{public-zK67N3z2.js → public-BlDxwcmS.js} +1 -1
  57. package/payload/server/public/assets/{rotate-ccw-BzBJxqBN.js → rotate-ccw-DSynJPZX.js} +1 -1
  58. package/payload/server/public/assets/{useSubAccountSwitcher-B-GuP1jj.css → useSubAccountSwitcher-CJelLQK-.css} +1 -1
  59. package/payload/server/public/browser.html +4 -4
  60. package/payload/server/public/calendar.html +5 -5
  61. package/payload/server/public/chat.html +9 -9
  62. package/payload/server/public/data.html +8 -8
  63. package/payload/server/public/graph.html +9 -9
  64. package/payload/server/public/index.html +11 -11
  65. package/payload/server/public/operator.html +11 -11
  66. package/payload/server/public/public.html +9 -9
  67. package/payload/server/server.js +82 -63
  68. package/payload/server/public/assets/chat-Qpyg5t65.js +0 -1
  69. package/payload/server/public/assets/chevron-left-DBUeR2CX.js +0 -1
  70. package/payload/server/public/assets/data-Ch5bne41.js +0 -1
  71. package/payload/server/public/assets/page-BcxrdxYL.js +0 -32
  72. /package/payload/server/public/assets/{useSubAccountSwitcher-Bg0RH3Gk.js → useSubAccountSwitcher-DGKQxXDD.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"rc-daemon.d.ts","sourceRoot":"","sources":["../src/rc-daemon.ts"],"names":[],"mappings":"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,7 @@ export function reapplyAdminLevers(_accountDir, claudeConfigDir, logger) {
314
314
  /** Compose the env carried by the rc-daemon child and by Task 543's
315
315
  * sessions-pane spawn route. Exported so the route's HTTP handler can
316
316
  * build a byte-identical env without duplicating the field set. */
317
- export function buildRcChildEnv(parts, platform = process.platform) {
317
+ export function buildRcChildEnv(parts, platform = process.platform, io) {
318
318
  const env = parts.env ?? process.env;
319
319
  const built = {
320
320
  ...env,
@@ -351,7 +351,7 @@ export function buildRcChildEnv(parts, platform = process.platform) {
351
351
  // CLAUDE_CODE_OAUTH_TOKEN read from the platform's credentials FILE (the host
352
352
  // stays the single refresh owner). No-op on Linux. parts.logger, when present,
353
353
  // emits the op=spawn-hostcreds line.
354
- applyHostCredsEnv(built, parts.claudeConfigDir, platform, parts.logger);
354
+ applyHostCredsEnv(built, parts.claudeConfigDir, platform, parts.logger, io);
355
355
  return built;
356
356
  }
357
357
  function buildDaemonEnv(deps) {
@@ -1 +1 @@
1
- {"version":3,"file":"rc-daemon.js","sourceRoot":"","sources":["../src/rc-daemon.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,wEAAwE;AACxE,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,gFAAgF;AAChF,kEAAkE;AAClE,oEAAoE;AACpE,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,4EAA4E;AAC5E,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,0EAA0E;AAC1E,8DAA8D;AAC9D,8DAA8D;AAC9D,0EAA0E;AAE1E,OAAO,EAAE,IAAI,E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IAAI,CAAA;YACd,IAAI,OAAO,EAAE,CAAC;gBACZ,4DAA4D;gBAC5D,4DAA4D;gBAC5D,6DAA6D;gBAC7D,8DAA8D;gBAC9D,mCAAmC;gBACnC,IAAI,CAAC;oBAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC;gBAC5D,IAAI,CAAC;oBAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAA;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,4BAA4B,CAAC,CAAC;gBAClE,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,gCAAgC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;QACrE,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,L as n,M as r,N as i,O as a}from"./useSubAccountSwitcher-Bg0RH3Gk.js";import{i as o}from"./admin-types-hioowVct.js";import{b as s,x as c}from"./AdminShell-BihejKg_.js";import{t as l}from"./Checkbox-Ds004CBE.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(n(),1);function m(e=`admin`){let[t,n]=(0,p.useState)(`loading`),[r,a]=(0,p.useState)(``),[s,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1),[G,K]=(0,p.useState)(!0);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,p.useRef)(null),J=(0,p.useRef)(null);(0,p.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=o(r.thinkingView);return H.current=i,V(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let Y=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){i(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){i(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await r.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=s.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let o=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){i(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await X(o);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,s]),Q=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await X(r)},[r]),ee=(0,p.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:a,operatorName:s,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var h=r();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function _(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,a.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,a.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n||!m.trim(),loading:c,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:a.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n,loading:c,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:n,setAuthPolling:r,authLoading:i,setAuthLoading:o,pinError:c,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){g(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function T(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){r(!0),f(!0),o(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),r(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),r(!1),l(``)}return n||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[n?(0,h.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,h.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:n?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!n&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(s,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),n&&_===`native`&&(0,h.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,h.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,h.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,h.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,h.jsx)(s,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,h.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:c})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:a.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,a.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(s,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,h.jsx)(`button`,{onClick:w,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,h.jsx)(y,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,h.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,L as n,M as r,N as i,O as a}from"./useSubAccountSwitcher-DGKQxXDD.js";import{i as o}from"./admin-types-hioowVct.js";import{b as s,x as c}from"./AdminShell-DH6Lcj-d.js";import{t as l}from"./Checkbox-54KtArF3.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(n(),1);function m(e=`admin`){let[t,n]=(0,p.useState)(`loading`),[r,a]=(0,p.useState)(``),[s,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1),[G,K]=(0,p.useState)(!0);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let q=(0,p.useRef)(null),J=(0,p.useRef)(null);(0,p.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=o(r.thinkingView);return H.current=i,V(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}K(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let Y=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();K(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){i(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),Y.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(K(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function X(e,t){y(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){i(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await r.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Z=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=s.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let o=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){i(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await X(o);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,s]),Q=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await X(r)},[r]),ee=(0,p.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;K(!1),D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),$=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{Y.current=$},[$]),{appState:t,setAppState:n,pin:r,setPin:a,operatorName:s,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,claudeConnected:G,pinInputRef:q,setPinFormRef:J,handleSetPin:Z,handleLogin:Q,handleDisconnect:ee,handleLogout:$}}var h=r();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function _(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,a.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,a.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n||!m.trim(),loading:c,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:a.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n,loading:c,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:n,setAuthPolling:r,authLoading:i,setAuthLoading:o,pinError:c,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``);async function C(){S(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:y})})).json();e.accepted?(S(`Code submitted. Finishing sign-in…`),b(``)):S(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),S(`Could not submit code.`)}}async function w(){g(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function T(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){r(!0),f(!0),o(!1),v(e.transport||``);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}l(`Timed out waiting for sign-in. Try again.`),r(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function E(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),r(!1),l(``)}return n||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[n?(0,h.jsx)(`button`,{onClick:E,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,h.jsx)(`button`,{onClick:()=>f(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:n?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!n&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(s,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),n&&_===`native`&&(0,h.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,h.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,h.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,h.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,h.jsx)(s,{variant:`primary`,onClick:C,disabled:!y.trim(),children:`Submit`})]}),x&&(0,h.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:x})]})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:c})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:a.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,a.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(s,{variant:`primary`,onClick:T,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,h.jsx)(`button`,{onClick:w,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,h.jsx)(y,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,h.jsx)(v,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{C as t,D as n,I as r,L as i,M as a,O as o,S as s,T as c,_ as l,b as u,c as d,d as f,h as p,j as m,l as h,m as g,o as ee,p as te,r as ne,s as _,t as re,u as ie,v as ae,w as oe,y as se}from"./useSubAccountSwitcher-Bg0RH3Gk.js";async function ce(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var v=e(i(),1),y=a(),b={sm:14,md:16,lg:18},x={sm:30,md:38,lg:46};function S({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=b[t],h={...e===`send`?{width:x[t],height:x[t]}:{},...u},g=Object.keys(h).length>0;return(0,y.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,y.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,y.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,y.jsx)(n,{size:m})]}),i&&(0,y.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var le=n(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),ue=n(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),de=n(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),C=n(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),w=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),fe=n(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=n(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),pe=n(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),me=n(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),he=n(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),E=n(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ge=n(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),D=`maxy-shell-side-px`;function O(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function k(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-O());return Math.min(Math.max(e,248),n)}function _e(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(D);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return k(t)}catch{}return 264}function ve({targetSelector:e=`.platform`}){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(()=>_e()),i=(0,v.useRef)(n);(0,v.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,v.useCallback)(()=>{r(e=>{let t=k(e);return t===e?e:t})},[]);(0,v.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(k(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(D,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=k(264);r(e);try{window.localStorage.removeItem(D)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,y.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var A=r();function ye({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,v.useRef)(null),[s,c]=(0,v.useState)({position:`fixed`,visibility:`hidden`}),l=(0,v.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,v.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,v.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,A.createPortal)((0,y.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function be({actions:e,disabled:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{r(!1),a(null)},[]);return(0,y.jsxs)(`div`,{className:`conv-actions`,children:[(0,y.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,y.jsx)(se,{size:12})}),n&&(0,y.jsx)(ye,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,y.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,y.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var j=`claude-opus-4-8[1m]`,M=`claude-sonnet-5`,N=`claude-haiku-4-5`,P={[j]:`Opus 4.8 (1M context)`,[M]:`Sonnet 5`,[N]:`Haiku 4.5`};function F(e){return P[e]??e}var I=[j,M,N];function L(e){return e.replace(/\[1m\]$/,``)}function xe(e){return I.find(t=>L(t)===L(e))??e}var Se=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],R=[`low`,`medium`,`high`,`xhigh`];[...Se],[...R],[...R];var Ce=[j,M,N],we={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Te=Se.map(e=>({value:e,label:we[e]??e})),Ee={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},De=R.map(e=>({value:e,label:Ee[e]??e}));function z(e){if(e){let t=Ce.find(t=>L(t)===L(e));if(t)return t}return j}function Oe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,v.useState)(()=>z(e.model)),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,d]=(0,v.useState)(!1),f=(0,v.useRef)(!1);(0,v.useEffect)(()=>{i(z(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Model`}),(0,y.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:Ce.map(e=>(0,y.jsx)(`option`,{value:e,children:F(e)},e))})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Mode`}),(0,y.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Effort`}),(0,y.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),De.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void p(),children:l?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function B(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function V(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ae({target:e,onConfirm:t,onCancel:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Delete this conversation?`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,y.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,y.jsx)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,y.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var je=`auth-refresh-failed`;function Me({error:e,onClose:t}){if(!e)return null;let n=e.reason===je,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:r}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,y.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ne(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,v.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,y.jsx)(`span`,{children:`Claude Code`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,y.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:p>0?ke(p):`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:B(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await V(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Pe({open:e,onConnect:t,onClose:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Claude isn’t connected`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,y.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,y.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,y.jsx)(S,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function H(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Fe(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function U(e){return e.toLocaleString(`en-GB`)}function Ie(e){return`£${e.toFixed(2)}`}function W({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,y.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,y.jsx)(r,{className:`usage-day`,children:e}),(0,y.jsx)(r,{children:H(Fe(t))}),(0,y.jsx)(r,{children:U(t.tokens.output)}),(0,y.jsx)(r,{children:U(t.tokens.input)}),(0,y.jsx)(r,{children:U(t.tokens.cacheWrite)}),(0,y.jsx)(r,{children:U(t.tokens.cacheRead)}),(0,y.jsx)(r,{children:Ie(t.costGBP.opus)}),(0,y.jsx)(r,{children:Ie(t.costGBP.sonnet)})]})}function Le({show:e,onClose:t,sessionId:n,summary:r,loading:i,error:a}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,y.jsx)(g,{size:14})})]}),(0,y.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[i&&(0,y.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!i&&a&&(0,y.jsx)(`div`,{className:`usage-note usage-error`,children:a}),!i&&!a&&r&&r.days.length===0&&(0,y.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!i&&!a&&r&&r.days.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`usage-table-scroll`,children:(0,y.jsxs)(`table`,{className:`usage-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,y.jsx)(`th`,{children:`Active`}),(0,y.jsx)(`th`,{children:`Output tok`}),(0,y.jsx)(`th`,{children:`Input tok`}),(0,y.jsx)(`th`,{children:`Cache write`}),(0,y.jsx)(`th`,{children:`Cache read`}),(0,y.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,y.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,y.jsxs)(`tbody`,{children:[r.days.map(e=>(0,y.jsx)(W,{label:e.date,d:e},e.date)),(0,y.jsx)(W,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,y.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,r.pricing.opusPriceDate,` · £/$ `,r.pricing.usdPerGbp,` · Sonnet tokenizer factor `,r.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})}):null}var Re=`https://claude.ai/code`,ze=200,Be=[500,1e3,1500,2e3,2500,3e3,3e3];function Ve(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Re}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function He(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ue(e){let{businessName:n,cacheKey:r,onConnectClaude:i,role:a,userName:u,userAvatar:f,onSelectProjects:g,onSelectPeople:re,onSelectTasks:se,onSelectAgents:ce,onCloseMobileDrawer:b,collapsed:x,selectedWhatsappId:S,onSelectWhatsappConversation:D,initialWhatsappSurface:O=!1,onSelectData:k,onCloseData:_e,initialDataSurface:ve=!1}=e,A=te(r),ye=(0,v.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,y.jsx)(he,{size:12}),panel:()=>(0,y.jsx)(Oe,{row:e,adminFetch:A,onError:e=>B({message:e,failed:!0})})}),[A]),j=o.productName,M=typeof u==`string`?u:u===null?`name unavailable`:n||j,N=(M.trim().charAt(0)||`?`).toUpperCase(),[P,F]=(0,v.useState)(ve?`data`:O?`whatsapp`:`sessions`),[I,L]=(0,v.useState)([]),[xe,Se]=(0,v.useState)(!1),[R,Ce]=(0,v.useState)(null),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(`file`),[z,B]=(0,v.useState)(null),[ke,V]=(0,v.useState)(null),[je,Ne]=(0,v.useState)(!1),[H,Fe]=(0,v.useState)([]),[U,Ie]=(0,v.useState)(!1),[W,Re]=(0,v.useState)(null),[Ue,We]=(0,v.useState)(!1),[G,Je]=(0,v.useState)(!1),[K,Ye]=(0,v.useState)(!1),[Xe,Ze]=(0,v.useState)(null),[q,Qe]=(0,v.useState)(new Set),[$e,et]=(0,v.useState)(null),[J,tt]=(0,v.useState)(new Set),[nt,rt]=(0,v.useState)(new Set),[it,at]=(0,v.useState)(new Set),[Y,ot]=(0,v.useState)(null),[st,X]=(0,v.useState)(``),[ct,lt]=(0,v.useState)(!1),[ut,dt]=(0,v.useState)(null),[ft,pt]=(0,v.useState)(null),[mt,ht]=(0,v.useState)(!1),[gt,_t]=(0,v.useState)(null),[Z,vt]=(0,v.useState)(!1),yt=(0,v.useRef)(0),[bt,xt]=(0,v.useState)([]),[St,Ct]=(0,v.useState)(!1),[wt,Tt]=(0,v.useState)(null),[Et,Dt]=(0,v.useState)(`whatsapp`),Ot=(0,v.useCallback)(e=>{if(b(),!r){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),B({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),B({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ne(r,e.downloadPath,e.downloadRoot??`data`),B({message:`Downloading ${e.name}`,failed:!1})},[r,b]);(0,v.useEffect)(()=>{if(!z)return;let e=setTimeout(()=>B(null),2500);return()=>clearTimeout(e)},[z]);let kt=(0,v.useCallback)(async()=>{if(r){Te(!0),Ce(null);try{let e=await A(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);L((await e.json()).artefacts??[]),Se(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Ce(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Te(!1)}}},[r,A]),Q=(0,v.useCallback)(async()=>{if(!r)return null;let e=++yt.current;We(!0),Re(null);try{let t=await A(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===yt.current?(Fe(r),Ze(n.accountId??null),Ie(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===yt.current&&Re(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===yt.current&&We(!1)}},[r,A]),At=(0,v.useCallback)(async()=>{if(r){Tt(null);try{let e=await A(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);xt((await e.json()).conversations??[]),Ct(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Tt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[r,A]);(0,v.useEffect)(()=>{!r||U||Q()},[r,U,Q]),(0,v.useEffect)(()=>{if(!r)return;let e=null;return At(),e=setInterval(()=>{At()},Ge),()=>{e!==null&&clearInterval(e)}},[r,At]),(0,v.useEffect)(()=>{if(!r)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Ke))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[r,Q]);let jt=(0,v.useMemo)(()=>{let e=new Map;for(let t of _)e.set(t,[]);for(let t of bt)e.get(t.channel)?.push(t);for(let t of _)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[bt]),Mt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Nt=()=>{D(null),F(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${xe?I.length:0} collapsed=${x}`),kt()},$=1.5,Pt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),kt()},Ft=()=>{D(null),F(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${U?H.length:0} collapsed=${x}`),U||Q()},It=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Lt=()=>{F(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${x}`),k(),b()},Rt=e=>{_e?.(),F(`whatsapp`),Dt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${jt.get(e)?.length??0} collapsed=${x}`)},zt=(0,v.useCallback)(async e=>{if(J.has(e.sessionId))return;tt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ve(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(b(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),V(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),V({sessionId:e.sessionId,reason:r})}finally{tt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[A,b,J]),Bt=(0,v.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Be.length;n++){await new Promise(e=>setTimeout(e,Be[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Vt=(0,v.useCallback)(async()=>{if(!Z){vt(!0);try{let e=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Ve(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Bt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ne(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),V(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),V({sessionId:null,reason:t})}finally{vt(!1)}}},[A,Z,Bt]),Ht=(0,v.useCallback)((e,t)=>{e.stopPropagation(),et(t)},[]),Ut=(0,v.useCallback)(async(e,t)=>{e.stopPropagation(),dt(t),pt(null),_t(null),ht(!0);try{let e=await A(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?pt(n):_t(n.error??`status ${e.status}`)}catch(e){_t(e instanceof Error?e.message:String(e))}finally{ht(!1)}},[A]),Wt=(0,v.useCallback)(async e=>{if(!q.has(e.sessionId)){Qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await A(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),B({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Fe(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),B({message:`Delete failed: ${n}`,failed:!0})}finally{Qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[A,q,Q]),Gt=(0,v.useCallback)(async(e,t)=>{if(e.stopPropagation(),!nt.has(t.sessionId)){rt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),B({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),B({message:`Stop failed: ${n}`,failed:!0})}finally{rt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,nt,Q]),Kt=(0,v.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!it.has(t.sessionId)){at(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{at(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,it,Q]),qt=(0,v.useCallback)(async e=>{let t=st.trim();if(!t){B({message:`Title can’t be empty`,failed:!0});return}if(t.length>ze){B({message:`Title too long (max ${ze})`,failed:!0});return}lt(!0);try{let n=await A(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),B({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),ot(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),B({message:`Rename failed: ${n}`,failed:!0})}finally{lt(!1)}},[A,st,Q]);return(0,y.jsxs)(`aside`,{className:`side`,children:[(0,y.jsx)(`div`,{className:`side-new-session-row`,children:(0,y.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Vt,disabled:Z,"aria-busy":Z,children:[(0,y.jsx)(me,{size:14}),(0,y.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,y.jsxs)(`nav`,{className:`side-nav`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),re(),b()},children:[(0,y.jsx)(ge,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`People`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ce(),b()},children:[(0,y.jsx)(de,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Agents`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),g(),b()},children:[(0,y.jsx)(C,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:m().term}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),se(),b()},children:[(0,y.jsx)(T,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`artefacts`?` active`:``}`,onClick:Nt,children:[(0,y.jsx)(s,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`sessions`?` active`:``}`,onClick:Ft,children:[(0,y.jsx)(fe,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`data`?` active`:``}`,onClick:Lt,children:[(0,y.jsx)(c,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Data`}),(0,y.jsx)(`span`,{className:`kbd`})]}),St&&_.filter(e=>jt.get(e).length>0).map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`whatsapp`&&Et===e?` active`:``}`,onClick:()=>Rt(e),children:[(0,y.jsx)(h,{channel:e,size:16}),(0,y.jsx)(`span`,{className:`label`,children:Mt[e]}),(0,y.jsx)(`span`,{className:`kbd`})]},e)),wt&&(0,y.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,y.jsx)(`span`,{className:`label`,children:wt})})]}),P===`artefacts`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Artefacts`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Pt,disabled:we,children:(0,y.jsx)(l,{size:12,className:we?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:we?`…`:String(I.length)})]})]}),R&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),xe&&!R&&I.length>0&&(()=>{let e=I.filter(e=>e.kind===`agent-template`).length,t=I.length-e;return(0,y.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:I.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${Ee===e.key?` active`:``}`,onClick:()=>De(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,y.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),xe&&!R&&I.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),I.filter(e=>Ee===`all`?!0:Ee===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?de:s,r=He(e.updatedAt),i=e.downloadPath!==null;return(0,y.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>Ot(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,y.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,y.jsx)(oe,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),P===`sessions`&&(()=>{let e=H.filter(e=>G?!0:!e.isSubagent).filter(e=>K?!0:!e.archived),n=H.some(e=>e.isSubagent),r=H.some(e=>e.archived);return(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Sessions`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:It,disabled:Ue,children:(0,y.jsx)(l,{size:12,className:Ue?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:Ue?`…`:String(e.length)})]})]}),Xe&&(0,y.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,y.jsx)(`code`,{children:Xe})}),(n||r)&&(0,y.jsxs)(`div`,{className:`artefact-filter-chips`,children:[n&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${G?` active`:``}`,"aria-pressed":G,onClick:()=>Je(e=>!e),title:G?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ye(e=>!e),title:K?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),W&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:W}),U&&!W&&e.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let n=He(e.startedAt),r=J.has(e.sessionId),i=q.has(e.sessionId),a=nt.has(e.sessionId),o=it.has(e.sessionId),s=r||i||a||o,c=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,y.jsx)(t,{size:12}),busy:r,onClick:()=>{zt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,y.jsx)(pe,{size:12}),onClick:()=>{c()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,y.jsx)(w,{size:12}),onClick:t=>{Ut(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,y.jsx)(E,{size:12}),busy:a,onClick:t=>{Gt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,y.jsx)(le,{size:12}),busy:o,onClick:t=>{Kt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,y.jsx)(ue,{size:12}),busy:o,onClick:t=>{Kt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,y.jsx)(ae,{size:12}),busy:ct&&Y===e.sessionId,onClick:t=>{t.stopPropagation(),ot(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,y.jsx)(p,{size:12}),danger:!0,busy:i,onClick:t=>{Ht(t,e)}},ye({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,y.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,y.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${e.personName??e.title} in webchat`,onClick:()=>{Y!==e.sessionId&&c()},onKeyDown:t=>{Y!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c())},children:[(0,y.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,y.jsx)(ie,{channel:e.channel,size:13}),Y===e.sessionId?(0,y.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:st,disabled:ct,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),qt(e)):t.key===`Escape`&&(t.preventDefault(),ot(null),X(``))},onBlur:()=>{Y===e.sessionId&&!ct&&(ot(null),X(``))}}):(0,y.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,y.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,y.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),n&&(0,y.jsxs)(`span`,{children:[` · `,n]})]})]})]}),(0,y.jsx)(be,{actions:l,disabled:s})]},e.sessionId)})]})})(),P===`whatsapp`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:Mt[Et]}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{At()},children:(0,y.jsx)(l,{size:12})}),(0,y.jsx)(`span`,{children:String(jt.get(Et).length)})]})]}),jt.get(Et).map(e=>{let t=He(e.lastMessageAt),n=d(e);return(0,y.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${S===n?` active`:``}`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{D(e),b()},title:e.title,children:[(0,y.jsx)(h,{channel:e.channel,size:14}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:ee(e)})}),t&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,y.jsx)(be,{actions:[ye({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,y.jsx)(qe,{}),(0,y.jsxs)(`div`,{className:`side-foot`,children:[(0,y.jsx)(`div`,{className:`avatar`,children:f?(0,y.jsx)(`img`,{src:f,alt:M}):N}),(0,y.jsxs)(`div`,{className:`who`,children:[(0,y.jsx)(`span`,{className:`name`,children:M}),(0,y.jsx)(`span`,{className:`role`,children:a??`operator`})]})]}),z&&(0,y.jsx)(`div`,{className:`copy-toast${z.failed?` copy-toast-failed`:``}`,role:`status`,children:z.message}),(0,y.jsx)(Me,{error:ke,onClose:()=>V(null)}),(0,y.jsx)(Pe,{open:je,onConnect:()=>{Ne(!1),i?.()},onClose:()=>Ne(!1)}),(0,y.jsx)(Ae,{target:$e,onCancel:()=>et(null),onConfirm:()=>{let e=$e;et(null),e&&Wt(e)}}),(0,y.jsx)(Le,{show:ut!==null,onClose:()=>{dt(null),pt(null),_t(null)},sessionId:ut?.sessionId??null,summary:ft,loading:mt,error:gt})]})}var We=5e3,Ge=3e4,Ke=3e4;function qe(){let[e,t]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},We))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,y.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var G=`admin-sidebar-collapsed`,Je=`admin-sidebar-drawer-open`;function K(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(G)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(G,`1`):window.sessionStorage.removeItem(G)}catch{}}function Xe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Je)===`1`}catch{return!1}}function Ze(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Je,`1`):window.sessionStorage.removeItem(Je)}catch{}}var q=720;function Qe(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function $e(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function et(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function J(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function tt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function nt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:u,role:p,onOpenConversations:h,children:g,footer:ee}=e,{subAccounts:te,activeAccountId:ne,switching:_,switchAccount:ie}=re(t),[ae,oe]=(0,v.useState)(!0);(0,v.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||oe(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let se=s??ae,ce=c??(()=>{window.location.assign(`/?connect=claude`)}),[b,x]=(0,v.useState)(()=>K()),[S,le]=(0,v.useState)(()=>Xe()),[ue,de]=(0,v.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${q}px)`).matches),[C,w]=(0,v.useState)(()=>typeof window>`u`||J(window.location.pathname,window.location.search)?null:et(window.location.pathname,window.location.search)),[fe]=(0,v.useState)(()=>C!==null),[T,pe]=(0,v.useState)(()=>typeof window>`u`?!1:J(window.location.pathname,window.location.search)),[me]=(0,v.useState)(()=>T);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${q}px)`),t=e=>de(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let he=(0,v.useCallback)(e=>{Ye(e),x(e)},[]),E=(0,v.useCallback)(e=>{Ze(e),le(e)},[]);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${b} drawer=${S}`)},[]),(0,v.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${C.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,v.useEffect)(()=>{typeof window>`u`||!T||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ge=(0,v.useCallback)(e=>{if(pe(!1),e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Qe(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),D=(0,v.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=$e(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}w(null),pe(!0)},[]),O=ue?S:!b,k=(0,v.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${q}px)`).matches){let e=S;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),E(!e)}else{let e=b;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),he(!e)}},[b,S,he,E]),_e=(0,v.useCallback)(e=>{let t=tt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),A={collapsed:b,mobileDrawerOpen:S,sidebarOpen:O,onToggleSidebar:k,setMobileDrawerOpen:E,selectedWhatsapp:C,onClearWhatsapp:()=>w(null),dataOpen:T};return r===`operator`?(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(A):g}),ee]}):(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:se,onConnectClaude:ce,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsxs)(`div`,{className:`platform${S?` menu-open`:``}${b?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,y.jsx)(Ue,{businessName:n,cacheKey:t,onConnectClaude:ce,role:p??null,userName:l,userAvatar:u??null,onSelectProjects:()=>{window.location.href=`/graph?label=${m().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>E(!1),collapsed:b,mobileDrawerOpen:S,selectedWhatsappId:C?d(C):null,onSelectWhatsappConversation:ge,initialWhatsappSurface:fe,onSelectData:D,onCloseData:()=>pe(!1),initialDataSurface:me}),!ue&&(0,y.jsx)(ve,{}),typeof g==`function`?g(A):g]}),S&&(0,y.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>E(!1)}),ee]})}export{de as _,V as a,S as b,M as c,ge as d,E as f,w as g,T as h,Ne as i,xe as l,me as m,Ve as n,N as o,he as p,Pe as r,j as s,nt as t,F as u,ue as v,ce as x,le as y};
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{C as t,D as n,I as r,L as i,M as a,O as o,S as s,T as c,_ as l,b as u,c as d,d as f,h as p,j as m,l as h,m as g,o as ee,p as te,r as ne,s as _,t as re,u as ie,v as ae,w as oe,y as se}from"./useSubAccountSwitcher-DGKQxXDD.js";async function ce(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var v=e(i(),1),y=a(),b={sm:14,md:16,lg:18},x={sm:30,md:38,lg:46};function S({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=b[t],h={...e===`send`?{width:x[t],height:x[t]}:{},...u},g=Object.keys(h).length>0;return(0,y.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,y.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,y.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,y.jsx)(n,{size:m})]}),i&&(0,y.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var le=n(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),ue=n(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),de=n(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),C=n(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),w=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),fe=n(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=n(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),pe=n(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),me=n(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),he=n(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),E=n(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ge=n(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),D=`maxy-shell-side-px`;function O(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function k(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-O());return Math.min(Math.max(e,248),n)}function _e(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(D);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return k(t)}catch{}return 264}function ve({targetSelector:e=`.platform`}){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(()=>_e()),i=(0,v.useRef)(n);(0,v.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,v.useCallback)(()=>{r(e=>{let t=k(e);return t===e?e:t})},[]);(0,v.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(k(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(D,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=k(264);r(e);try{window.localStorage.removeItem(D)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,y.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var A=r();function ye({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,v.useRef)(null),[s,c]=(0,v.useState)({position:`fixed`,visibility:`hidden`}),l=(0,v.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,v.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,v.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,A.createPortal)((0,y.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function be({actions:e,disabled:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{r(!1),a(null)},[]);return(0,y.jsxs)(`div`,{className:`conv-actions`,children:[(0,y.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,y.jsx)(se,{size:12})}),n&&(0,y.jsx)(ye,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,y.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,y.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var j=`claude-opus-4-8[1m]`,M=`claude-sonnet-5`,N=`claude-haiku-4-5`,P={[j]:`Opus 4.8 (1M context)`,[M]:`Sonnet 5`,[N]:`Haiku 4.5`};function F(e){return P[e]??e}var I=[j,M,N];function L(e){return e.replace(/\[1m\]$/,``)}function xe(e){return I.find(t=>L(t)===L(e))??e}var Se=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],R=[`low`,`medium`,`high`,`xhigh`];[...Se],[...R],[...R];var Ce=[j,M,N],we={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Te=Se.map(e=>({value:e,label:we[e]??e})),Ee={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},De=R.map(e=>({value:e,label:Ee[e]??e}));function z(e){if(e){let t=Ce.find(t=>L(t)===L(e));if(t)return t}return j}function Oe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,v.useState)(()=>z(e.model)),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,d]=(0,v.useState)(!1),f=(0,v.useRef)(!1);(0,v.useEffect)(()=>{i(z(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Model`}),(0,y.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:Ce.map(e=>(0,y.jsx)(`option`,{value:e,children:F(e)},e))})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Mode`}),(0,y.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Effort`}),(0,y.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),De.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void p(),children:l?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function B(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function V(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ae({target:e,onConfirm:t,onCancel:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Delete this conversation?`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,y.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,y.jsx)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,y.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var je=`auth-refresh-failed`;function Me({error:e,onClose:t}){if(!e)return null;let n=e.reason===je,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:r}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,y.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ne(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,v.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,y.jsx)(`span`,{children:`Claude Code`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,y.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:p>0?ke(p):`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:B(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await V(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Pe({open:e,onConnect:t,onClose:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Claude isn’t connected`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,y.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,y.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,y.jsx)(S,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function H(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Fe(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function U(e){return e.toLocaleString(`en-GB`)}function Ie(e){return`£${e.toFixed(2)}`}function W({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,y.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,y.jsx)(r,{className:`usage-day`,children:e}),(0,y.jsx)(r,{children:H(Fe(t))}),(0,y.jsx)(r,{children:U(t.tokens.output)}),(0,y.jsx)(r,{children:U(t.tokens.input)}),(0,y.jsx)(r,{children:U(t.tokens.cacheWrite)}),(0,y.jsx)(r,{children:U(t.tokens.cacheRead)}),(0,y.jsx)(r,{children:Ie(t.costGBP.opus)}),(0,y.jsx)(r,{children:Ie(t.costGBP.sonnet)})]})}function Le({show:e,onClose:t,sessionId:n,summary:r,loading:i,error:a}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,y.jsx)(g,{size:14})})]}),(0,y.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[i&&(0,y.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!i&&a&&(0,y.jsx)(`div`,{className:`usage-note usage-error`,children:a}),!i&&!a&&r&&r.days.length===0&&(0,y.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!i&&!a&&r&&r.days.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`usage-table-scroll`,children:(0,y.jsxs)(`table`,{className:`usage-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,y.jsx)(`th`,{children:`Active`}),(0,y.jsx)(`th`,{children:`Output tok`}),(0,y.jsx)(`th`,{children:`Input tok`}),(0,y.jsx)(`th`,{children:`Cache write`}),(0,y.jsx)(`th`,{children:`Cache read`}),(0,y.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,y.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,y.jsxs)(`tbody`,{children:[r.days.map(e=>(0,y.jsx)(W,{label:e.date,d:e},e.date)),(0,y.jsx)(W,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,y.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,r.pricing.opusPriceDate,` · £/$ `,r.pricing.usdPerGbp,` · Sonnet tokenizer factor `,r.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})}):null}var Re=`https://claude.ai/code`,ze=200,Be=[500,1e3,1500,2e3,2500,3e3,3e3];function Ve(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Re}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function He(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ue(e){let{businessName:n,cacheKey:r,onConnectClaude:i,role:a,userName:u,userAvatar:f,onSelectProjects:g,onSelectPeople:re,onSelectTasks:se,onSelectAgents:ce,onCloseMobileDrawer:b,collapsed:x,selectedWhatsappId:S,onSelectWhatsappConversation:D,initialWhatsappSurface:O=!1,onSelectData:k,onCloseData:_e,initialDataSurface:ve=!1}=e,A=te(r),ye=(0,v.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,y.jsx)(he,{size:12}),panel:()=>(0,y.jsx)(Oe,{row:e,adminFetch:A,onError:e=>B({message:e,failed:!0})})}),[A]),j=o.productName,M=typeof u==`string`?u:u===null?`name unavailable`:n||j,N=(M.trim().charAt(0)||`?`).toUpperCase(),[P,F]=(0,v.useState)(ve?`data`:O?`whatsapp`:`sessions`),[I,L]=(0,v.useState)([]),[xe,Se]=(0,v.useState)(!1),[R,Ce]=(0,v.useState)(null),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(`file`),[z,B]=(0,v.useState)(null),[ke,V]=(0,v.useState)(null),[je,Ne]=(0,v.useState)(!1),[H,Fe]=(0,v.useState)([]),[U,Ie]=(0,v.useState)(!1),[W,Re]=(0,v.useState)(null),[Ue,We]=(0,v.useState)(!1),[G,Je]=(0,v.useState)(!1),[K,Ye]=(0,v.useState)(!1),[Xe,Ze]=(0,v.useState)(null),[q,Qe]=(0,v.useState)(new Set),[$e,et]=(0,v.useState)(null),[J,tt]=(0,v.useState)(new Set),[nt,rt]=(0,v.useState)(new Set),[it,at]=(0,v.useState)(new Set),[Y,ot]=(0,v.useState)(null),[st,X]=(0,v.useState)(``),[ct,lt]=(0,v.useState)(!1),[ut,dt]=(0,v.useState)(null),[ft,pt]=(0,v.useState)(null),[mt,ht]=(0,v.useState)(!1),[gt,_t]=(0,v.useState)(null),[Z,vt]=(0,v.useState)(!1),yt=(0,v.useRef)(0),[bt,xt]=(0,v.useState)([]),[St,Ct]=(0,v.useState)(!1),[wt,Tt]=(0,v.useState)(null),[Et,Dt]=(0,v.useState)(`whatsapp`),Ot=(0,v.useCallback)(e=>{if(b(),!r){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),B({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),B({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ne(r,e.downloadPath,e.downloadRoot??`data`),B({message:`Downloading ${e.name}`,failed:!1})},[r,b]);(0,v.useEffect)(()=>{if(!z)return;let e=setTimeout(()=>B(null),2500);return()=>clearTimeout(e)},[z]);let kt=(0,v.useCallback)(async()=>{if(r){Te(!0),Ce(null);try{let e=await A(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);L((await e.json()).artefacts??[]),Se(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Ce(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Te(!1)}}},[r,A]),Q=(0,v.useCallback)(async()=>{if(!r)return null;let e=++yt.current;We(!0),Re(null);try{let t=await A(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===yt.current?(Fe(r),Ze(n.accountId??null),Ie(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===yt.current&&Re(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===yt.current&&We(!1)}},[r,A]),At=(0,v.useCallback)(async()=>{if(r){Tt(null);try{let e=await A(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);xt((await e.json()).conversations??[]),Ct(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Tt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[r,A]);(0,v.useEffect)(()=>{!r||U||Q()},[r,U,Q]),(0,v.useEffect)(()=>{if(!r)return;let e=null;return At(),e=setInterval(()=>{At()},Ge),()=>{e!==null&&clearInterval(e)}},[r,At]),(0,v.useEffect)(()=>{if(!r)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Ke))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[r,Q]);let jt=(0,v.useMemo)(()=>{let e=new Map;for(let t of _)e.set(t,[]);for(let t of bt)e.get(t.channel)?.push(t);for(let t of _)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[bt]),Mt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Nt=()=>{D(null),F(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${xe?I.length:0} collapsed=${x}`),kt()},$=1.5,Pt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),kt()},Ft=()=>{D(null),F(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${U?H.length:0} collapsed=${x}`),U||Q()},It=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Lt=()=>{F(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${x}`),k(),b()},Rt=e=>{_e?.(),F(`whatsapp`),Dt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${jt.get(e)?.length??0} collapsed=${x}`)},zt=(0,v.useCallback)(async e=>{if(J.has(e.sessionId))return;tt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ve(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(b(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),V(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),V({sessionId:e.sessionId,reason:r})}finally{tt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[A,b,J]),Bt=(0,v.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Be.length;n++){await new Promise(e=>setTimeout(e,Be[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Vt=(0,v.useCallback)(async()=>{if(!Z){vt(!0);try{let e=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Ve(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Bt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ne(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),V(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),V({sessionId:null,reason:t})}finally{vt(!1)}}},[A,Z,Bt]),Ht=(0,v.useCallback)((e,t)=>{e.stopPropagation(),et(t)},[]),Ut=(0,v.useCallback)(async(e,t)=>{e.stopPropagation(),dt(t),pt(null),_t(null),ht(!0);try{let e=await A(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?pt(n):_t(n.error??`status ${e.status}`)}catch(e){_t(e instanceof Error?e.message:String(e))}finally{ht(!1)}},[A]),Wt=(0,v.useCallback)(async e=>{if(!q.has(e.sessionId)){Qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await A(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),B({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Fe(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),B({message:`Delete failed: ${n}`,failed:!0})}finally{Qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[A,q,Q]),Gt=(0,v.useCallback)(async(e,t)=>{if(e.stopPropagation(),!nt.has(t.sessionId)){rt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),B({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),B({message:`Stop failed: ${n}`,failed:!0})}finally{rt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,nt,Q]),Kt=(0,v.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!it.has(t.sessionId)){at(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{at(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,it,Q]),qt=(0,v.useCallback)(async e=>{let t=st.trim();if(!t){B({message:`Title can’t be empty`,failed:!0});return}if(t.length>ze){B({message:`Title too long (max ${ze})`,failed:!0});return}lt(!0);try{let n=await A(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),B({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),ot(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),B({message:`Rename failed: ${n}`,failed:!0})}finally{lt(!1)}},[A,st,Q]);return(0,y.jsxs)(`aside`,{className:`side`,children:[(0,y.jsx)(`div`,{className:`side-new-session-row`,children:(0,y.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Vt,disabled:Z,"aria-busy":Z,children:[(0,y.jsx)(me,{size:14}),(0,y.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,y.jsxs)(`nav`,{className:`side-nav`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),re(),b()},children:[(0,y.jsx)(ge,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`People`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ce(),b()},children:[(0,y.jsx)(de,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Agents`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),g(),b()},children:[(0,y.jsx)(C,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:m().term}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),se(),b()},children:[(0,y.jsx)(T,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`artefacts`?` active`:``}`,onClick:Nt,children:[(0,y.jsx)(s,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`sessions`?` active`:``}`,onClick:Ft,children:[(0,y.jsx)(fe,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`data`?` active`:``}`,onClick:Lt,children:[(0,y.jsx)(c,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Data`}),(0,y.jsx)(`span`,{className:`kbd`})]}),St&&_.filter(e=>jt.get(e).length>0).map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`whatsapp`&&Et===e?` active`:``}`,onClick:()=>Rt(e),children:[(0,y.jsx)(h,{channel:e,size:16}),(0,y.jsx)(`span`,{className:`label`,children:Mt[e]}),(0,y.jsx)(`span`,{className:`kbd`})]},e)),wt&&(0,y.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,y.jsx)(`span`,{className:`label`,children:wt})})]}),P===`artefacts`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Artefacts`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Pt,disabled:we,children:(0,y.jsx)(l,{size:12,className:we?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:we?`…`:String(I.length)})]})]}),R&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),xe&&!R&&I.length>0&&(()=>{let e=I.filter(e=>e.kind===`agent-template`).length,t=I.length-e;return(0,y.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:I.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${Ee===e.key?` active`:``}`,onClick:()=>De(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,y.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),xe&&!R&&I.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),I.filter(e=>Ee===`all`?!0:Ee===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?de:s,r=He(e.updatedAt),i=e.downloadPath!==null;return(0,y.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>Ot(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,y.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,y.jsx)(oe,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),P===`sessions`&&(()=>{let e=H.filter(e=>G?!0:!e.isSubagent).filter(e=>K?!0:!e.archived),n=H.some(e=>e.isSubagent),r=H.some(e=>e.archived);return(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Sessions`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:It,disabled:Ue,children:(0,y.jsx)(l,{size:12,className:Ue?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:Ue?`…`:String(e.length)})]})]}),Xe&&(0,y.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,y.jsx)(`code`,{children:Xe})}),(n||r)&&(0,y.jsxs)(`div`,{className:`artefact-filter-chips`,children:[n&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${G?` active`:``}`,"aria-pressed":G,onClick:()=>Je(e=>!e),title:G?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ye(e=>!e),title:K?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),W&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:W}),U&&!W&&e.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let n=He(e.startedAt),r=J.has(e.sessionId),i=q.has(e.sessionId),a=nt.has(e.sessionId),o=it.has(e.sessionId),s=r||i||a||o,c=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,y.jsx)(t,{size:12}),busy:r,onClick:()=>{zt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,y.jsx)(pe,{size:12}),onClick:()=>{c()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,y.jsx)(w,{size:12}),onClick:t=>{Ut(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,y.jsx)(E,{size:12}),busy:a,onClick:t=>{Gt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,y.jsx)(le,{size:12}),busy:o,onClick:t=>{Kt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,y.jsx)(ue,{size:12}),busy:o,onClick:t=>{Kt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,y.jsx)(ae,{size:12}),busy:ct&&Y===e.sessionId,onClick:t=>{t.stopPropagation(),ot(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,y.jsx)(p,{size:12}),danger:!0,busy:i,onClick:t=>{Ht(t,e)}},ye({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,y.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,y.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${e.personName??e.title} in webchat`,onClick:()=>{Y!==e.sessionId&&c()},onKeyDown:t=>{Y!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c())},children:[(0,y.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,y.jsx)(ie,{channel:e.channel,size:13}),Y===e.sessionId?(0,y.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:st,disabled:ct,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),qt(e)):t.key===`Escape`&&(t.preventDefault(),ot(null),X(``))},onBlur:()=>{Y===e.sessionId&&!ct&&(ot(null),X(``))}}):(0,y.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,y.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,y.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),n&&(0,y.jsxs)(`span`,{children:[` · `,n]})]})]})]}),(0,y.jsx)(be,{actions:l,disabled:s})]},e.sessionId)})]})})(),P===`whatsapp`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:Mt[Et]}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{At()},children:(0,y.jsx)(l,{size:12})}),(0,y.jsx)(`span`,{children:String(jt.get(Et).length)})]})]}),jt.get(Et).map(e=>{let t=He(e.lastMessageAt),n=d(e);return(0,y.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${S===n?` active`:``}`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{D(e),b()},title:e.title,children:[(0,y.jsx)(h,{channel:e.channel,size:14}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:ee(e)})}),t&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,y.jsx)(be,{actions:[ye({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,y.jsx)(qe,{}),(0,y.jsxs)(`div`,{className:`side-foot`,children:[(0,y.jsx)(`div`,{className:`avatar`,children:f?(0,y.jsx)(`img`,{src:f,alt:M}):N}),(0,y.jsxs)(`div`,{className:`who`,children:[(0,y.jsx)(`span`,{className:`name`,children:M}),(0,y.jsx)(`span`,{className:`role`,children:a??`operator`})]})]}),z&&(0,y.jsx)(`div`,{className:`copy-toast${z.failed?` copy-toast-failed`:``}`,role:`status`,children:z.message}),(0,y.jsx)(Me,{error:ke,onClose:()=>V(null)}),(0,y.jsx)(Pe,{open:je,onConnect:()=>{Ne(!1),i?.()},onClose:()=>Ne(!1)}),(0,y.jsx)(Ae,{target:$e,onCancel:()=>et(null),onConfirm:()=>{let e=$e;et(null),e&&Wt(e)}}),(0,y.jsx)(Le,{show:ut!==null,onClose:()=>{dt(null),pt(null),_t(null)},sessionId:ut?.sessionId??null,summary:ft,loading:mt,error:gt})]})}var We=5e3,Ge=3e4,Ke=3e4;function qe(){let[e,t]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},We))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,y.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var G=`admin-sidebar-collapsed`,Je=`admin-sidebar-drawer-open`;function K(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(G)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(G,`1`):window.sessionStorage.removeItem(G)}catch{}}function Xe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Je)===`1`}catch{return!1}}function Ze(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Je,`1`):window.sessionStorage.removeItem(Je)}catch{}}var q=720;function Qe(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function $e(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function et(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function J(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function tt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function nt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:u,role:p,onOpenConversations:h,children:g,footer:ee}=e,{subAccounts:te,activeAccountId:ne,switching:_,switchAccount:ie}=re(t),[ae,oe]=(0,v.useState)(!0);(0,v.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||oe(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let se=s??ae,ce=c??(()=>{window.location.assign(`/?connect=claude`)}),[b,x]=(0,v.useState)(()=>K()),[S,le]=(0,v.useState)(()=>Xe()),[ue,de]=(0,v.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${q}px)`).matches),[C,w]=(0,v.useState)(()=>typeof window>`u`||J(window.location.pathname,window.location.search)?null:et(window.location.pathname,window.location.search)),[fe]=(0,v.useState)(()=>C!==null),[T,pe]=(0,v.useState)(()=>typeof window>`u`?!1:J(window.location.pathname,window.location.search)),[me]=(0,v.useState)(()=>T);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${q}px)`),t=e=>de(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let he=(0,v.useCallback)(e=>{Ye(e),x(e)},[]),E=(0,v.useCallback)(e=>{Ze(e),le(e)},[]);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${b} drawer=${S}`)},[]),(0,v.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${C.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,v.useEffect)(()=>{typeof window>`u`||!T||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ge=(0,v.useCallback)(e=>{if(pe(!1),e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Qe(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),D=(0,v.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=$e(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}w(null),pe(!0)},[]),O=ue?S:!b,k=(0,v.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${q}px)`).matches){let e=S;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),E(!e)}else{let e=b;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),he(!e)}},[b,S,he,E]),_e=(0,v.useCallback)(e=>{let t=tt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),A={collapsed:b,mobileDrawerOpen:S,sidebarOpen:O,onToggleSidebar:k,setMobileDrawerOpen:E,selectedWhatsapp:C,onClearWhatsapp:()=>w(null),dataOpen:T};return r===`operator`?(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(A):g}),ee]}):(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:se,onConnectClaude:ce,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsxs)(`div`,{className:`platform${S?` menu-open`:``}${b?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,y.jsx)(Ue,{businessName:n,cacheKey:t,onConnectClaude:ce,role:p??null,userName:l,userAvatar:u??null,onSelectProjects:()=>{window.location.href=`/graph?label=${m().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>E(!1),collapsed:b,mobileDrawerOpen:S,selectedWhatsappId:C?d(C):null,onSelectWhatsappConversation:ge,initialWhatsappSurface:fe,onSelectData:D,onCloseData:()=>pe(!1),initialDataSurface:me}),!ue&&(0,y.jsx)(ve,{}),typeof g==`function`?g(A):g]}),S&&(0,y.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>E(!1)}),ee]})}export{de as _,V as a,S as b,M as c,ge as d,E as f,w as g,T as h,Ne as i,xe as l,me as m,Ve as n,N as o,he as p,Pe as r,j as s,nt as t,F as u,ue as v,ce as x,le as y};
@@ -1 +1 @@
1
- import{M as e}from"./useSubAccountSwitcher-Bg0RH3Gk.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
1
+ import{M as e}from"./useSubAccountSwitcher-DGKQxXDD.js";var t=e();function n({checked:e,onChange:n,label:r,disabled:i}){return(0,t.jsxs)(`label`,{className:`maxy-checkbox${i?` maxy-checkbox--disabled`:``}`,children:[(0,t.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>n(e.target.checked),disabled:i}),(0,t.jsx)(`span`,{className:`maxy-checkbox__box`,children:`✱`}),r&&(0,t.jsx)(`span`,{className:`maxy-checkbox__label`,children:r})]})}export{n as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-render-m08Xm2Nm.js","assets/preload-helper-CvXuAEud.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./chunk-CAM3fms7.js";import{D as t,L as n,M as r,m as i,w as a}from"./useSubAccountSwitcher-Bg0RH3Gk.js";import{t as o}from"./maximize-2-DWmyXX8h.js";import{t as s}from"./preload-helper-CvXuAEud.js";var c=t(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),l=e(n(),1),u=r();function d({children:e,tail:t=null,repinSignals:n}){let r=(0,l.useRef)(null),i=(0,l.useRef)(null),a=(0,l.useRef)(!0),[o,s]=(0,l.useState)(!0),c=(0,l.useRef)(0),d=(0,l.useRef)(0),f=()=>{let e=r.current;if(!e)return;let t=e.clientHeight,n=e.scrollHeight,i=t!==c.current||n!==d.current;if(c.current=t,d.current=n,i){a.current&&(e.scrollTop=e.scrollHeight);return}let o=n-e.scrollTop-t<=32;a.current=o,s(e=>e===o?e:o)},p=()=>{let e=r.current;e&&(e.scrollTop=e.scrollHeight,d.current=e.scrollHeight,c.current=e.clientHeight,a.current=!0,s(!0))},m=t!=null;return(0,l.useLayoutEffect)(()=>{let e=r.current;e&&a.current&&(e.scrollTop=e.scrollHeight),e&&(d.current=e.scrollHeight,c.current=e.clientHeight)},[...n,m]),(0,l.useLayoutEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>f());return r.current&&e.observe(r.current),i.current&&e.observe(i.current),()=>e.disconnect()},[]),(0,u.jsxs)(`div`,{className:`wa-reader`,children:[(0,u.jsx)(`div`,{className:`wa-reader-thread`,ref:r,onScroll:f,children:(0,u.jsxs)(`div`,{className:`wa-thread-scroll`,ref:i,children:[e,t]})}),!o&&(0,u.jsx)(`button`,{type:`button`,className:`wa-jump`,onClick:p,"aria-label":`Jump to latest message`,title:`Jump to latest message`,children:`↓`})]})}var f={auth_expired:`Your session has expired. Please sign in again.`,claude_down:`Claude is currently experiencing an outage. Please try again in a few minutes.`,claude_overloaded:`Claude is overloaded right now. Please try again shortly.`,model_unavailable:`The selected model is currently unavailable. Switch to a different model from the model picker to continue.`,agent_error:`Something went wrong. Please try again.`},p={auth_expired:`I'm not available right now. Please try again later.`,claude_down:`I'm not available right now. Please try again later.`,claude_overloaded:`I'm not available right now. Please try again shortly.`,model_unavailable:`I'm not available right now. Please try again later.`,agent_error:`I'm not available right now. Please try again later.`};function m(e,t=`admin`){return t===`public`?p[e]:f[e]}function h(e){return e===`whatsapp`?` · via WhatsApp`:e===`webchat`?` · via web`:``}var g=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,_=/\.pdf$/i;function v(e,t){return(t?t.startsWith(`image/`):g.test(e))?`image`:t&&t.startsWith(`audio/`)?`audio`:(t?t===`application/pdf`:_.test(e))?`pdf`:`file`}function y(e,t,n,r){let i=encodeURIComponent(e.path),a=encodeURIComponent(n),o=r?`&disposition=${r}`:``;return e.root===`scratchpad`?`/api/admin/files/download?path=${i}&root=scratchpad&sessionId=${encodeURIComponent(t)}&session_key=${a}${o}`:`/api/admin/files/download?path=${i}&root=data&session_key=${a}${o}`}function b(e,t,n,r){return t===`public`?`/api/public-reader/attachment/${e}?sessionId=${encodeURIComponent(n)}`:`/api/admin/attachment/${e}?session_key=${encodeURIComponent(r)}`}function x(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)} KB`;let n=t/1024;return`${n<10?n.toFixed(1):Math.round(n)} MB`}function S({href:e,filename:t,label:n}){return(0,u.jsxs)(`a`,{className:`chat-attachment-chip`,href:e,download:t,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0}),n]})}function C({href:e,filename:t,className:n,size:r=14,onClick:i}){return(0,u.jsx)(`a`,{className:n,href:e,download:t,"aria-label":`Download ${t}`,onClick:i,children:(0,u.jsx)(a,{size:r,"aria-hidden":!0})})}function w({src:e,filename:t,sizeBytes:n,expandable:r,onFail:i}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),d=n==null?t:`${t} · ${x(n)}`;return s?(0,u.jsx)(S,{href:e,filename:t,label:d}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:`chat-attachment-image-wrap`,children:[(0,u.jsx)(`img`,{className:`chat-attachment-image`,src:e,alt:t,onClick:r?()=>o(!0):void 0,onError:()=>{c(!0),i?.(`fetch`)}}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-download`})]}),r&&a&&(0,u.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":t,onClick:()=>o(!1),children:(0,u.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:e,alt:t})})]})}var T=280,E=360,D=16;function O({src:e,filename:t,sizeBytes:n,onFail:r}){let[i,a]=(0,l.useState)(!1),[c,d]=(0,l.useState)(!1),f=(0,l.useRef)(null),p=n==null?t:`${t} · ${x(n)}`;return(0,l.useEffect)(()=>{let t=!1,n=null;return(async()=>{try{let{loadPdf:r,renderPageToFit:i}=await s(async()=>{let{loadPdf:e,renderPageToFit:t}=await import(`./pdf-render-m08Xm2Nm.js`);return{loadPdf:e,renderPageToFit:t}},__vite__mapDeps([0,1])),a=await r(e);n=a;let o=f.current;if(t||!o)return;await i(a,1,o,T,E)}catch{t||(d(!0),r?.(`render`))}})(),()=>{t=!0;try{n?.destroy()}catch{}}},[e]),c?(0,u.jsx)(S,{href:e,filename:t,label:p}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`chat-attachment-pdf`,children:[(0,u.jsx)(`canvas`,{ref:f,className:`chat-attachment-pdf-canvas`,"aria-label":t}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-download`}),(0,u.jsx)(`button`,{type:`button`,className:`chat-attachment-pdf-expand`,"aria-label":`Expand ${t}`,onClick:()=>a(!0),children:(0,u.jsx)(o,{size:14,"aria-hidden":!0})})]}),i&&(0,u.jsx)(k,{src:e,filename:t,label:p,onClose:()=>a(!1),onFail:r})]})}function k({src:e,filename:t,label:n,onClose:r,onFail:a}){let o=(0,l.useRef)(null),c=(0,l.useRef)(null),[d,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let t=!1;return(async()=>{try{let{loadPdf:n}=await s(async()=>{let{loadPdf:e}=await import(`./pdf-render-m08Xm2Nm.js`);return{loadPdf:e}},__vite__mapDeps([0,1])),r=await n(e);if(t){try{r.destroy()}catch{}return}c.current=r,f(r.numPages)}catch{t||(m(!0),a?.(`render`))}})(),()=>{t=!0;try{c.current?.destroy()}catch{}}},[e]),(0,l.useEffect)(()=>{if(d==null)return;let e=o.current,t=c.current;if(!e||!t)return;let n=!1;return(async()=>{try{let{renderPageToWidth:r}=await s(async()=>{let{renderPageToWidth:e}=await import(`./pdf-render-m08Xm2Nm.js`);return{renderPageToWidth:e}},__vite__mapDeps([0,1])),i=Array.from(e.querySelectorAll(`canvas.chat-attachment-overlay-page`)),a=Math.max(e.clientWidth-D*2,1);for(let e=0;e<i.length;e++){if(n)return;await r(t,e+1,i[e],a)}}catch{n||(m(!0),a?.(`render`))}})(),()=>{n=!0}},[d]),(0,u.jsxs)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":t,onClick:r,children:[(0,u.jsx)(`div`,{ref:o,className:`chat-attachment-overlay-pdf`,onClick:e=>e.stopPropagation(),children:p?(0,u.jsx)(S,{href:e,filename:t,label:n}):Array.from({length:d??0},(e,n)=>(0,u.jsx)(`canvas`,{className:`chat-attachment-overlay-page`,"aria-label":`${t} page ${n+1}`},n))}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-overlay-download`,size:20,onClick:e=>e.stopPropagation()}),(0,u.jsx)(`button`,{type:`button`,className:`chat-attachment-overlay-close`,"aria-label":`Close`,onClick:r,children:(0,u.jsx)(i,{size:20,"aria-hidden":!0})})]})}function A({filename:e,href:t,mimeType:n,sizeBytes:r,expandable:i,telemetry:a}){let o=v(e,n);(0,l.useEffect)(()=>{a?.onRender?.({kind:o,mime:n,served:!!t})},[]);let s=a?.onFail?e=>a.onFail({kind:o===`pdf`?`pdf`:`image`,mime:n,reason:e}):void 0;if(o===`image`&&t)return(0,u.jsx)(w,{src:t,filename:e,sizeBytes:r,expandable:i,onFail:s});if(o===`audio`&&t)return(0,u.jsx)(`audio`,{className:`chat-attachment-audio`,controls:!0,preload:`metadata`,src:t});if(o===`pdf`&&t)return(0,u.jsx)(O,{src:t,filename:e,sizeBytes:r,onFail:s});let d=r==null?e:`${e} · ${x(r)}`;return t?(0,u.jsx)(S,{href:t,filename:e,label:d}):(0,u.jsxs)(`p`,{className:`chat-doc`,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,d]})}function j(e,t,n,r=`/api/whatsapp-reader/stream`,i=e,a=!0){let[o,s]=(0,l.useState)([]),[c,u]=(0,l.useState)(`open`),[d,f]=(0,l.useState)(null),p=(0,l.useRef)([]);return(0,l.useEffect)(()=>{p.current=o},[o]),(0,l.useEffect)(()=>{s([]),p.current=[],f(null)},[i,t,n,r]),(0,l.useEffect)(()=>{if(u(`open`),!a)return;let i=p.current.slice(),o=i.map(M),c=0,l=i.length>0,d=`${r}?sessionId=${encodeURIComponent(e)}&projectDir=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,m=new EventSource(d);return m.onopen=()=>{console.info(`[admin-ui] wa-stream onopen sessionId=${e}`),u(`open`)},m.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(l){if(c<o.length&&M(t)===o[c]){c+=1;return}l=!1}s(e=>[...e,t])},m.addEventListener(`activity`,e=>{try{f(JSON.parse(e.data))}catch{}}),m.addEventListener(`activity-clear`,()=>f(null)),m.onerror=()=>{m.readyState===2&&(console.error(`[admin-ui] wa-stream onerror readyState=${m.readyState}`),u(`error`))},()=>m.close()},[e,t,n,r,i,a]),{turns:o,status:c,subagentActivity:d}}function M(e){return JSON.stringify(e)}function N(e,t,n,r=!0){let[i,a]=(0,l.useState)([]),[o,s]=(0,l.useState)(`open`);return(0,l.useEffect)(()=>{if(a([]),s(`open`),!r||!e||!t)return;let i=`/api/whatsapp-reader/store-stream?accountId=${encodeURIComponent(e)}&remoteJid=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,o=new EventSource(i);return o.onopen=()=>s(`open`),o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}a(e=>[...e,t])},o.onerror=()=>{o.readyState===2&&s(`error`)},()=>o.close()},[e,t,n,r]),{turns:i,status:o}}var P=e=>{if(!e)return 1/0;let t=new Date(e).getTime();return Number.isNaN(t)?1/0:t};function F(e,t){let n=[],r=0;return e.forEach((e,t)=>n.push({sort:P(e.ts),sub:1,ins:r++,item:{kind:`turn`,turn:e,idx:t}})),t.forEach(e=>n.push({sort:P(e.ts),sub:0,ins:r++,item:{kind:`directive`,entry:e}})),n.sort((e,t)=>e.sort===t.sort?e.sort===1/0?e.ins-t.ins:e.sub-t.sub||e.ins-t.ins:e.sort<t.sort?-1:1).map(e=>e.item)}function I(e,t,n=!0){let[r,i]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!n||typeof fetch!=`function`)return;let r=!0,a=`/api/whatsapp-reader/directives?sessionId=${encodeURIComponent(e)}&session_key=${encodeURIComponent(t)}`;return fetch(a).then(e=>e.ok?e.json():{entries:[]}).then(e=>{r&&i(Array.isArray(e.entries)?e.entries:[])}).catch(()=>{r&&i([])}),()=>{r=!1}},[e,t,n]),r}var L=new Set([`operator-inbound`,`operator-typed`,`agent-reply`,`agent-reply-document`,`agent-file`,`agent-error`,`whatsapp-persisted`]);function R(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function z(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}var B=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],V=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function H(e){let t=String(e.getMonth()+1).padStart(2,`0`),n=String(e.getDate()).padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}function U(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:H(t)}function W(e,t=new Date){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=H(n);if(r===H(t))return`Today`;let i=new Date(t);return i.setDate(i.getDate()-1),r===H(i)?`Yesterday`:`${B[n.getDay()]} ${n.getDate()} ${V[n.getMonth()]} ${n.getFullYear()}`}function G(e){return e.kind===`turn`?e.turn.ts:e.entry.ts}function K({ts:e}){return(0,u.jsx)(`div`,{className:`day-divider`,role:`separator`,children:(0,u.jsx)(`span`,{className:`day-divider-label`,children:W(e)})})}function q(){return(0,u.jsx)(`div`,{className:`session-divider`,role:`separator`,children:(0,u.jsx)(`span`,{className:`session-divider-label`,children:`Conversation continued`})})}function J({label:e,ts:t}){return(0,u.jsxs)(`div`,{className:`wa-turn-head`,children:[(0,u.jsx)(`span`,{className:`wa-who`,children:e}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(t)})]})}function Y({turn:e}){let[t,n]=(0,l.useState)(!1),r=e.kind===`tool-result`,i=r?`wa-turn wa-turn-result${e.isError?` is-error`:``}`:`wa-turn wa-turn-tool`,a=r?e.isError?`result (error)`:`result`:`↳ ${e.name}`,o=r?e.text:JSON.stringify(e.input,null,2);return(0,u.jsxs)(`div`,{className:i,children:[(0,u.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,u.jsx)(`span`,{className:`wa-chevron`,children:t?`▾`:`▸`}),(0,u.jsx)(`span`,{className:`wa-who`,children:a}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(e.ts)})]}),t&&(0,u.jsx)(`pre`,{className:`wa-code`,children:o})]})}function X({entry:e,sessionId:t,sessionKey:n}){let[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(null),s=()=>{let s=!r;if(i(s),s&&a===null&&typeof fetch==`function`){let r=`/api/whatsapp-reader/directive?sessionId=${encodeURIComponent(t)}&name=${encodeURIComponent(e.name)}&session_key=${encodeURIComponent(n)}`;fetch(r).then(e=>e.ok?e.text():`(directive unavailable)`).then(o).catch(()=>o(`(directive unavailable)`))}};return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-directive`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":r,onClick:s,children:[(0,u.jsx)(`span`,{className:`wa-chevron`,children:r?`▾`:`▸`}),(0,u.jsxs)(`span`,{className:`wa-who`,children:[`⚙ directive injected (`,e.len,` B)`]}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(e.ts)})]}),r&&(0,u.jsx)(`pre`,{className:`wa-code`,children:a??`Loading…`})]})}var Z={onRender:({kind:e,mime:t,served:n})=>console.info(`[operator-ui] op=reader-attachment kind=${e} mime=${t??``} served=${n}`),onFail:({kind:e,mime:t,reason:n})=>console.info(`[operator-ui] op=reader-attachment-fail kind=${e} mime=${t??``} reason=${n}`)};function Q(e,t,n){switch(e.kind){case`operator-inbound`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-in`,children:[(0,u.jsx)(J,{label:`Operator${h(e.source)}`,ts:e.ts}),e.text&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.text}),e.attachments&&e.attachments.length>0&&(0,u.jsx)(`div`,{className:`chat-attachment-list`,children:e.attachments.map((e,t)=>(0,u.jsx)(A,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:b(e.attachmentId,n.audience,n.sessionId,n.sessionKey),telemetry:Z},t))})]},t);case`operator-typed`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-in wa-turn-typed`,children:[(0,u.jsx)(J,{label:`Operator (web)`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-text`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-think`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply-document`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsxs)(`p`,{className:`wa-doc`,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,`sent document(s): `,e.files.map(z).join(`, `)]}),e.caption&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`agent-file`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),e.files.map((t,r)=>{let i=z(t),a=e.downloads?.[r];return(0,u.jsx)(A,{expandable:!0,filename:i,href:a?y(a,n.sessionId,n.sessionKey,_.test(i)?`inline`:void 0):void 0,telemetry:Z},r)}),e.caption&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`whatsapp-persisted`:return(0,u.jsxs)(`div`,{className:`wa-turn ${e.fromMe?`wa-turn-out`:`wa-turn-in`}`,children:[(0,u.jsx)(J,{label:e.fromMe?`Sent`:e.senderName??`Contact`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`session-continued`:return(0,u.jsx)(q,{},t);case`tool-call`:case`tool-result`:return(0,u.jsx)(Y,{turn:e},t);case`agent-error`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-error`,role:`alert`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body wa-error-body`,children:m(e.code,`admin`)}),e.code===`agent_error`&&e.raw&&(0,u.jsx)(`pre`,{className:`wa-code`,children:e.raw})]},t)}}function $(e,t,n,r=`admin`){let i={sessionId:t,sessionKey:n,audience:r},a=[],o=null;return e.forEach((e,r)=>{let s=G(e),c=U(s);c!==null&&c!==o&&(a.push((0,u.jsx)(K,{ts:s},`day-${r}`)),o=c),a.push(e.kind===`turn`?Q(e.turn,r,i):(0,u.jsx)(X,{entry:e.entry,sessionId:t,sessionKey:n},r))}),a}function ee(e){return e.filter(e=>e.kind===`turn`&&L.has(e.turn.kind))}function te({sessionId:e,projectDir:t,sessionKey:n,renderItems:r=$,clean:i,onToggleClean:a,forceDeliveredOnly:o=!1,streamEndpoint:s=`/api/whatsapp-reader/stream`,suppressDirectives:c=!1,tail:f=null,resetKey:p,onTurnsChange:m,onActivityChange:h,store:g}){let _=!!g,v=j(e,t,n,s,p,!_),y=N(g?.accountId??``,g?.remoteJid??``,n,_),{turns:b,status:x}=_?{turns:y.turns,status:y.status}:{turns:v.turns,status:v.status},S=_?null:v.subagentActivity;(0,l.useEffect)(()=>{h?.(S)},[S,h]),(0,l.useEffect)(()=>{m?.(b.length)},[b.length,m]);let C=F(b,I(e,n,!c)),w=a==null?!1:!!i,T=o||w?ee(C):C;return(0,u.jsxs)(d,{repinSignals:[b,w],tail:f,children:[x===`error`&&(0,u.jsx)(`div`,{className:`wa-reader-error`,children:`Stream disconnected.`}),b.length===0&&x===`open`&&(0,u.jsx)(`div`,{className:`wa-reader-placeholder`,children:`No messages in this conversation yet.`}),r(T,e,n)]})}export{c as _,z as a,G as c,g as d,_ as f,m as g,h,te as i,A as l,y as m,X as n,U as o,b as p,q as r,R as s,K as t,O as u};
2
+ import{o as e}from"./chunk-CAM3fms7.js";import{D as t,L as n,M as r,m as i,w as a}from"./useSubAccountSwitcher-DGKQxXDD.js";import{t as o}from"./maximize-2-CyPKq7HZ.js";import{t as s}from"./preload-helper-CvXuAEud.js";var c=t(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),l=e(n(),1),u=r();function d({children:e,tail:t=null,repinSignals:n}){let r=(0,l.useRef)(null),i=(0,l.useRef)(null),a=(0,l.useRef)(!0),[o,s]=(0,l.useState)(!0),c=(0,l.useRef)(0),d=(0,l.useRef)(0),f=()=>{let e=r.current;if(!e)return;let t=e.clientHeight,n=e.scrollHeight,i=t!==c.current||n!==d.current;if(c.current=t,d.current=n,i){a.current&&(e.scrollTop=e.scrollHeight);return}let o=n-e.scrollTop-t<=32;a.current=o,s(e=>e===o?e:o)},p=()=>{let e=r.current;e&&(e.scrollTop=e.scrollHeight,d.current=e.scrollHeight,c.current=e.clientHeight,a.current=!0,s(!0))},m=t!=null;return(0,l.useLayoutEffect)(()=>{let e=r.current;e&&a.current&&(e.scrollTop=e.scrollHeight),e&&(d.current=e.scrollHeight,c.current=e.clientHeight)},[...n,m]),(0,l.useLayoutEffect)(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>f());return r.current&&e.observe(r.current),i.current&&e.observe(i.current),()=>e.disconnect()},[]),(0,u.jsxs)(`div`,{className:`wa-reader`,children:[(0,u.jsx)(`div`,{className:`wa-reader-thread`,ref:r,onScroll:f,children:(0,u.jsxs)(`div`,{className:`wa-thread-scroll`,ref:i,children:[e,t]})}),!o&&(0,u.jsx)(`button`,{type:`button`,className:`wa-jump`,onClick:p,"aria-label":`Jump to latest message`,title:`Jump to latest message`,children:`↓`})]})}var f={auth_expired:`Your session has expired. Please sign in again.`,claude_down:`Claude is currently experiencing an outage. Please try again in a few minutes.`,claude_overloaded:`Claude is overloaded right now. Please try again shortly.`,model_unavailable:`The selected model is currently unavailable. Switch to a different model from the model picker to continue.`,agent_error:`Something went wrong. Please try again.`},p={auth_expired:`I'm not available right now. Please try again later.`,claude_down:`I'm not available right now. Please try again later.`,claude_overloaded:`I'm not available right now. Please try again shortly.`,model_unavailable:`I'm not available right now. Please try again later.`,agent_error:`I'm not available right now. Please try again later.`};function m(e,t=`admin`){return t===`public`?p[e]:f[e]}function h(e){return e===`whatsapp`?` · via WhatsApp`:e===`webchat`?` · via web`:``}var g=/\.(png|jpe?g|gif|webp|svg|bmp)$/i,_=/\.pdf$/i;function v(e,t){return(t?t.startsWith(`image/`):g.test(e))?`image`:t&&t.startsWith(`audio/`)?`audio`:(t?t===`application/pdf`:_.test(e))?`pdf`:`file`}function y(e,t,n,r){let i=encodeURIComponent(e.path),a=encodeURIComponent(n),o=r?`&disposition=${r}`:``;return e.root===`scratchpad`?`/api/admin/files/download?path=${i}&root=scratchpad&sessionId=${encodeURIComponent(t)}&session_key=${a}${o}`:`/api/admin/files/download?path=${i}&root=data&session_key=${a}${o}`}function b(e,t,n,r){return t===`public`?`/api/public-reader/attachment/${e}?sessionId=${encodeURIComponent(n)}`:`/api/admin/attachment/${e}?session_key=${encodeURIComponent(r)}`}function x(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t<10?t.toFixed(1):Math.round(t)} KB`;let n=t/1024;return`${n<10?n.toFixed(1):Math.round(n)} MB`}function S({href:e,filename:t,label:n}){return(0,u.jsxs)(`a`,{className:`chat-attachment-chip`,href:e,download:t,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0}),n]})}function C({href:e,filename:t,className:n,size:r=14,onClick:i}){return(0,u.jsx)(`a`,{className:n,href:e,download:t,"aria-label":`Download ${t}`,onClick:i,children:(0,u.jsx)(a,{size:r,"aria-hidden":!0})})}function w({src:e,filename:t,sizeBytes:n,expandable:r,onFail:i}){let[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),d=n==null?t:`${t} · ${x(n)}`;return s?(0,u.jsx)(S,{href:e,filename:t,label:d}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`span`,{className:`chat-attachment-image-wrap`,children:[(0,u.jsx)(`img`,{className:`chat-attachment-image`,src:e,alt:t,onClick:r?()=>o(!0):void 0,onError:()=>{c(!0),i?.(`fetch`)}}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-download`})]}),r&&a&&(0,u.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":t,onClick:()=>o(!1),children:(0,u.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:e,alt:t})})]})}var T=280,E=360,D=16;function O({src:e,filename:t,sizeBytes:n,onFail:r}){let[i,a]=(0,l.useState)(!1),[c,d]=(0,l.useState)(!1),f=(0,l.useRef)(null),p=n==null?t:`${t} · ${x(n)}`;return(0,l.useEffect)(()=>{let t=!1,n=null;return(async()=>{try{let{loadPdf:r,renderPageToFit:i}=await s(async()=>{let{loadPdf:e,renderPageToFit:t}=await import(`./pdf-render-m08Xm2Nm.js`);return{loadPdf:e,renderPageToFit:t}},__vite__mapDeps([0,1])),a=await r(e);n=a;let o=f.current;if(t||!o)return;await i(a,1,o,T,E)}catch{t||(d(!0),r?.(`render`))}})(),()=>{t=!0;try{n?.destroy()}catch{}}},[e]),c?(0,u.jsx)(S,{href:e,filename:t,label:p}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`chat-attachment-pdf`,children:[(0,u.jsx)(`canvas`,{ref:f,className:`chat-attachment-pdf-canvas`,"aria-label":t}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-download`}),(0,u.jsx)(`button`,{type:`button`,className:`chat-attachment-pdf-expand`,"aria-label":`Expand ${t}`,onClick:()=>a(!0),children:(0,u.jsx)(o,{size:14,"aria-hidden":!0})})]}),i&&(0,u.jsx)(k,{src:e,filename:t,label:p,onClose:()=>a(!1),onFail:r})]})}function k({src:e,filename:t,label:n,onClose:r,onFail:a}){let o=(0,l.useRef)(null),c=(0,l.useRef)(null),[d,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let t=!1;return(async()=>{try{let{loadPdf:n}=await s(async()=>{let{loadPdf:e}=await import(`./pdf-render-m08Xm2Nm.js`);return{loadPdf:e}},__vite__mapDeps([0,1])),r=await n(e);if(t){try{r.destroy()}catch{}return}c.current=r,f(r.numPages)}catch{t||(m(!0),a?.(`render`))}})(),()=>{t=!0;try{c.current?.destroy()}catch{}}},[e]),(0,l.useEffect)(()=>{if(d==null)return;let e=o.current,t=c.current;if(!e||!t)return;let n=!1;return(async()=>{try{let{renderPageToWidth:r}=await s(async()=>{let{renderPageToWidth:e}=await import(`./pdf-render-m08Xm2Nm.js`);return{renderPageToWidth:e}},__vite__mapDeps([0,1])),i=Array.from(e.querySelectorAll(`canvas.chat-attachment-overlay-page`)),a=Math.max(e.clientWidth-D*2,1);for(let e=0;e<i.length;e++){if(n)return;await r(t,e+1,i[e],a)}}catch{n||(m(!0),a?.(`render`))}})(),()=>{n=!0}},[d]),(0,u.jsxs)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":t,onClick:r,children:[(0,u.jsx)(`div`,{ref:o,className:`chat-attachment-overlay-pdf`,onClick:e=>e.stopPropagation(),children:p?(0,u.jsx)(S,{href:e,filename:t,label:n}):Array.from({length:d??0},(e,n)=>(0,u.jsx)(`canvas`,{className:`chat-attachment-overlay-page`,"aria-label":`${t} page ${n+1}`},n))}),(0,u.jsx)(C,{href:e,filename:t,className:`chat-attachment-overlay-download`,size:20,onClick:e=>e.stopPropagation()}),(0,u.jsx)(`button`,{type:`button`,className:`chat-attachment-overlay-close`,"aria-label":`Close`,onClick:r,children:(0,u.jsx)(i,{size:20,"aria-hidden":!0})})]})}function A({filename:e,href:t,mimeType:n,sizeBytes:r,expandable:i,telemetry:a}){let o=v(e,n);(0,l.useEffect)(()=>{a?.onRender?.({kind:o,mime:n,served:!!t})},[]);let s=a?.onFail?e=>a.onFail({kind:o===`pdf`?`pdf`:`image`,mime:n,reason:e}):void 0;if(o===`image`&&t)return(0,u.jsx)(w,{src:t,filename:e,sizeBytes:r,expandable:i,onFail:s});if(o===`audio`&&t)return(0,u.jsx)(`audio`,{className:`chat-attachment-audio`,controls:!0,preload:`metadata`,src:t});if(o===`pdf`&&t)return(0,u.jsx)(O,{src:t,filename:e,sizeBytes:r,onFail:s});let d=r==null?e:`${e} · ${x(r)}`;return t?(0,u.jsx)(S,{href:t,filename:e,label:d}):(0,u.jsxs)(`p`,{className:`chat-doc`,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,d]})}function j(e,t,n,r=`/api/whatsapp-reader/stream`,i=e,a=!0){let[o,s]=(0,l.useState)([]),[c,u]=(0,l.useState)(`open`),[d,f]=(0,l.useState)(null),p=(0,l.useRef)([]);return(0,l.useEffect)(()=>{p.current=o},[o]),(0,l.useEffect)(()=>{s([]),p.current=[],f(null)},[i,t,n,r]),(0,l.useEffect)(()=>{if(u(`open`),!a)return;let i=p.current.slice(),o=i.map(M),c=0,l=i.length>0,d=`${r}?sessionId=${encodeURIComponent(e)}&projectDir=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,m=new EventSource(d);return m.onopen=()=>{console.info(`[admin-ui] wa-stream onopen sessionId=${e}`),u(`open`)},m.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(l){if(c<o.length&&M(t)===o[c]){c+=1;return}l=!1}s(e=>[...e,t])},m.addEventListener(`activity`,e=>{try{f(JSON.parse(e.data))}catch{}}),m.addEventListener(`activity-clear`,()=>f(null)),m.onerror=()=>{m.readyState===2&&(console.error(`[admin-ui] wa-stream onerror readyState=${m.readyState}`),u(`error`))},()=>m.close()},[e,t,n,r,i,a]),{turns:o,status:c,subagentActivity:d}}function M(e){return JSON.stringify(e)}function N(e,t,n,r=!0){let[i,a]=(0,l.useState)([]),[o,s]=(0,l.useState)(`open`);return(0,l.useEffect)(()=>{if(a([]),s(`open`),!r||!e||!t)return;let i=`/api/whatsapp-reader/store-stream?accountId=${encodeURIComponent(e)}&remoteJid=${encodeURIComponent(t)}&session_key=${encodeURIComponent(n)}`,o=new EventSource(i);return o.onopen=()=>s(`open`),o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}a(e=>[...e,t])},o.onerror=()=>{o.readyState===2&&s(`error`)},()=>o.close()},[e,t,n,r]),{turns:i,status:o}}var P=e=>{if(!e)return 1/0;let t=new Date(e).getTime();return Number.isNaN(t)?1/0:t};function F(e,t){let n=[],r=0;return e.forEach((e,t)=>n.push({sort:P(e.ts),sub:1,ins:r++,item:{kind:`turn`,turn:e,idx:t}})),t.forEach(e=>n.push({sort:P(e.ts),sub:0,ins:r++,item:{kind:`directive`,entry:e}})),n.sort((e,t)=>e.sort===t.sort?e.sort===1/0?e.ins-t.ins:e.sub-t.sub||e.ins-t.ins:e.sort<t.sort?-1:1).map(e=>e.item)}function I(e,t,n=!0){let[r,i]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!n||typeof fetch!=`function`)return;let r=!0,a=`/api/whatsapp-reader/directives?sessionId=${encodeURIComponent(e)}&session_key=${encodeURIComponent(t)}`;return fetch(a).then(e=>e.ok?e.json():{entries:[]}).then(e=>{r&&i(Array.isArray(e.entries)?e.entries:[])}).catch(()=>{r&&i([])}),()=>{r=!1}},[e,t,n]),r}var L=new Set([`operator-inbound`,`operator-typed`,`agent-reply`,`agent-reply-document`,`agent-file`,`agent-error`,`whatsapp-persisted`]);function R(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function z(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}var B=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],V=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function H(e){let t=String(e.getMonth()+1).padStart(2,`0`),n=String(e.getDate()).padStart(2,`0`);return`${e.getFullYear()}-${t}-${n}`}function U(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:H(t)}function W(e,t=new Date){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=H(n);if(r===H(t))return`Today`;let i=new Date(t);return i.setDate(i.getDate()-1),r===H(i)?`Yesterday`:`${B[n.getDay()]} ${n.getDate()} ${V[n.getMonth()]} ${n.getFullYear()}`}function G(e){return e.kind===`turn`?e.turn.ts:e.entry.ts}function K({ts:e}){return(0,u.jsx)(`div`,{className:`day-divider`,role:`separator`,children:(0,u.jsx)(`span`,{className:`day-divider-label`,children:W(e)})})}function q(){return(0,u.jsx)(`div`,{className:`session-divider`,role:`separator`,children:(0,u.jsx)(`span`,{className:`session-divider-label`,children:`Conversation continued`})})}function J({label:e,ts:t}){return(0,u.jsxs)(`div`,{className:`wa-turn-head`,children:[(0,u.jsx)(`span`,{className:`wa-who`,children:e}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(t)})]})}function Y({turn:e}){let[t,n]=(0,l.useState)(!1),r=e.kind===`tool-result`,i=r?`wa-turn wa-turn-result${e.isError?` is-error`:``}`:`wa-turn wa-turn-tool`,a=r?e.isError?`result (error)`:`result`:`↳ ${e.name}`,o=r?e.text:JSON.stringify(e.input,null,2);return(0,u.jsxs)(`div`,{className:i,children:[(0,u.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,u.jsx)(`span`,{className:`wa-chevron`,children:t?`▾`:`▸`}),(0,u.jsx)(`span`,{className:`wa-who`,children:a}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(e.ts)})]}),t&&(0,u.jsx)(`pre`,{className:`wa-code`,children:o})]})}function X({entry:e,sessionId:t,sessionKey:n}){let[r,i]=(0,l.useState)(!1),[a,o]=(0,l.useState)(null),s=()=>{let s=!r;if(i(s),s&&a===null&&typeof fetch==`function`){let r=`/api/whatsapp-reader/directive?sessionId=${encodeURIComponent(t)}&name=${encodeURIComponent(e.name)}&session_key=${encodeURIComponent(n)}`;fetch(r).then(e=>e.ok?e.text():`(directive unavailable)`).then(o).catch(()=>o(`(directive unavailable)`))}};return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-directive`,children:[(0,u.jsxs)(`button`,{type:`button`,className:`wa-tool-toggle`,"aria-expanded":r,onClick:s,children:[(0,u.jsx)(`span`,{className:`wa-chevron`,children:r?`▾`:`▸`}),(0,u.jsxs)(`span`,{className:`wa-who`,children:[`⚙ directive injected (`,e.len,` B)`]}),(0,u.jsx)(`time`,{className:`wa-time`,children:R(e.ts)})]}),r&&(0,u.jsx)(`pre`,{className:`wa-code`,children:a??`Loading…`})]})}var Z={onRender:({kind:e,mime:t,served:n})=>console.info(`[operator-ui] op=reader-attachment kind=${e} mime=${t??``} served=${n}`),onFail:({kind:e,mime:t,reason:n})=>console.info(`[operator-ui] op=reader-attachment-fail kind=${e} mime=${t??``} reason=${n}`)};function Q(e,t,n){switch(e.kind){case`operator-inbound`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-in`,children:[(0,u.jsx)(J,{label:`Operator${h(e.source)}`,ts:e.ts}),e.text&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.text}),e.attachments&&e.attachments.length>0&&(0,u.jsx)(`div`,{className:`chat-attachment-list`,children:e.attachments.map((e,t)=>(0,u.jsx)(A,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:b(e.attachmentId,n.audience,n.sessionId,n.sessionKey),telemetry:Z},t))})]},t);case`operator-typed`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-in wa-turn-typed`,children:[(0,u.jsx)(J,{label:`Operator (web)`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-text`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-think`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`agent-reply-document`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsxs)(`p`,{className:`wa-doc`,children:[(0,u.jsx)(c,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,`sent document(s): `,e.files.map(z).join(`, `)]}),e.caption&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`agent-file`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-out`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),e.files.map((t,r)=>{let i=z(t),a=e.downloads?.[r];return(0,u.jsx)(A,{expandable:!0,filename:i,href:a?y(a,n.sessionId,n.sessionKey,_.test(i)?`inline`:void 0):void 0,telemetry:Z},r)}),e.caption&&(0,u.jsx)(`p`,{className:`wa-body`,children:e.caption})]},t);case`whatsapp-persisted`:return(0,u.jsxs)(`div`,{className:`wa-turn ${e.fromMe?`wa-turn-out`:`wa-turn-in`}`,children:[(0,u.jsx)(J,{label:e.fromMe?`Sent`:e.senderName??`Contact`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body`,children:e.text})]},t);case`session-continued`:return(0,u.jsx)(q,{},t);case`harness-internal`:return null;case`tool-call`:case`tool-result`:return(0,u.jsx)(Y,{turn:e},t);case`agent-error`:return(0,u.jsxs)(`div`,{className:`wa-turn wa-turn-error`,role:`alert`,children:[(0,u.jsx)(J,{label:`Agent`,ts:e.ts}),(0,u.jsx)(`p`,{className:`wa-body wa-error-body`,children:m(e.code,`admin`)}),e.code===`agent_error`&&e.raw&&(0,u.jsx)(`pre`,{className:`wa-code`,children:e.raw})]},t)}}function $(e,t,n,r=`admin`){let i={sessionId:t,sessionKey:n,audience:r},a=[],o=null;return e.forEach((e,r)=>{let s=G(e),c=U(s);c!==null&&c!==o&&(a.push((0,u.jsx)(K,{ts:s},`day-${r}`)),o=c),a.push(e.kind===`turn`?Q(e.turn,r,i):(0,u.jsx)(X,{entry:e.entry,sessionId:t,sessionKey:n},r))}),a}function ee(e){return e.filter(e=>e.kind===`turn`&&L.has(e.turn.kind))}function te({sessionId:e,projectDir:t,sessionKey:n,renderItems:r=$,clean:i,onToggleClean:a,forceDeliveredOnly:o=!1,streamEndpoint:s=`/api/whatsapp-reader/stream`,suppressDirectives:c=!1,tail:f=null,resetKey:p,onTurnsChange:m,onActivityChange:h,store:g}){let _=!!g,v=j(e,t,n,s,p,!_),y=N(g?.accountId??``,g?.remoteJid??``,n,_),{turns:b,status:x}=_?{turns:y.turns,status:y.status}:{turns:v.turns,status:v.status},S=_?null:v.subagentActivity;(0,l.useEffect)(()=>{h?.(S)},[S,h]),(0,l.useEffect)(()=>{m?.(b.length)},[b.length,m]);let C=F(b,I(e,n,!c)),w=a==null?!1:!!i,T=o||w?ee(C):C;return(0,u.jsxs)(d,{repinSignals:[b,w],tail:f,children:[x===`error`&&(0,u.jsx)(`div`,{className:`wa-reader-error`,children:`Stream disconnected.`}),b.length===0&&x===`open`&&(0,u.jsx)(`div`,{className:`wa-reader-placeholder`,children:`No messages in this conversation yet.`}),r(T,e,n)]})}export{z as a,G as c,g as d,_ as f,c as g,m as h,te as i,A as l,y as m,X as n,U as o,b as p,q as r,R as s,K as t,O as u};