remote-codex 0.11.3 → 0.11.5

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 (36) hide show
  1. package/README.md +4 -0
  2. package/apps/relay-server/dist/index.js +51 -2
  3. package/apps/supervisor-api/dist/chunk-ZWZQVPDT.js +27893 -0
  4. package/apps/supervisor-api/dist/index.js +4 -25727
  5. package/apps/supervisor-api/dist/worker-index.d.ts +2 -0
  6. package/apps/supervisor-api/dist/worker-index.js +197 -0
  7. package/apps/supervisor-web/dist/assets/index-CbdWtyx0.js +5 -0
  8. package/apps/supervisor-web/dist/assets/index-Di1JBevU.css +1 -0
  9. package/apps/supervisor-web/dist/assets/thread-ui-ICfwCbte.js +3604 -0
  10. package/apps/supervisor-web/dist/assets/ui-vendor-D1uxdi-d.js +430 -0
  11. package/apps/supervisor-web/dist/index.html +6 -7
  12. package/bin/remote-codex.mjs +534 -19
  13. package/package.json +41 -2
  14. package/packages/agent-runtime/src/types.ts +2 -1
  15. package/packages/codex/src/appServerManager.ts +1 -0
  16. package/packages/codex/src/historyItems.test.ts +45 -0
  17. package/packages/codex/src/historyItems.ts +22 -0
  18. package/packages/codex/src/runtimeAdapter.ts +6 -0
  19. package/packages/codex/src/types.ts +2 -1
  20. package/packages/db/migrations/0018_control_plane.sql +129 -0
  21. package/packages/db/migrations/0019_control_plane_projects.sql +19 -0
  22. package/packages/db/migrations/0020_control_workspace_status.sql +1 -0
  23. package/packages/db/migrations/0021_control_sandbox_lifecycle_fields.sql +3 -0
  24. package/packages/db/migrations/0022_control_sandbox_resource_profile.sql +1 -0
  25. package/packages/db/migrations/0023_control_usage_import_state.sql +18 -0
  26. package/packages/db/migrations/0024_control_auth.sql +23 -0
  27. package/packages/db/migrations/0025_control_harness_credentials.sql +29 -0
  28. package/packages/db/migrations/0026_control_harness_usage_events.sql +27 -0
  29. package/packages/db/src/schema.ts +305 -1
  30. package/packages/shared/src/index.ts +32 -0
  31. package/packages/shared/src/tokens.ts +137 -0
  32. package/apps/supervisor-web/dist/assets/index-CBIze1VS.css +0 -1
  33. package/apps/supervisor-web/dist/assets/index-YpGAPjED.js +0 -4
  34. package/apps/supervisor-web/dist/assets/thread-ui-BEieA99i.css +0 -1
  35. package/apps/supervisor-web/dist/assets/thread-ui-CF80LEEN.js +0 -3613
  36. package/apps/supervisor-web/dist/assets/ui-vendor-CW6egZBG.js +0 -430
@@ -1,4 +0,0 @@
1
- import{r as o,j as e,u as bs,d as Ee,L as Ae,e as Gr,f as vs,a as Vr,N as Jr,B as Kr,h as ys,i as ke,O as Zr,k as Yr,c as Xr}from"./react-vendor-o1Xrx7m4.js";import{u as ws,t as Qr,f as $t,E as en,C as aa,T as tn,a as an,b as sn,c as rn,d as nn,L as on,P as ln}from"./thread-ui-CF80LEEN.js";import"./ui-vendor-CW6egZBG.js";import"./terminal-vendor-CLGgN91S.js";import"./graph-vendor-CGzY-MFv.js";import"./markdown-vendor-hBDTCSB-.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&l(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function l(c){if(c.ep)return;c.ep=!0;const u=r(c);fetch(c.href,u)}})();const js=["codex","claude","opencode"],Me="codex",Ns={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}};function dn(t){return typeof t=="string"&&js.includes(t)}function cn(t){return dn(t)?t:null}const rs=15;function un(t){return t.replace(/\s+/g," ").trim()}function ks(t){const a=un(t);if(!a)return"";const r=Array.from(a);return r.length<=rs?a:`${r.slice(0,rs).join("")}...`}const Ss=o.createContext(null);function Be(){return o.useContext(Ss)}class G extends Error{constructor(a,r){super(r.message),this.statusCode=a,this.payload=r}}const Gt="remote-codex-auth-token",Vt="remote-codex-relay-token",Ts="remote-codex-relay-mode",Jt="remote-codex-relay-device-id",Kt="remote-codex-relay-thread-id";function Cs(){return typeof window>"u"?null:window.localStorage.getItem(Gt)}function mn(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Gt,t);return}window.localStorage.removeItem(Gt)}}function Is(){return typeof window>"u"?null:window.localStorage.getItem(Vt)}function sa(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Vt,t);return}window.localStorage.removeItem(Vt)}}function Ve(){var t;return typeof window>"u"?!1:((t=window.__REMOTE_CODEX_BOOTSTRAP__)==null?void 0:t.mode)==="relay"||window.location.pathname.startsWith("/relay-portal")||window.location.pathname.startsWith("/relay-admin")||window.location.search.includes("relay=1")||window.localStorage.getItem(Ts)==="true"}function Tt(){typeof window>"u"||window.localStorage.setItem(Ts,"true")}function Es(){return Ve()}function Rs(){return typeof window>"u"?null:window.localStorage.getItem(Jt)}function Zt(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Jt,t);return}window.localStorage.removeItem(Jt)}}function hn(){return typeof window>"u"?null:window.localStorage.getItem(Kt)}function Yt(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Kt,t);return}window.localStorage.removeItem(Kt)}}function Os(t){if(!Ve())return t;if(t.startsWith("/api/")){const a=Rs();return a?`/relay/devices/${encodeURIComponent(a)}${t}`:`/relay${t}`}return t}function fn(t){return t===400?"bad_request":t===401?"unauthorized":t===403?"forbidden":t===404?"not_found":t===409?"conflict":t===429||t===503?"service_unavailable":"internal_error"}function pn(t,a){const r=a==null?void 0:a.trim(),l=r?`${t} ${r}`:`${t}`;return t===429?`Too many requests (${l}).`:t===503?`Upstream service unavailable (${l}).`:`Request failed (${l}).`}function We(t,a,r){const l=typeof(a==null?void 0:a.message)=="string"&&a.message.trim()?a.message.trim():r,c=a!=null&&a.details&&typeof a.details=="object"?a.details:void 0;return{code:(a==null?void 0:a.code)??fn(t.status),message:l,...c?{details:c}:{}}}async function Ps(t){var c,u;const a=pn(t.status,t.statusText),r=((u=(c=t.headers)==null?void 0:c.get)==null?void 0:u.call(c,"content-type"))??"",l=async()=>We(t,await t.json(),a);if(r.includes("application/json"))try{return await l()}catch{return We(t,null,a)}try{if(typeof t.text!="function")try{return await l()}catch{return We(t,null,a)}const m=(await t.text()).trim();if(m.startsWith("{"))try{return We(t,JSON.parse(m),a)}catch{}return We(t,m?{message:`${a}
2
- ${m}`}:null,a)}catch{try{return await l()}catch{return We(t,null,a)}}}async function T(t,a){const r=new Headers(a==null?void 0:a.headers);(a==null?void 0:a.body)!==void 0&&!(a.body instanceof FormData)&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const l=await fetch(Os(String(t)),Ms({...a,headers:r}));if(!l.ok){const c=await Ps(l);throw new G(l.status,c)}return await l.json()}function gn(t){const a=String(t);return a.includes("/exports/pdf")?a.includes("format=html")?"remote-codex-transcript.html":"remote-codex-transcript.pdf":"download"}function xn(t){var c;if(!t)return null;const a=t.match(/filename\*=UTF-8''([^;]+)/i);if(a!=null&&a[1])try{return decodeURIComponent(a[1].trim())}catch{return a[1].trim()}const r=t.match(/filename="([^"]+)"/i);if(r!=null&&r[1])return r[1].trim();const l=t.match(/filename=([^;]+)/i);return((c=l==null?void 0:l[1])==null?void 0:c.trim())??null}async function As(t,a){const r=await fetch(Os(String(t)),Ms(a));if(!r.ok){const c=await Ps(r);throw new G(r.status,c)}const l=xn(r.headers.get("content-disposition"))??gn(t);return{blob:await r.blob(),filename:l}}function Ms(t={}){const a=new Headers(t.headers),r=Is(),l=Cs();return Ve()&&r&&!a.has("Authorization")?a.set("Authorization",`Bearer ${r}`):l&&!a.has("Authorization")&&a.set("Authorization",`Bearer ${l}`),{...t,credentials:t.credentials??"same-origin",headers:a}}function ns(t,a){const r=t.originalName.trim();if(r)return r;const l=t.file.name.trim();return l||(t.kind==="photo"?`photo-${a+1}.jpg`:`file-${a+1}`)}function bn(){return T("/api/config/runtime")}function vn(){return T("/api/auth/session",{cache:"no-store"})}async function yn(t){const a=await T("/api/auth/login",{method:"POST",body:JSON.stringify(t)});return mn(a.token??null),a}function Xt(){return T("/relay/auth/session",{credentials:"same-origin"})}async function wn(t){Tt();const a=await T("/relay/auth/login",{method:"POST",body:JSON.stringify(t)});return sa(a.token),a}async function jn(t){Tt();const a=await T("/relay/auth/register",{method:"POST",body:JSON.stringify(t)});return sa(a.token),a}async function Nn(){const t=await T("/relay/auth/logout",{method:"POST"});return sa(null),Zt(null),Yt(null),t}function kn(){return T("/relay/portal")}function Sn(t){return T("/relay/devices",{method:"POST",body:JSON.stringify(t)})}function Tn(t){return T(`/relay/devices/${encodeURIComponent(t)}`,{method:"DELETE"})}function Cn(t){return T("/relay/shares",{method:"POST",body:JSON.stringify(t)})}function In(t){return T(`/relay/shares/${encodeURIComponent(t)}`,{method:"DELETE"})}function En(){return T("/relay/admin")}function Rn(t){return T("/relay/admin/settings/registration",{method:"PATCH",body:JSON.stringify({enabled:t})})}function On(t,a){return T(`/relay/admin/users/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({enabled:a})})}function Pn(){return T("/api/config/workspace-settings",{cache:"no-store"})}function An(t){return T("/api/config/workspace-settings",{method:"PATCH",body:JSON.stringify(t)})}function Us(){return T("/api/agent-runtimes",{cache:"no-store"})}function Ls(t){return T(`/api/agent-runtimes/${encodeURIComponent(t)}/status`,{cache:"no-store"})}function Mn(t){return T(`/api/agent-runtimes/${encodeURIComponent(t)}/restart`,{method:"POST"})}function Un(t,a){return T(`/api/agent-runtimes/${encodeURIComponent(t)}/install`,{method:"POST",body:JSON.stringify({action:a})})}function Qt(t){return T(`/api/agent-runtimes/${encodeURIComponent(t)}/models`,{cache:"no-store"})}function $s(t,a){return T(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(a)}`,{cache:"no-store"})}function Ds(t,a,r){return T(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify(r)})}function Ln(t){return T(`/api/config/providers/${encodeURIComponent(t)}/archives`,{cache:"no-store"})}function $n(t,a={}){return T(`/api/config/providers/${encodeURIComponent(t)}/archives`,{method:"POST",body:JSON.stringify(a)})}function Dn(t,a,r){return T(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(a)}`,{method:"PATCH",body:JSON.stringify(r)})}function Hn(t,a){return T(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(a)}/apply`,{method:"POST"})}function Bn(){return T("/api/service/build-restart",{method:"POST"})}function Fn(){return T("/healthz",{cache:"no-store"})}function ra(){return T("/api/workspaces")}function qn(t){return T(`/api/workspaces/${encodeURIComponent(t)}/files/tree`,{cache:"no-store"})}function _n(t,a){const r=new URLSearchParams({path:a.path});return a.offset!==void 0&&r.set("offset",String(a.offset)),a.limit!==void 0&&r.set("limit",String(a.limit)),T(`/api/workspaces/${encodeURIComponent(t)}/files/preview?${r.toString()}`,{cache:"no-store"})}function Wn(t,a){const r=new URLSearchParams({path:a.path});return`/api/workspaces/${encodeURIComponent(t)}/files/raw?${r.toString()}`}function zn(t,a){const r=new URLSearchParams({path:a.path});return As(`/api/workspaces/${encodeURIComponent(t)}/files/download?${r.toString()}`,{cache:"no-store"})}function Gn(t,a){const r=new FormData;return r.append("file",a.file,a.file.name),T(`/api/workspaces/${encodeURIComponent(t)}/files/upload`,{method:"POST",body:r})}function Hs(){return T("/api/threads")}function os(t,a={}){const r=new URLSearchParams;return a.limit!==void 0&&r.set("limit",String(a.limit)),a.beforeTurnId&&r.set("beforeTurnId",a.beforeTurnId),T(`/api/threads/${t}${r.size>0?`?${r.toString()}`:""}`)}function Vn(t,a){return T(`/api/threads/${t}/items/${encodeURIComponent(a)}/detail`)}function Jn(){return T("/api/plugins",{cache:"no-store"})}function Kn(t){return T("/api/plugins/import",{method:"POST",body:JSON.stringify(t)})}function Zn(t,a){return T(`/api/plugins/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(a)})}function Yn(t){return T(`/api/threads/${t}/export-turns`,{cache:"no-store"})}function Xn(t,a){var l,c,u;const r=new URLSearchParams;return a.format!==void 0&&r.set("format",a.format),r.set("mode",a.mode),a.limit!==void 0&&r.set("limit",String(a.limit)),a.turnIds!==void 0&&r.set("turnIds",a.turnIds.join(",")),a.profile!==void 0&&r.set("profile",a.profile),((l=a.options)==null?void 0:l.includeTokenAndPrice)!==void 0&&r.set("includeTokenAndPrice",String(a.options.includeTokenAndPrice)),((c=a.options)==null?void 0:c.includeCommandOutput)!==void 0&&r.set("includeCommandOutput",String(a.options.includeCommandOutput)),((u=a.options)==null?void 0:u.includeAbsolutePaths)!==void 0&&r.set("includeAbsolutePaths",String(a.options.includeAbsolutePaths)),`/api/threads/${encodeURIComponent(t)}/exports/pdf?${r.toString()}`}function Qn(t,a){return As(Xn(t,a),{cache:"no-store"})}function eo(t){return T(`/api/threads/${t}/shell`)}function to(t){return T("/api/threads/start",{method:"POST",body:JSON.stringify(t)})}function ao(t){return T("/api/threads/import",{method:"POST",body:JSON.stringify({sessionId:t})})}function so(t,a={}){return T(`/api/threads/${t}/shell`,{method:"POST",...Object.keys(a).length>0?{body:JSON.stringify(a)}:{}})}function ro(t){return T(`/api/shells/${t}/terminate`,{method:"POST"})}function no(t,a){return T(`/api/shells/${t}`,{method:"PATCH",body:JSON.stringify(a)})}function ls(t,a={}){return T(`/api/threads/${t}/resume`,{method:"POST",...Object.keys(a).length>0?{body:JSON.stringify(a)}:{}})}function oo(t){return T(`/api/threads/${t}/disconnect`,{method:"POST"})}function lo(t,a){const r=a.attachments??[];if(r.length===0)return T(`/api/threads/${t}/prompt`,{method:"POST",body:JSON.stringify(a)});const l=new FormData;l.append("prompt",a.prompt),a.clientRequestId!==void 0&&l.append("clientRequestId",a.clientRequestId),a.model!==void 0&&l.append("model",a.model),a.reasoningEffort!==void 0&&a.reasoningEffort!==null&&l.append("reasoningEffort",a.reasoningEffort),a.collaborationMode!==void 0&&l.append("collaborationMode",a.collaborationMode),a.sandboxMode!==void 0&&a.sandboxMode!==null&&l.append("sandboxMode",a.sandboxMode);const c=r.map((u,m)=>({clientId:u.clientId,kind:u.kind,originalName:ns(u,m),placeholder:u.placeholder}));l.append("attachmentManifest",JSON.stringify(c));for(const[u,m]of r.entries())l.append("attachments",m.file,ns(m,u));return T(`/api/threads/${t}/prompt`,{method:"POST",body:l})}function is(t,a={}){return T(`/api/threads/${t}/interrupt`,{method:"POST",body:JSON.stringify(a)})}function Bs(t,a){return T(`/api/threads/${t}`,{method:"PATCH",body:JSON.stringify(a)})}function Fs(t){return T(`/api/threads/${t}`,{method:"DELETE"})}function io(t,a){return T(`/api/threads/${t}/settings`,{method:"PATCH",body:JSON.stringify(a)})}function co(t){return T(`/api/threads/${t}/compact`,{method:"POST"})}function uo(t){return T(`/api/threads/${t}/goal`,{cache:"no-store"})}function mo(t,a){return T(`/api/threads/${t}/goal`,{method:"PATCH",body:JSON.stringify(a)})}function ho(t){return T(`/api/threads/${t}/goal`,{method:"DELETE"})}function fo(t){return T(`/api/threads/${t}/fork-turns`,{cache:"no-store"})}function ds(t,a){return T(`/api/threads/${t}/fork`,{method:"POST",body:JSON.stringify(a)})}function po(t){return T(`/api/threads/${t}/skills`,{cache:"no-store"})}function go(t){return T(`/api/threads/${t}/mcp-servers`,{cache:"no-store"})}function xo(t){return T(`/api/threads/${t}/hooks`,{cache:"no-store"})}function bo(t,a){return T(`/api/threads/${t}/hooks`,{method:"POST",body:JSON.stringify(a)})}function vo(t,a){return T(`/api/threads/${t}/hooks`,{method:"PUT",body:JSON.stringify(a)})}function yo(t,a){return T(`/api/threads/${t}/hooks/trust`,{method:"POST",body:JSON.stringify(a)})}function wo(t,a){return T(`/api/threads/${t}/hooks/untrust`,{method:"POST",body:JSON.stringify(a)})}function jo(t,a,r){return T(`/api/threads/${t}/requests/${encodeURIComponent(a)}/respond`,{method:"POST",body:JSON.stringify(r)})}function No(t){return T("/api/workspaces",{method:"POST",body:JSON.stringify(t)})}function ko(t,a){return T(`/api/workspaces/${t}`,{method:"PATCH",body:JSON.stringify(a)})}function So(t){return T(`/api/workspaces/${t}`,{method:"DELETE"})}function To(t,a){return T(`/api/workspaces/${t}/favorite`,{method:"POST",body:JSON.stringify(a)})}function qs(t){const a=window.location.protocol==="https:"?"wss:":"ws:",r=new WebSocket(_s(a));return r.addEventListener("message",l=>{try{const c=JSON.parse(l.data);Io(c)&&t(c)}catch{}}),r}function Co(t={}){const a=window.location.protocol==="https:"?"wss:":"ws:",r=new WebSocket(_s(a));return r.addEventListener("message",l=>{var c,u;try{const m=JSON.parse(l.data);if(m.type==="supervisor.connected"){(c=t.onConnected)==null||c.call(t,m);return}Eo(m)&&((u=t.onShellEvent)==null||u.call(t,m))}catch{}}),{socket:r,send(l){r.send(JSON.stringify(l))}}}function _s(t){const a=new URL(`${t}//${window.location.host}/ws`);if(Ve()){const u=Rs();a.pathname=u?`/relay/devices/${encodeURIComponent(u)}/ws`:"/relay/ws"}const r=Cs(),l=Is(),c=hn();return Ve()&&l&&a.searchParams.set("relaySession",l),Ve()&&c&&a.searchParams.set("threadId",c),r&&a.searchParams.set("token",r),a.toString()}function Io(t){return"threadId"in t&&t.type.startsWith("thread.")&&typeof t.payload=="object"&&t.payload!==null}function Eo(t){return"shellId"in t&&t.type.startsWith("shell.")&&typeof t.payload=="object"&&t.payload!==null}function Ro(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M2 3.25h12v1.5H2Zm0 4h12v1.5H2Zm0 4h12v1.5H2Z"})})}function Nt(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})}function cs(t=!1){return`flex w-full items-center rounded-[0.95rem] px-3 py-2 text-left text-sm transition ${t?"cursor-not-allowed bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]":"text-[var(--theme-fg)] hover:bg-[var(--theme-hover)]"}`}const Oo=[{value:"light",label:"Light",description:"Always use the bright theme."},{value:"dark",label:"Dark",description:"Always use the dark theme."},{value:"system",label:"System",description:"Follow the operating system appearance."}],Ws={hostConfigFiles:[],toolboxItems:[],hookCommandTemplates:[],providerConfigFormat:"none",mcpConfigFormat:"none",configArchives:!1,buildRestart:!1},Po={codex:{packageName:"@openai/codex",installCommand:null,updateCommand:"npm install -g @openai/codex@latest"},claude:{packageName:"@anthropic-ai/claude-agent-sdk",installCommand:"npm install -g @anthropic-ai/claude-code @anthropic-ai/claude-agent-sdk",updateCommand:"npm install -g @anthropic-ai/claude-code@latest @anthropic-ai/claude-agent-sdk@latest"},opencode:{packageName:"opencode-ai",installCommand:"npm install -g opencode-ai @opencode-ai/sdk",updateCommand:"npm install -g opencode-ai@latest @opencode-ai/sdk@latest"}};function ea(t){const a=Po[t];return{packageName:a.packageName,installed:t==="codex",installedVersion:null,latestVersion:null,installCommand:a.installCommand,updateCommand:a.updateCommand,busy:!1,lastError:null}}function Ao(t,a){return{provider:t,displayName:a,description:`${a} backend descriptor is not available.`,enabled:!1,isDefault:t===Me,status:{state:"stopped",transport:Ns[t].defaultTransport,lastStartedAt:null,lastError:"Backend descriptor is not available.",restartCount:0},capabilities:{sessions:{list:!1,read:!1,resume:!1,importLocal:!1},turns:{start:!1,streamInput:!1,steer:!1,interrupt:!1,compact:!1},branching:{fork:!1,hardRollback:!1,resumeAt:!1,rewindFiles:!1},controls:{planMode:!1,permissionRequests:!1,sandboxMode:!1,performanceMode:!1,goals:!1},management:{models:!1,mcpStatus:!1,skills:!1,hooks:!1,hookTrust:!1,hostConfigFiles:!1,providerSettings:!1},usage:{contextWindow:!1,tokenUsage:!1,costUsd:!1}},managementSchema:Ws,installation:ea(t)}}function Dt(t){const a=t.installation??ea(t.provider);return{...t,installation:{...ea(t.provider),...a}}}const Ge=[...js.map(t=>Ao(t,Ns[t].displayName))];function Mo(t){var a;return((a=Ge.find(r=>r.provider===t))==null?void 0:a.managementSchema)??Ws}function Uo(t){const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Lo(t){const a=t.payload.details,r=typeof(a==null?void 0:a.stderr)=="string"&&a.stderr.trim()?a.stderr.trim():typeof(a==null?void 0:a.stdout)=="string"&&a.stdout.trim()?a.stdout.trim():null;return r?`${t.message}
3
- ${r}`:t.message}function Ye(t){return{path:t,exists:!1,originalContent:"",draftContent:"",loading:!1,saving:!1,error:null,saveMessage:null}}function zs({className:t=""}){const a=Be();return a?e.jsx("button",{type:"button","aria-label":a.navOpen?"Close Navigation":"Open Navigation","aria-expanded":a.navOpen,"aria-controls":"app-shell-navigation-menu",onClick:a.toggleNav,className:`inline-flex h-10 w-10 shrink-0 items-center justify-center text-[var(--theme-fg)] transition hover:text-[var(--theme-fg-soft)] ${t}`.trim(),children:a.navOpen?e.jsx(Nt,{}):e.jsx(Ro,{})}):null}function Gs({className:t=""}){const a=Be(),r=bs(),l=Ee(),c=o.useRef(null),u=r.pathname==="/workspaces";return o.useEffect(()=>{if(!(a!=null&&a.navOpen))return;const m=a;function x(N){const y=N.target;if(!y)return;const C=c.current;C!=null&&C.contains(y)||y instanceof Element&&y.closest('[aria-controls="app-shell-navigation-menu"]')||m.closeNav()}return document.addEventListener("pointerdown",x),()=>{document.removeEventListener("pointerdown",x)}},[a]),a!=null&&a.navOpen?e.jsxs("div",{ref:c,id:"app-shell-navigation-menu",onPointerDown:m=>{m.stopPropagation()},onMouseDown:m=>{m.stopPropagation()},onTouchStart:m=>{m.stopPropagation()},className:`rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 shadow-2xl shadow-black/15 backdrop-blur ${t}`.trim(),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold tracking-wide text-[var(--theme-accent-strong)]",children:"Remote Codex"}),e.jsx("p",{className:"mt-1 text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Navigation"})]}),e.jsxs("nav",{className:"mt-4 flex flex-col gap-1.5 text-sm",children:[e.jsx("button",{type:"button",disabled:u,onClick:()=>{u||(a.closeNav(),l("/workspaces"))},className:cs(u),children:"Workspaces"}),e.jsx("button",{type:"button",onClick:()=>{a.openSettings()},className:cs(),children:"Settings"})]})]}):null}function na({embedded:t=!1}={}){const a=Be(),r=ws(),[l,c]=o.useState(""),[u,m]=o.useState({busy:!1,message:null,error:null}),[x,N]=o.useState(!1),[y,C]=o.useState(null),[p,I]=o.useState({}),w=y?p[y]:null,[P,M]=o.useState({busy:!1,message:null,error:null}),[$,te]=o.useState([]),[ae,V]=o.useState(Ge),[D,oe]=o.useState({loading:!1,saving:!1,error:null,operatingProvider:null,operatingAction:null,message:null}),[i,B]=o.useState(null),[ne,F]=o.useState({devHomeDraft:"",loading:!1,saving:!1,message:null,error:null}),[Y,J]=o.useState({loading:!1,creating:!1,applyingId:null,renamingId:null,renameDraft:"",message:null,error:null}),R=(a==null?void 0:a.themeMode)??"system",W=t||!!(a!=null&&a.settingsOpen);async function E(){const h=l.trim();if(!(!h||u.busy)){m({busy:!0,message:null,error:null});try{await r.importPluginManifest({manifestJson:h,enabled:!0}),c(""),m({busy:!1,message:"Plugin manifest imported.",error:null})}catch(g){m({busy:!1,message:null,error:g instanceof Error?g.message:"Unable to import plugin manifest."})}}}const z=(a==null?void 0:a.effectiveTheme)??"dark",H=(a==null?void 0:a.defaultBackend)??Me,Ne=r.plugins.filter(h=>h.enabled).length,be=r.loading?"Loading...":`${Ne}/${r.plugins.length} enabled`,O=ae.find(h=>h.provider===H)??Ge.find(h=>h.provider===H)??Ge[0],K=O.managementSchema??Mo(O.provider),X=K.hostConfigFiles;o.useEffect(()=>{if(!W||t||!a||!K.configArchives)return;const h=a;function g(v){v.key==="Escape"&&h.closeSettings()}return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[K.configArchives,t,W,a]),o.useEffect(()=>{if(!W)return;let h=!1;return oe(g=>({...g,loading:!0,error:null})),Us().then(g=>{if(h)return;const v=[...g.map(Dt),...Ge.filter(L=>!g.some(se=>se.provider===L.provider))];V(v),oe(L=>({...L,loading:!1}))}).catch(g=>{h||(V(Ge),oe(v=>({...v,loading:!1,error:g instanceof G?g.message:"Unable to load backend settings."})))}),()=>{h=!0}},[W]),o.useEffect(()=>{if(!W)return;let h=!1;return F(g=>({...g,loading:!0,message:null,error:null})),Pn().then(g=>{h||(B(g),F(v=>({...v,devHomeDraft:g.devHome,loading:!1})))}).catch(g=>{h||F(v=>({...v,loading:!1,error:g instanceof G?g.message:"Unable to load workspace settings."}))}),()=>{h=!0}},[W]),o.useEffect(()=>{if(!W||!O.capabilities.management.hostConfigFiles)return;let h=!1;async function g(){I(L=>{const se={...L};for(const xe of X)se[xe.name]={...Ye(xe.name),...L[xe.name],loading:!0,saving:!1,error:null,saveMessage:null};return se});const v=await Promise.allSettled(X.map(async L=>({name:L.name,result:await $s(O.provider,L.name)})));h||I(L=>{var xe,Re;const se={...L};for(const Se of v){if(Se.status==="fulfilled"){const{name:nt,result:Oe}=Se.value;se[nt]={path:Oe.path,exists:Oe.exists,originalContent:Oe.content,draftContent:Oe.content,loading:!1,saving:!1,error:null,saveMessage:null};continue}const rt=Se.reason instanceof G?Se.reason.message:"Unable to load the file.",Le=((xe=X[v.indexOf(Se)])==null?void 0:xe.name)??((Re=X[0])==null?void 0:Re.name);Le&&(se[Le]={...Ye(Le),...se[Le],loading:!1,saving:!1,error:rt,saveMessage:null})}return se})}return g(),()=>{h=!0}},[O.capabilities.management.hostConfigFiles,O.provider,X,W]),o.useEffect(()=>{if(!W)return;let h=!1;async function g(){J(v=>({...v,loading:!0,error:null,message:null}));try{const v=await Ln(O.provider);if(h)return;te(v),J(L=>({...L,loading:!1}))}catch(v){if(h)return;J(L=>({...L,loading:!1,error:v instanceof G?v.message:"Unable to load config archives."}))}}return g(),()=>{h=!0}},[O.provider,K.configArchives,W]);async function de(){if(!(P.busy||D.saving)){M({busy:!0,message:null,error:null});try{const h=await Mn(O.provider),g=Dt(h);M({busy:!1,message:g.status.state==="ready"?`${g.displayName} backend restarted.`:`${g.displayName} backend state: ${g.status.state}`,error:null}),V(v=>v.map(L=>L.provider===g.provider?g:L))}catch(h){M({busy:!1,message:null,error:h instanceof G?h.message:"Unable to restart the app server."})}}}async function ue(h,g){if(P.busy||D.saving)return;const v=ae.find(L=>L.provider===h);oe(L=>({...L,saving:!0,operatingProvider:h,operatingAction:g,message:null,error:null}));try{const L=await Un(h,g),se=Dt(L);V(xe=>xe.map(Re=>Re.provider===se.provider?se:Re)),oe(xe=>({...xe,saving:!1,operatingProvider:null,operatingAction:null,message:se.installation.lastError?`${se.displayName} ${g==="install"?"installed":"updated"}, but requires attention:
4
- ${se.installation.lastError}`:`${se.displayName} ${g==="install"?"installed":"updated"}.`,error:null}))}catch(L){oe(se=>({...se,saving:!1,operatingProvider:null,operatingAction:null,message:null,error:L instanceof G?Lo(L):`Unable to ${g} ${(v==null?void 0:v.displayName)??h}.`}))}}async function It(){if(!(P.busy||D.saving)){M({busy:!0,message:null,error:null});try{await Bn(),M({busy:!1,message:"Build and restart launched. The page may disconnect briefly.",error:null})}catch(h){M({busy:!1,message:null,error:h instanceof G?h.message:"Unable to launch build and restart."})}}}async function Et(){const h=ne.devHomeDraft.trim();if(!(!h||ne.saving)){F(g=>({...g,saving:!0,message:null,error:null}));try{const g=await An({devHome:h});B(g),F(v=>({...v,devHomeDraft:g.devHome,saving:!1,message:"Workspace defaults saved."}))}catch(g){F(v=>({...v,saving:!1,error:g instanceof G?g.message:"Unable to save workspace settings."}))}}}async function et(h){const g=p[h];if(!(!g||g.saving)){I(v=>({...v,[h]:{...Ye(h),...v[h],saving:!0,error:null,saveMessage:null}}));try{const v=await Ds(O.provider,h,{content:g.draftContent});I(L=>({...L,[h]:{path:v.path,exists:v.exists,originalContent:v.content,draftContent:v.content,loading:!1,saving:!1,error:null,saveMessage:"Saved"}}))}catch(v){I(L=>({...L,[h]:{...Ye(h),...L[h],saving:!1,error:v instanceof G?v.message:"Unable to save the file.",saveMessage:null}}))}}}async function tt(){if(!Y.creating){J(h=>({...h,creating:!0,message:null,error:null}));try{const h=await $n(O.provider);te(g=>[h,...g]),J(g=>({...g,creating:!1,message:"Backup created."}))}catch(h){J(g=>({...g,creating:!1,error:h instanceof G?h.message:"Unable to create a config backup."}))}}}async function at(h){if(!Y.applyingId){J(g=>({...g,applyingId:h.id,message:null,error:null}));try{const g=await Hn(O.provider,h.id);J(v=>({...v,applyingId:null,message:g.status.state==="ready"?`Applied "${g.archive.label}" and restarted ${O.displayName}.`:`Applied "${g.archive.label}". ${O.displayName} state: ${g.status.state}.`}))}catch(g){J(v=>({...v,applyingId:null,error:g instanceof G?g.message:"Unable to apply the config archive."}))}}}async function st(h){const g=Y.renameDraft.trim();if(!(!g||Y.renamingId!==h.id)){J(v=>({...v,message:null,error:null}));try{const v=await Dn(O.provider,h.id,{label:g});te(L=>L.map(se=>se.id===h.id?v:se)),J(L=>({...L,renamingId:null,renameDraft:"",message:"Backup renamed."}))}catch(v){J(L=>({...L,error:v instanceof G?v.message:"Unable to rename the config backup."}))}}}if(!W)return null;const Ue=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 grid gap-2",children:[r.plugins.map(h=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2.5",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--theme-fg)]",children:h.name}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--theme-fg-muted)]",children:h.description}),e.jsx("span",{className:"mt-2 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:[...h.capabilities.artifactTypes.map(g=>g.type),...h.capabilities.threadPanels.map(g=>g.kind??g.id)].join(", ")||"utility"}),e.jsx("span",{className:"mt-1 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:h.source==="imported"?"Imported manifest":"Built-in module"})]}),e.jsx("input",{type:"checkbox",checked:h.enabled,onChange:g=>void r.setPluginEnabled(h.id,g.currentTarget.checked),className:"mt-1 h-4 w-4 shrink-0 accent-[var(--theme-accent-solid)]"})]},h.id)),r.plugins.length===0&&e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No plugins are registered."})]}),e.jsxs("div",{className:"mt-3 border-t border-[var(--theme-border)] pt-3",children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--theme-fg)]",children:"Import manifest JSON"}),e.jsx("textarea",{value:l,onChange:h=>{c(h.currentTarget.value),(u.message||u.error)&&m({busy:!1,message:null,error:null})},placeholder:'{"id":"example.viewer","name":"Example Viewer","version":"0.1.0",...}',rows:4,className:"mt-2 min-h-28 w-full resize-y rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs leading-5 text-[var(--theme-fg)] outline-none transition placeholder:text-[var(--theme-fg-muted)] focus:border-[var(--theme-accent-border)]"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"max-w-[42rem] text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Imports register manifest-declared artifact types. Rendering code still needs a trusted built-in frontend module."}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:!l.trim()||u.busy,className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:u.busy?"Importing...":"Import"})]}),u.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:u.error}),u.message&&e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:u.message})]}),r.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:r.error})]}),Fe=e.jsxs(e.Fragment,{children:[t?null:e.jsx("div",{className:"shrink-0 p-5 pb-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Settings"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold text-[var(--theme-fg)]",children:"Settings"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Choose the default backend and manage host-side runtime files."})]}),e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:a==null?void 0:a.closeSettings,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(Nt,{})})]})}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${t?"p-0":"p-5 pt-5"}`,children:e.jsxs("div",{className:"space-y-2",children:[t?null:e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Appearance"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Choose light, dark, or follow the system setting. Active:"," ",z,"."]})]})}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-3",children:Oo.map(h=>{const g=R===h.value;return e.jsxs("button",{type:"button",onClick:()=>a==null?void 0:a.setThemeMode(h.value),className:`block rounded-[1rem] border px-3 py-2.5 text-left transition ${g?"border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)]":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] hover:bg-[var(--theme-hover)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:h.label}),g?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Active"}):null]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:h.description})]},h.value)})})]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Enable renderers and thread extensions loaded by this supervisor."})]}),e.jsx("button",{type:"button",onClick:()=>void r.refresh(),disabled:r.loading,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:r.loading?"Loading...":"Refresh"})]}),t?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2",children:[e.jsx("span",{className:"text-xs text-[var(--theme-fg-muted)]",children:be}),e.jsx("button",{type:"button",onClick:()=>N(!0),className:"rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Manage"})]}):Ue]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Workspace defaults"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Git projects clone into dev home. New workspace directories can create one missing child under this path."})]})}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Workspace root"}),e.jsx("p",{title:(i==null?void 0:i.workspaceRoot)??"Loading workspace root",className:"mt-1 truncate rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs text-[var(--theme-fg-soft)]",children:ne.loading&&!i?"Loading...":(i==null?void 0:i.workspaceRoot)??"Unavailable"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-dev-home",className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Dev home"}),e.jsxs("div",{className:"mt-1 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:"settings-dev-home",value:ne.devHomeDraft,onChange:h=>F(g=>({...g,devHomeDraft:h.target.value,message:null,error:null})),placeholder:"/Users/name/dev",className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":"Save workspace defaults",onClick:()=>void Et(),disabled:ne.loading||ne.saving||!ne.devHomeDraft.trim(),className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:ne.saving?"Saving...":"Save"})]})]})]}),ne.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:ne.error}):ne.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:ne.message}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Runtime controls"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Inspect installed backend versions, install optional runtimes, or restart the selected backend."})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void de(),disabled:P.busy||D.saving,className:"rounded-full border border-sky-400/35 bg-sky-400/10 px-3 py-1.5 text-xs font-medium text-sky-500 transition hover:bg-sky-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:P.busy?"Restarting...":"Restart"}),e.jsx("button",{type:"button",onClick:()=>void It(),disabled:P.busy||D.saving,className:"rounded-full border border-amber-400/35 bg-amber-400/10 px-3 py-1.5 text-xs font-medium text-amber-500 transition hover:bg-amber-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:P.busy?"Working...":"Build and restart"})]})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:ae.map(h=>{const g=h.installation,v=!g.installed&&!!g.installCommand,L=g.installed&&!!g.updateCommand,se=D.saving&&D.operatingProvider===h.provider,xe=v?"Install":"Update";return e.jsxs("div",{className:"flex flex-col gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:h.displayName}),e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] ${h.enabled?"border-emerald-400/35 bg-emerald-400/10 text-emerald-400":"border-[var(--theme-border)] bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]"}`,children:h.enabled?"Ready":g.installed?h.status.state:"Not installed"})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[var(--theme-fg-muted)]",children:["Version:"," ",g.installedVersion??(g.installed?"Installed":"Unavailable"),g.latestVersion?` · Latest: ${g.latestVersion}`:""]}),g.lastError?e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-rose-300",children:g.lastError}):null]}),v||L?e.jsx("button",{type:"button","aria-label":`${v?"Install":"Update"} ${h.displayName}`,onClick:()=>void ue(h.provider,v?"install":"update"),disabled:P.busy||D.saving||!v&&!L,className:"shrink-0 rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:se?D.operatingAction==="install"?"Installing...":"Updating...":xe}):null]},h.provider)})}),P.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:P.error}):P.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:P.message}):D.message?e.jsx("p",{className:`mt-2 whitespace-pre-line text-xs ${D.message.includes("requires attention")?"text-amber-300":"text-emerald-300"}`,children:D.message}):D.error?e.jsx("p",{className:"mt-2 whitespace-pre-line text-xs text-rose-300",children:D.error}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Provider host files"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:[O.displayName," exposes these editable files through its backend schema."]})]})}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[X.map(h=>{const g=p[h.name]??{path:h.name,exists:!1,originalContent:"",draftContent:"",loading:!1},v=g.draftContent!==g.originalContent;return e.jsx("button",{type:"button",onClick:()=>C(h.name),className:"block rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-left transition hover:bg-[var(--theme-hover)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:h.label}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:h.description})]}),e.jsx("div",{className:"shrink-0",children:g.loading?e.jsx("span",{className:"text-[11px] uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Loading"}):v?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Unsaved"}):g.exists?e.jsx("span",{className:"rounded-full border border-emerald-400/25 bg-emerald-400/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-emerald-600 dark:text-emerald-100",children:"Ready"}):e.jsx("span",{className:"rounded-full border border-sky-300/25 bg-sky-300/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-600 dark:text-sky-100",children:"New"})})]})},h.name)}),X.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"This backend does not expose editable host files."}):null]})]}),K.configArchives?e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Config archives"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Backup the selected backend host files, then apply a saved archive with a backend restart."})]}),e.jsx("button",{type:"button",onClick:()=>void tt(),disabled:Y.creating,className:"shrink-0 rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:Y.creating?"Creating...":"Create backup"})]}),Y.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:Y.error}):Y.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:Y.message}):null,e.jsx("div",{className:"mt-3 space-y-2",children:Y.loading?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"Loading backups..."}):$.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No config backups yet."}):$.map(h=>{const g=Y.renamingId===h.id;return e.jsx("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[g?e.jsxs("div",{className:"flex max-w-xl gap-2",children:[e.jsx("input",{"aria-label":`Rename ${h.label}`,value:Y.renameDraft,onChange:v=>J(L=>({...L,renameDraft:v.target.value,error:null,message:null})),className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":`Save archive name ${h.label}`,onClick:()=>void st(h),className:"rounded-full bg-[var(--theme-accent-solid)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)]",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>J(v=>({...v,renamingId:null,renameDraft:""})),className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Cancel"})]}):e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:h.label}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[11px] text-[var(--theme-fg-muted)]",children:[e.jsxs("span",{children:["Created ",Uo(h.createdAt)]}),X.map(v=>{var L;return e.jsxs("span",{className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-2 py-0.5 font-mono",children:[v.name,":"," ",(L=h.files[v.name])!=null&&L.exists?"saved":"missing"]},v.name)})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J(v=>({...v,renamingId:h.id,renameDraft:h.label,message:null,error:null})),disabled:g,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:"Rename"}),e.jsx("button",{type:"button",onClick:()=>void at(h),disabled:Y.applyingId!==null,className:"rounded-full border border-emerald-400/35 bg-emerald-400/10 px-3 py-1.5 text-xs font-medium text-emerald-600 transition hover:bg-emerald-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)] dark:text-emerald-100",children:Y.applyingId===h.id?"Applying...":"Apply"})]})]})},h.id)})})]}):null]})})]});return t?e.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden",children:[Fe,x?e.jsxs("div",{className:"fixed inset-0 z-[90] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),4rem)] sm:items-center sm:pt-4",children:[e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>N(!1),className:"absolute inset-0 bg-black/35 backdrop-blur-[2px]"}),e.jsxs("section",{className:"relative z-10 flex max-h-[min(82vh,42rem)] w-full max-w-2xl flex-col overflow-hidden rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/25",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:be})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void r.refresh(),disabled:r.loading,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:r.loading?"Loading...":"Refresh"}),e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>N(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:e.jsx(Nt,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:Ue})]})]}):null]}):e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),1rem)] sm:items-center",children:[e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:a==null?void 0:a.closeSettings,className:"ui-overlay-scrim absolute inset-0 backdrop-blur-sm"}),e.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Settings",className:"relative z-10 flex max-h-[calc(100vh-2rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/20",children:Fe}),y&&w?e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[71] flex items-center justify-center p-4",children:e.jsxs("div",{className:"pointer-events-auto relative z-10 flex max-h-[min(88vh,56rem)] w-full max-w-3xl flex-col overflow-hidden rounded-[1.6rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:y}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs text-[var(--theme-fg-muted)]",children:w.path})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.error?e.jsx("span",{className:"text-xs text-rose-300",children:w.error}):w.saveMessage?e.jsx("span",{className:"text-xs text-emerald-300",children:w.saveMessage}):null,e.jsx("button",{type:"button","aria-label":`Save ${y}`,onClick:()=>void et(y),disabled:w.loading||w.saving||w.draftContent===w.originalContent,className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-sm font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:w.saving?"Saving...":"Save"}),e.jsx("button",{type:"button","aria-label":"Close File Editor",onClick:()=>C(null),className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(Nt,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-5",children:e.jsx("textarea",{"aria-label":`Edit ${y}`,value:w.draftContent,onChange:h=>I(g=>({...g,[y]:{...Ye(y),...g[y],draftContent:h.target.value,error:null,saveMessage:null}})),spellCheck:!1,className:"min-h-[28rem] w-full rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 font-mono text-[13px] leading-6 text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-border)]",placeholder:w.loading?"Loading...":`Edit ${y} here`})})]})}):null]})}function Ht({eyebrow:t,title:a,description:r}){return e.jsxs("div",{className:"host-card rounded-3xl border p-5",children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:t}),e.jsx("h2",{className:"host-page-title mt-3 text-xl font-semibold",children:a}),e.jsx("p",{className:"host-page-description mt-2 text-sm leading-6",children:r})]})}function $o(){const[t,a]=o.useState(null),[r,l]=o.useState(null);return o.useEffect(()=>{bn().then(a).catch(c=>{l(c instanceof Error?c.message:"Unable to load runtime config.")})},[]),e.jsx("div",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-8 text-[var(--app-fg)] sm:px-6",children:e.jsx("div",{className:"mx-auto max-w-7xl",children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1.2fr_0.8fr]",children:[e.jsxs("section",{className:"host-card rounded-[2rem] border p-8 sm:p-10",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.35em] text-[var(--theme-accent-strong)]",children:"Local Supervisor"}),e.jsx("h1",{className:"host-page-title mt-4 max-w-3xl text-4xl font-semibold tracking-tight sm:text-6xl",children:"Bring your local workspaces into a mobile-ready control surface."}),e.jsx("p",{className:"host-page-description mt-6 max-w-2xl text-base leading-7 sm:text-lg",children:"Phase 1 focuses on a stable supervisor shell: runtime config, workspace onboarding, database bootstrap, and a read-only file tree that already respects workspace root boundaries."}),e.jsxs("div",{className:"mt-8 flex flex-wrap gap-4",children:[e.jsx(Ae,{to:"/workspaces",className:"ui-action-primary rounded-full px-5 py-3 font-medium transition",children:"Enter Workspace Console"}),e.jsx(Ae,{to:"/workspaces/new",className:"host-secondary-button rounded-full border px-5 py-3 font-medium transition",children:"Add First Workspace"})]})]}),e.jsxs("section",{className:"grid gap-4",children:[e.jsx(Ht,{eyebrow:"Health",title:r?"API unavailable":"Supervisor reachable",description:r??`Connected to ${(t==null?void 0:t.appName)??"Remote Codex Supervisor"} ${(t==null?void 0:t.appVersion)??""}`.trim()}),e.jsx(Ht,{eyebrow:"Workspace Root",title:(t==null?void 0:t.workspaceRoot)??"Loading root path",description:"The file tree and workspace creation flow stay inside this boundary in Phase 1."}),e.jsx(Ht,{eyebrow:"Environment",title:(t==null?void 0:t.environment)??"Loading environment",description:t?`${t.host}:${t.port}`:"Runtime metadata appears here after bootstrap."})]})]})})})}function Do({onLogin:t}){const[a,r]=o.useState(""),[l,c]=o.useState(""),[u,m]=o.useState(null),[x,N]=o.useState(!1);async function y(C){C.preventDefault(),m(null),N(!0);try{await t({username:a,password:l})}catch(p){p instanceof G?m(p.payload.message):m("Unable to sign in.")}finally{N(!1)}}return e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 py-8 text-[var(--app-fg)]",children:e.jsxs("section",{className:"w-full max-w-sm rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-2xl shadow-[color-mix(in_oklch,var(--app-fg)_14%,transparent)] sm:p-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-muted)]",children:"Supervisor Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-normal text-[var(--theme-fg)]",children:"Sign in"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-muted)]",children:"Use the admin credentials configured on this Remote Codex server."})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Username"}),e.jsx("input",{autoComplete:"username",autoFocus:!0,className:"mt-2 h-11 w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:x,name:"username",onChange:C=>r(C.target.value),value:a})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Password"}),e.jsx("input",{autoComplete:"current-password",className:"mt-2 h-11 w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:x,name:"password",onChange:C=>c(C.target.value),type:"password",value:l})]}),u&&e.jsx("p",{className:"rounded-xl border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-sm text-[var(--status-danger-fg)]",children:u}),e.jsx("button",{className:"h-11 w-full rounded-xl bg-[var(--theme-accent-solid)] px-4 text-sm font-semibold text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-60",disabled:x||!a.trim()||!l,type:"submit",children:x?"Signing in...":"Sign in"})]})]})})}function Bt(t){return t instanceof G?t.payload.message:t instanceof Error?t.message:"Unable to update relay admin state."}function Ho(){const[t,a]=o.useState(null),[r,l]=o.useState(!0),[c,u]=o.useState(null),[m,x]=o.useState(null);async function N(){l(!0),u(null);try{Tt(),a(await En())}catch(p){u(Bt(p))}finally{l(!1)}}o.useEffect(()=>{N()},[]);async function y(p){x("registration"),u(null);try{const I=await Rn(p);a(w=>w&&{...w,registrationEnabled:I.registrationEnabled})}catch(I){u(Bt(I))}finally{x(null)}}async function C(p,I){x(p),u(null);try{const w=await On(p,I);a(P=>P&&{...P,users:P.users.map(M=>M.id===w.id?w:M)})}catch(w){u(Bt(w))}finally{x(null)}}return e.jsx("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5",children:[e.jsxs("header",{className:"flex flex-col gap-3 border-b border-[var(--theme-border)] pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Admin"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Users and devices"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Manage relay accounts, registration, and connected devices."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(Ae,{className:"relay-button-secondary",to:"/relay-portal",children:"Portal"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void N(),type:"button",children:"Refresh"})]})]}),r?e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading relay admin..."}):c?e.jsx("section",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] p-4 text-sm text-[var(--status-danger-fg)]",children:c}):t?e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Registration"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"New users can create relay accounts without email verification."})]}),e.jsx("button",{className:"relay-button-primary",disabled:m==="registration",onClick:()=>void y(!t.registrationEnabled),type:"button",children:t.registrationEnabled?"Disable":"Enable"})]})}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Users"}),e.jsx("div",{className:"mt-4 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[44rem] border-collapse text-left text-sm",children:[e.jsx("thead",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"User"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Email"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Role"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Status"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Actions"})]})}),e.jsx("tbody",{children:t.users.map(p=>e.jsxs("tr",{children:[e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 font-medium text-[var(--theme-fg)]",children:p.username}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:p.email}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:p.role}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:p.enabled?"Enabled":"Disabled"}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3",children:e.jsx("button",{className:"relay-button-secondary",disabled:m===p.id||p.role==="admin",onClick:()=>void C(p.id,!p.enabled),type:"button",children:p.enabled?"Disable":"Enable"})})]},p.id))})]})})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Devices"}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:t.devices.map(p=>e.jsxs("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${p.connected?"bg-emerald-500":"bg-[var(--theme-fg-muted)]"}`}),e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:p.name})]}),e.jsx("p",{className:"mt-2 font-mono text-xs text-[var(--theme-fg-muted)]",children:p.id}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:["Owner: ",p.ownerUserId]})]},p.id))})]})]}):null]})})}function Ct(t,a){return t instanceof G?t.payload.message:t instanceof Error?t.message:a}function oa(){var D,oe;const t=Ee(),[a,r]=o.useState(null),[l,c]=o.useState(null),[u,m]=o.useState(!0),[x,N]=o.useState(null),[y,C]=o.useState(null);async function p(){m(!0),N(null);try{Tt();const i=await Xt();r(i),i.authenticated?c(await kn()):c(null)}catch(i){N(Ct(i,"Unable to load relay portal."))}finally{m(!1)}}o.useEffect(()=>{p()},[]);async function I(){C(null),await p()}async function w(i){const B=await Sn({name:i});C(B),await p()}async function P(i){await Tn(i),await p()}async function M(i){await Cn(i),await p()}async function $(i){await In(i),await p()}async function te(){await Nn(),r(await Xt()),c(null),C(null)}function ae(i){Zt(i),Yt(null),t("/workspaces")}function V(i,B){Zt(i),Yt(B),t(`/threads/${encodeURIComponent(B)}`)}return u?e.jsx(Ft,{children:"Checking relay session..."}):a!=null&&a.authenticated?e.jsx(Ft,{children:e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5",children:[e.jsxs("header",{className:"flex flex-col gap-3 border-b border-[var(--theme-border)] pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Portal"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:(D=a.user)==null?void 0:D.username}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Manage devices and shared Remote Codex sessions."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[((oe=a.user)==null?void 0:oe.role)==="admin"?e.jsx(Ae,{className:"relay-button-secondary",to:"/relay-admin",children:"Admin"}):null,e.jsx("button",{className:"relay-button-secondary",onClick:()=>void p(),type:"button",children:"Refresh"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void te(),type:"button",children:"Sign out"})]})]}),x?e.jsx(ta,{tone:"danger",children:x}):null,y?e.jsxs(ta,{tone:"accent",children:["Device token for ",y.device.name,". Store it on the device as REMOTE_CODEX_RELAY_AGENT_TOKEN. It will not be shown again.",e.jsx("code",{className:"mt-2 block break-all rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 font-mono text-xs",children:y.token})]}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.2fr)_minmax(20rem,0.8fr)]",children:[e.jsxs(qt,{title:"Devices",description:"Owned devices and sessions shared with you.",children:[e.jsx(Fo,{onCreate:w}),e.jsx("div",{className:"mt-4 divide-y divide-[var(--theme-border)] rounded-lg border border-[var(--theme-border)]",children:l!=null&&l.devices.length?l.devices.map(i=>e.jsxs("div",{className:"flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${i.connected?"bg-emerald-500":"bg-[var(--theme-fg-muted)]"}`}),e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:i.name})]}),e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--theme-fg-muted)]",children:i.tokenPreview})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{className:"relay-button-primary",disabled:!i.connected,onClick:()=>ae(i.id),type:"button",children:"Open"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void P(i.id),type:"button",children:"Delete"})]})]},i.id)):e.jsx("p",{className:"p-3 text-sm text-[var(--theme-fg-muted)]",children:"No devices yet."})}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--theme-fg)]",children:"Shared"}),e.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:(l==null?void 0:l.sharedWithMe.length)??0})]}),e.jsx("div",{className:"mt-3 space-y-3",children:l!=null&&l.sharedWithMe.length?l.sharedWithMe.map(i=>e.jsx("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:i.label||i.threadId}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:[i.ownerUsername," / ",i.deviceName]})]}),e.jsx("button",{className:"relay-button-primary",onClick:()=>V(i.deviceId,i.threadId),type:"button",children:"Continue"})]})},i.id)):e.jsx("p",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3 text-sm text-[var(--theme-fg-muted)]",children:"No shared sessions."})})]})]}),e.jsx(qt,{title:"Invite",description:"Share a single thread with another relay user.",children:e.jsx(qo,{devices:(l==null?void 0:l.devices)??[],onShare:M})})]}),e.jsx("section",{children:e.jsx(qt,{title:"Shared By Me",description:"Active invitations you created.",children:e.jsx("div",{className:"space-y-3",children:l!=null&&l.sharedByMe.length?l.sharedByMe.map(i=>e.jsxs("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:i.label||i.threadId}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:["Shared with ",i.targetUsername," on ",i.deviceName]}),e.jsx("button",{className:"relay-button-secondary mt-3",onClick:()=>void $(i.id),type:"button",children:"Revoke"})]},i.id)):e.jsx("p",{className:"text-sm text-[var(--theme-fg-muted)]",children:"No active shares."})})})})]})}):e.jsx(Ft,{children:e.jsx(Bo,{registrationEnabled:(a==null?void 0:a.registrationEnabled)??!0,initialError:x,onAuthenticated:I})})}function Bo({registrationEnabled:t,initialError:a,onAuthenticated:r}){const[l,c]=o.useState("login"),[u,m]=o.useState(""),[x,N]=o.useState(""),[y,C]=o.useState(""),[p,I]=o.useState(""),[w,P]=o.useState(a),[M,$]=o.useState(!1);async function te(ae){ae.preventDefault(),$(!0),P(null);try{l==="login"?await wn({identifier:u,password:p}):await jn({email:x,username:y,password:p}),await r()}catch(V){P(Ct(V,"Unable to authenticate with relay."))}finally{$(!1)}}return e.jsxs("section",{className:"w-full max-w-sm rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-xl shadow-black/10",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:l==="login"?"Sign in":"Create account"}),e.jsxs("form",{className:"mt-5 space-y-4",onSubmit:te,children:[l==="login"?e.jsx(He,{autoComplete:"username",label:"Email or username",onChange:m,value:u}):e.jsxs(e.Fragment,{children:[e.jsx(He,{autoComplete:"email",label:"Email",onChange:N,value:x}),e.jsx(He,{autoComplete:"username",label:"Username",onChange:C,value:y})]}),e.jsx(He,{autoComplete:l==="login"?"current-password":"new-password",label:"Password",onChange:I,type:"password",value:p}),w?e.jsx(ta,{tone:"danger",children:w}):null,e.jsx("button",{className:"relay-button-primary h-11 w-full",disabled:M,type:"submit",children:M?"Working...":l==="login"?"Sign in":"Register"})]}),e.jsx("button",{className:"mt-4 text-sm text-[var(--theme-accent-strong)] disabled:text-[var(--theme-fg-muted)]",disabled:l==="login"?!t:!1,onClick:()=>c(l==="login"?"register":"login"),type:"button",children:l==="login"?t?"Create relay account":"Registration is disabled":"Use an existing account"})]})}function Fo({onCreate:t}){const[a,r]=o.useState(""),[l,c]=o.useState(!1),[u,m]=o.useState(null);async function x(N){N.preventDefault(),c(!0),m(null);try{await t(a),r("")}catch(y){m(Ct(y,"Unable to create device."))}finally{c(!1)}}return e.jsxs("form",{className:"flex flex-col gap-2 sm:flex-row",onSubmit:x,children:[e.jsx("input",{className:"relay-input min-w-0 flex-1",onChange:N=>r(N.target.value),placeholder:"Device name",value:a}),e.jsx("button",{className:"relay-button-primary",disabled:l||!a.trim(),type:"submit",children:"Create"}),u?e.jsx("p",{className:"text-sm text-[var(--status-danger-fg)]",children:u}):null]})}function qo({devices:t,onShare:a}){const r=o.useMemo(()=>{var $;return(($=t[0])==null?void 0:$.id)??""},[t]),[l,c]=o.useState(r),[u,m]=o.useState(""),[x,N]=o.useState(""),[y,C]=o.useState(""),[p,I]=o.useState(!1),[w,P]=o.useState(null);o.useEffect(()=>{!l&&r&&c(r)},[l,r]);async function M($){$.preventDefault(),I(!0),P(null);try{await a({targetUsername:u,deviceId:l,threadId:x,...y.trim()?{label:y}:{}}),m(""),N(""),C(""),P("Invitation created.")}catch(te){P(Ct(te,"Unable to create invitation."))}finally{I(!1)}}return e.jsxs("form",{className:"space-y-3",onSubmit:M,children:[e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:["Device",e.jsx("select",{className:"relay-input mt-2 w-full",onChange:$=>c($.target.value),value:l,children:t.map($=>e.jsx("option",{value:$.id,children:$.name},$.id))})]}),e.jsx(He,{label:"Username",onChange:m,value:u}),e.jsx(He,{label:"Thread ID",onChange:N,value:x}),e.jsx(He,{label:"Label",onChange:C,value:y}),w?e.jsx("p",{className:"text-sm text-[var(--theme-fg-muted)]",children:w}):null,e.jsx("button",{className:"relay-button-primary",disabled:p||!l||!u.trim()||!x.trim(),type:"submit",children:"Invite"})]})}function Ft({children:t}){return e.jsx("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:e.jsx("div",{className:"flex min-h-[calc(100vh-3rem)] items-center justify-center",children:t})})}function qt({title:t,description:a,children:r}){return e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:t}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:a})]}),r]})}function He({label:t,value:a,onChange:r,type:l="text",autoComplete:c}){return e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:[t,e.jsx("input",{autoComplete:c,className:"relay-input mt-2 w-full",onChange:u=>r(u.target.value),type:l,value:a})]})}function ta({tone:t,children:a}){return e.jsx("div",{className:`rounded-lg border px-3 py-2 text-sm ${t==="danger"?"border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)]":"border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] text-[var(--theme-fg)]"}`,children:a})}function _o(t){return t.sandboxMode??(t.approvalMode==="guarded"?"workspace-write":"danger-full-access")}function Wo(t,a){const r=new Set(a.map(l=>l.id));return[...a,...t.filter(l=>!r.has(l.id))]}function De(t,a){const r=new Set(a.map(l=>l.id));return[...t.filter(l=>!r.has(l.id)),...a]}function zo(t,a){return{...t,pendingRequests:[...t.pendingRequests.filter(r=>r.id!==a.id),a]}}function Go(t,a){const r=t.pendingRequests.filter(l=>l.id!==a);return r.length===t.pendingRequests.length?t:{...t,pendingRequests:r}}function us(t,a,r){const l=a.filter(x=>!r.has(x.id)),c=t.filter(x=>!r.has(x.id));if(c.length===0)return l;const u=new Map(l.map(x=>[x.id,x]));return[...c.map(x=>u.get(x.id)??x),...l.filter(x=>!c.some(N=>N.id===x.id))].sort((x,N)=>x.createdAt.localeCompare(N.createdAt))}function Vo(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.id=="string"&&(a.kind==="requestUserInput"||a.kind==="planDecision")&&typeof a.title=="string"&&typeof a.createdAt=="string"&&Array.isArray(a.questions)}function Vs(t,a){var u,m;if(!t||t.kind!==a.kind)return a;const r=x=>{let N=x;const y=typeof a.sequence=="number"&&Number.isFinite(a.sequence)?a.sequence:typeof t.sequence=="number"&&Number.isFinite(t.sequence)?t.sequence:null;y!==null&&N.sequence!==y&&(N={...N,sequence:y});const C=typeof a.transcriptOrder=="number"&&Number.isFinite(a.transcriptOrder)?a.transcriptOrder:typeof t.transcriptOrder=="number"&&Number.isFinite(t.transcriptOrder)?t.transcriptOrder:null;return C!==null&&N.transcriptOrder!==C&&(N={...N,transcriptOrder:C}),N};if(t.kind==="agentMessage"&&a.kind==="agentMessage")return r(t.text.length>a.text.length?{...a,text:t.text,sequence:a.sequence??t.sequence??null}:a);const l=((u=t.detailText)==null?void 0:u.trim())||t.text.trim(),c=((m=a.detailText)==null?void 0:m.trim())||a.text.trim();return r(l.length>c.length?t:a)}function Jo(t,a,r){if(!t||a&&a.turnId!==t.turnId)return a;const l=r.find(p=>p.id===t.turnId),c=new Map((l==null?void 0:l.items.map(p=>[p.id,p]))??[]),u=(l==null?void 0:l.items.filter(p=>p.kind==="agentMessage").map(p=>p.text.trim()).filter(Boolean))??[],m=p=>p.kind==="agentMessage"&&p.text.trim().length>0&&u.some(I=>I.includes(p.text.trim()));if(!a){const p=t.items.filter(I=>{const w=c.get(I.id);return w?w.kind!==I.kind||typeof I.sequence=="number"&&Number.isFinite(I.sequence)&&w.sequence!==I.sequence:!m(I)});return p.length===0?null:{...t,items:p}}const x=new Map(t.items.map(p=>[p.id,p])),N=new Map(a.items.map(p=>[p.id,p])),C=[...t.items.map(p=>p.id),...a.items.map(p=>p.id).filter(p=>!x.has(p))].map(p=>{const I=N.get(p),w=x.get(p);if(!I){const P=c.get(p);return!P&&w&&m(w)||P&&P.kind===(w==null?void 0:w.kind)&&!(w&&typeof w.sequence=="number"&&Number.isFinite(w.sequence)&&P.sequence!==w.sequence)?null:w??null}return Vs(w,I)}).filter(p=>!!p);return C.length===0?null:{turnId:a.turnId,items:C,updatedAt:a.updatedAt.localeCompare(t.updatedAt)>=0?a.updatedAt:t.updatedAt}}function Xe(t,a){const r=t.filter(l=>l.id!==a.id);return[a,...r]}function Ko(t){return`${t.threadId}:${t.objective}:${t.createdAt}`}function Zo(t,a){const r=Date.parse(t.updatedAt)||0,c=(Date.parse(a.updatedAt)||0)>=r?a:t,u=c===a?t:a;return{...c,localGoalId:c.localGoalId??u.localGoalId??null}}function Js(t){const a=new Map;for(const r of t){const l=Ko(r),c=a.get(l);a.set(l,c?Zo(c,r):r)}return[...a.values()].sort((r,l)=>Date.parse(l.updatedAt)-Date.parse(r.updatedAt))}function yt(t,a){return Js([a,...t])}function Yo(t){const a=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});return t.tokenBudget===null?`${a.format(t.tokensUsed)} tok`:`${a.format(t.tokensUsed)}/${a.format(t.tokenBudget)} tok`}function Xo(t){const a=Math.max(0,Math.floor(t/60)),r=Math.floor(a/60),l=a%60;return r>0?`${r}h ${l}m`:`${a}m`}function ms(t,a){if(!a)return null;const r=t.find(l=>l.model===a);return r?r.supportedReasoningEfforts.length>1:null}function Qo(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function Qe(t,a){return(t==null?void 0:t.items.some(r=>r.kind==="userMessage"&&r.text.trim()===a))??!1}function hs(t){return t.replace(/\s*\[PHOTO\s+[^\]]+\]\s*/g," ").replace(/\s+/g," ").trim()}function kt(t,a){const r=hs(a);return r?(t==null?void 0:t.items.some(l=>l.kind==="userMessage"&&hs(l.text)===r))??!1:!1}function _t(t){return(t==null?void 0:t.items.some(a=>a.kind==="userMessage"&&/\[PHOTO\s+\.\/\.temp\/threads\/[^\]]+\]/.test(a.text)))??!1}function el(t,a){return t.find(r=>Qe(r,a))??(a.includes("[PHOTO ")?t.find(r=>kt(r,a))??null:null)}function tl(t,a,r,l){let c=!1;const u=t.map(m=>m.id!==a?m:(c=!0,{...m,tokenUsage:r,priceEstimate:l}));return c?u:t}const fs=3,al=10,sl=1e3,rl=2e3,Wt=5500,nl=3e3,zt=0,ze=1,wt=3,ol=["read-only","workspace-write","danger-full-access"],ll=[],il=[],dl=[],cl={workspace:!0,toolUsage:!1,guide:!1,threadGraph:!1,extensions:!1,defaultTab:"workspace"};function ul(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-current",children:e.jsx("path",{d:"M5.75 1.75c-.97 0-1.75.78-1.75 1.75v.25H3.5c-.97 0-1.75.78-1.75 1.75v6c0 .97.78 1.75 1.75 1.75h4.75c.97 0 1.75-.78 1.75-1.75v-.25h.5c.97 0 1.75-.78 1.75-1.75v-6c0-.97-.78-1.75-1.75-1.75h-4.75Zm-.5 2V3.5c0-.28.22-.5.5-.5h4.75c.28 0 .5.22.5.5v6a.5.5 0 0 1-.5.5H10v-4.5c0-.97-.78-1.75-1.75-1.75h-3Zm-1.75 1.25h4.75c.28 0 .5.22.5.5v6a.5.5 0 0 1-.5.5H3.5a.5.5 0 0 1-.5-.5v-6c0-.28.22-.5.5-.5Z"})})}function ml(){return e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4.25 2.25h5.2l2.3 2.3v9.2h-7.5a2 2 0 0 1-2-2v-7.5a2 2 0 0 1 2-2Z"}),e.jsx("path",{d:"M9.25 2.5v2.25h2.25"}),e.jsx("path",{d:"M7 6.75v4"}),e.jsx("path",{d:"m5.45 9.35 1.55 1.55 1.55-1.55"})]})}function jt({status:t}){return e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2.5 6.75A8.22 8.22 0 0 1 8 4.5c2.14 0 4.1.8 5.5 2.25"}),e.jsx("path",{d:"M4.75 9a4.95 4.95 0 0 1 6.5 0"}),e.jsx("path",{d:"M6.9 11.3a1.9 1.9 0 0 1 2.2 0"}),t==="connected"?e.jsx("path",{d:"m6.7 13.2.9.9 1.7-2"}):t==="offline"?e.jsx("path",{d:"M3 3l10 10"}):t==="detached"?null:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11.8 11.1a2.2 2.2 0 0 1-1.8 2.7"}),e.jsx("path",{d:"m10.7 11.35 1.3-.55-.55-1.3"})]})]})}function hl(t,a){if(!t)return"Thread disconnected";switch(a.status){case"connected":return"Realtime updates connected";case"reconnecting":return"Realtime updates reconnecting";case"offline":return"Browser offline";case"checking":return"Checking realtime connection"}}function fl(){var as;const{id:t=""}=Gr(),a=Ee(),r=Be(),l=ws(),c=o.useRef(""),u=o.useRef(null),m=o.useRef(null),x=o.useRef(null),N=o.useRef(!1),y=o.useRef(null),C=o.useRef(null),p=o.useRef(typeof navigator>"u"?!0:navigator.onLine),I=o.useRef(!1),w=o.useRef(null),P=o.useRef(null),M=o.useRef(0),$=o.useRef(0),te=o.useRef(null),ae=o.useRef(null),V=o.useRef(null),D=o.useRef(null),oe=o.useRef(new Set),[i,B]=o.useState(null),[ne,F]=o.useState([]),[Y,J]=o.useState([]),[R,W]=o.useState(null),[E,z]=o.useState(null),[H,Ne]=o.useState(null),[be,O]=o.useState(""),[K,X]=o.useState(null),[de,ue]=o.useState(null),[It,Et]=o.useState(!0),[et,tt]=o.useState(0),[at,st]=o.useState(!0),[Ue,Fe]=o.useState(!1),[h,g]=o.useState(!1),[v,L]=o.useState("chat"),se=l.getThreadPanels().some(s=>s.kind==="terminal"),xe=o.useMemo(()=>({fetchState:eo,createShell:so,terminateShell:ro,updateShell:no,connectSocket:Co}),[]),Re=o.useCallback(s=>`/threads/${s}`,[]),Se=o.useCallback(s=>{a(`/threads/${s}`)},[a]),rt=o.useCallback(s=>s?`/threads/new?workspaceId=${encodeURIComponent(s)}`:"/threads/new",[]),Le=o.useCallback(({threadId:s,path:n})=>`/api/threads/${s}/assets/image?path=${encodeURIComponent(n)}`,[]),[nt,Oe]=o.useState({prompt:"",attachments:[]}),[Je,Qs]=o.useState(!1),[er,tr]=o.useState(0),[ar,la]=o.useState(0),[ia,sr]=o.useState(0),[da,rr]=o.useState(!1),[q,ca]=o.useState(null),[ua,Ke]=o.useState(!1),[ma,ha]=o.useState(!1),[nr,fa]=o.useState(!1),[pa,ga]=o.useState(null),[$e,ot]=o.useState("idle"),[Pe,xa]=o.useState({status:p.current?"checking":"offline",browserOnline:p.current,healthOk:!1,socketOpen:!1,lastHealthyAt:null}),[re,Te]=o.useState(null),[lt,qe]=o.useState([]),[or,it]=o.useState({status:"idle",data:null,error:null}),[lr,dt]=o.useState({status:"idle",data:null,error:null}),[ir,fe]=o.useState({status:"idle",data:null,error:null}),[dr,ct]=o.useState({status:"idle",data:null,error:null}),[ut,we]=o.useState({status:"idle",data:null,error:null}),[cr,ba]=o.useState(!1),[Rt,mt]=o.useState(!1),[ur,mr]=o.useState(()=>new Set),[hr,ht]=o.useState(!1),[va,ya]=o.useState(!1),[fr,ft]=o.useState({status:"idle",data:null,error:null}),[Ie,Ot]=o.useState(null),[wa,ja]=o.useState(!1),[pr,Q]=o.useState(null),Pt=((as=H==null?void 0:H.hostConfigFiles.find(s=>{var n;return(n=s.roles)==null?void 0:n.includes("mcp")}))==null?void 0:as.name)??null,Na=o.useCallback(()=>{const s=c.current;c.current="",u.current=null,s&&o.startTransition(()=>{O(n=>n+s)})},[]),ka=o.useCallback(s=>{c.current+=s,u.current===null&&(u.current=window.requestAnimationFrame(()=>{Na()}))},[Na]),Sa=o.useCallback((s,n)=>{ue(d=>{const b=(d==null?void 0:d.turnId)===s?d.items:[],j=b.findIndex(ce=>ce.id===n.id),A=Vs(b[j],n),_=j>=0?b.map((ce,S)=>S===j?A:ce):[...b,A];return{turnId:s,items:_,updatedAt:new Date().toISOString()}})},[]),Ta=o.useCallback((s,n,d,b)=>{ue(j=>{const A=(j==null?void 0:j.turnId)===s?j.items:[],_=A.find(me=>me.id===n),ce=(_==null?void 0:_.kind)==="agentMessage"?{..._,text:`${_.text}${d}`,sequence:b??_.sequence??null}:{id:n,kind:"agentMessage",text:d,sequence:b},S=A.findIndex(me=>me.id===n),ge=S>=0?A.map((me,he)=>he===S?ce:me):[...A,ce];return{turnId:s,items:ge,updatedAt:new Date().toISOString()}})},[]),Ce=o.useCallback(()=>{c.current="",u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null)},[]);o.useEffect(()=>{it({status:"idle",data:null,error:null}),dt({status:"idle",data:null,error:null}),fe({status:"idle",data:null,error:null}),ct({status:"idle",data:null,error:null}),we({status:"idle",data:null,error:null}),ht(!1),ft({status:"idle",data:null,error:null})},[t]);const gr=o.useCallback(async()=>{if(t){ft(s=>({status:"loading",data:s.data,error:null}));try{const s=await Yn(t);ft({status:"ready",data:s,error:null})}catch(s){const n=s instanceof G?s.payload.message:"Unable to load export turns.";ft(d=>({status:"failed",data:d.data,error:n}))}}},[t]);async function xr(s){if(t){Q(null),ya(!0);try{const{blob:n,filename:d}=await Qn(t,s),b=URL.createObjectURL(n),j=document.createElement("a");j.href=b,j.download=d,document.body.append(j),j.click(),j.remove(),window.setTimeout(()=>URL.revokeObjectURL(b),3e4),ht(!1)}catch(n){const d=n instanceof G?n.payload.message:"Unable to export transcript.";Q(d)}finally{ya(!1)}}}async function Ca(){if(t){we(s=>{var n;return{status:"loading",data:s.data??((n=V.current)==null?void 0:n.goal)??null,error:null}});try{const s=await uo(t);we({status:"ready",data:s.goal,error:null}),B(n=>n&&(s.goal?{...n,goal:s.goal,goalHistory:yt(n.goalHistory??[],s.goal)}:{...n,goal:s.goal}))}catch(s){we(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to load goal."}))}}}async function Ia(s){if(t){we(n=>{var d;return{status:"loading",data:n.data??((d=V.current)==null?void 0:d.goal)??null,error:null}});try{const n=await mo(t,s);we({status:"ready",data:n.goal,error:null}),B(d=>d&&(n.goal?{...d,goal:n.goal,goalHistory:yt(d.goalHistory??[],n.goal)}:{...d,goal:n.goal}))}catch(n){throw we(d=>({status:"failed",data:d.data,error:n instanceof G?n.payload.message:"Unable to update goal."})),n}}}async function br(){if(t){we(s=>{var n;return{status:"loading",data:s.data??((n=V.current)==null?void 0:n.goal)??null,error:null}});try{const s=await ho(t);we({status:"ready",data:null,error:null}),B(n=>n&&(s.goalHistory?{...n,goal:null,goalHistory:s.goalHistory}:{...n,goal:null}))}catch(s){throw we(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to clear goal."})),s}}}async function Ea(s){mt(!0);try{await Ia({status:s})}finally{mt(!1)}}async function vr(){mt(!0);try{await br()}finally{mt(!1)}}async function yr(){if(t){it(s=>({status:"loading",data:s.data,error:null}));try{const s=await po(t);it({status:"ready",data:s,error:null})}catch(s){it(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to load skills."}))}}}async function wr(){if(t){dt(s=>({status:"loading",data:s.data,error:null}));try{const s=await go(t);dt({status:"ready",data:s,error:null})}catch(s){dt(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to load MCP servers."}))}}}async function jr(){if(t){fe(s=>({status:"loading",data:s.data,error:null}));try{const s=await xo(t);fe({status:"ready",data:s,error:null})}catch(s){fe(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to load hooks."}))}}}async function Nr(s){if(t){fe(n=>({status:"loading",data:n.data,error:null}));try{const n=await bo(t,s);fe({status:"ready",data:n,error:null})}catch(n){throw fe(d=>({status:"failed",data:d.data,error:n instanceof G?n.payload.message:"Unable to create hook."})),n}}}async function kr(s){if(t){fe(n=>({status:"loading",data:n.data,error:null}));try{const n=await vo(t,s);fe({status:"ready",data:n,error:null})}catch(n){throw fe(d=>({status:"failed",data:d.data,error:n instanceof G?n.payload.message:"Unable to update hook."})),n}}}async function Sr(s){if(t){fe(n=>({status:"loading",data:n.data,error:null}));try{const n=await yo(t,s);fe({status:"ready",data:n,error:null})}catch(n){throw fe(d=>({status:"failed",data:d.data,error:n instanceof G?n.payload.message:"Unable to trust hook."})),n}}}async function Tr(s){if(t){fe(n=>({status:"loading",data:n.data,error:null}));try{const n=await wo(t,s);fe({status:"ready",data:n,error:null})}catch(n){throw fe(d=>({status:"failed",data:d.data,error:n instanceof G?n.payload.message:"Unable to untrust hook."})),n}}}async function Cr(){if(t){ct(s=>({status:"loading",data:s.data,error:null}));try{const s=await fo(t);ct({status:"ready",data:s,error:null})}catch(s){ct(n=>({status:"failed",data:n.data,error:s instanceof G?s.payload.message:"Unable to load turns for forking."}))}}}async function Ir(){if(!t)return;const s=await ds(t,{mode:"latest"});F(n=>Xe(n,s.thread.thread)),a(`/threads/${s.thread.thread.id}`)}async function Er(s){if(!t)return;const n=await ds(t,{mode:"turn",turnId:s});F(d=>Xe(d,n.thread.thread)),a(`/threads/${n.thread.thread.id}`)}const Ra=o.useCallback(s=>{const n=D.current,d=n&&Object.keys(n).length>0?{...s,thread:{...s.thread,...n}}:s,b=V.current;V.current=d,X(d.livePlan??null);const j=b?De(b.turns,d.turns):d.turns;ue(S=>Jo(S,d.liveItems??null,j)),we(S=>S.status==="idle"?S:{...S,data:d.goal??null});const A=d.thread.activeTurnId===null&&d.thread.status!=="running";B(S=>S&&!d.goalHistory?{...d,turns:De(S.turns,d.turns),pendingRequests:us(S.pendingRequests,d.pendingRequests,oe.current),...S.goalHistory?{goalHistory:S.goalHistory}:{}}:S?{...d,turns:De(S.turns,d.turns),pendingRequests:us(S.pendingRequests,d.pendingRequests,oe.current)}:d),F(S=>Xe(S,d.thread));const _=new Map(d.turns.map(S=>[S.id,S])),ce=new Set((d.pendingSteers??[]).map(S=>S.clientRequestId).filter(S=>!!S));qe(S=>S.filter(ge=>{if(ce.has(ge.clientRequestId))return!1;const me=_.get(ge.turnId);return!(!me||Qe(me,ge.prompt)||d.thread.activeTurnId!==ge.turnId&&me.status!=="inProgress")})),Te(S=>{if(!S)return S;const ge=S.serverTurnId??S.id,me=d.turns.some(k=>k.id===ge),he=_.get(ge)??null,ee=el(d.turns,S.prompt),f=!!ee;if(ee&&!S.serverTurnId)return{...S,id:ee.id,serverTurnId:ee.id,status:S.status==="failed"?S.status:ee.status==="inProgress"?"inProgress":S.status};if(he&&S.serverTurnId)return Qe(he,S.prompt)||S.prompt.includes("[PHOTO ")&&(kt(he,S.prompt)||_t(he))?he.status==="inProgress"?{...S,id:he.id,serverTurnId:he.id,status:S.status==="failed"?S.status:"inProgress"}:null:{...S,id:he.id,serverTurnId:he.id,status:S.status==="failed"?S.status:"inProgress"};if(!S.serverTurnId&&S.prompt.includes("[PHOTO ")&&d.thread.activeTurnId&&d.thread.status==="running"){const k=_.get(d.thread.activeTurnId);if(k&&_t(k))return{...S,id:k.id,serverTurnId:k.id,status:S.status==="failed"?S.status:"inProgress"}}return me||A&&f?null:S}),(A||ae.current&&d.turns.some(S=>S.id===ae.current))&&(ae.current=null,Ce(),O(""),X(null),ue(null))},[Ce]);o.useEffect(()=>{V.current=i},[i]);const Oa=o.useCallback(async({seedThread:s}={})=>{var _;const n=$.current+1;$.current=n;const d=(s==null?void 0:s.provider)??((_=V.current)==null?void 0:_.thread.provider)??"codex",[b,j,A]=await Promise.allSettled([Hs(),Ls(d),Qt(d)]);$.current===n&&(b.status==="fulfilled"?F(s?Xe(b.value,s):b.value):s&&F(ce=>Xe(ce,s)),j.status==="fulfilled"&&(te.current=d,W(j.value.status),z(j.value.capabilities),Ne(j.value.managementSchema)),A.status==="fulfilled"&&(te.current=d,J(A.value)))},[]),_e=o.useCallback(async({showLoading:s=!0,clearError:n=!0,reportError:d=!0,limit:b=fs}={})=>{const j=M.current+1;M.current=j,s&&st(!0),n&&Q(null);try{const A=await os(t,{limit:b});if(M.current!==j)return;Ra(A),te.current!==A.thread.provider&&Oa({seedThread:A.thread})}catch(A){if(M.current!==j||!d)return;Q(A instanceof Error?A.message:"Unable to load thread detail.")}finally{M.current===j&&st(!1)}},[Ra,t,Oa]),pe=o.useCallback(()=>{var ce;const s=((ce=m.current)==null?void 0:ce.readyState)??wt,n=s===ze,d=p.current,b=Date.now(),j=y.current!==null&&b-Date.parse(y.current)<=Wt,A=C.current!==null&&b-C.current<=Wt;let _;d?n&&A?_="connected":s===zt||x.current!==null||j||A||N.current?_="reconnecting":_="checking":_="offline",xa(S=>S.status===_&&S.browserOnline===d&&S.healthOk===j&&S.socketOpen===n&&S.lastHealthyAt===y.current?S:{status:_,browserOnline:d,healthOk:j,socketOpen:n,lastHealthyAt:y.current})},[]);o.useEffect(()=>{M.current+=1,$.current+=1,B(null),Oe({prompt:"",attachments:[]}),Fe(!1),ot("idle"),Te(null),qe([]),ue(null),D.current=null,ae.current=null,oe.current=new Set,y.current=null,C.current=null,I.current=!1,p.current=typeof navigator>"u"?!0:navigator.onLine,xa({status:p.current?"checking":"offline",browserOnline:p.current,healthOk:!1,socketOpen:!1,lastHealthyAt:null})},[t]),o.useEffect(()=>{if($e==="idle")return;const s=window.setTimeout(()=>{ot("idle")},$e==="copied"?1200:1600);return()=>{window.clearTimeout(s)}},[$e]),o.useEffect(()=>{if(typeof document>"u")return;const{documentElement:s,body:n}=document;return s.classList.add("thread-detail-scroll-locked"),n.classList.add("thread-detail-scroll-locked"),()=>{s.classList.remove("thread-detail-scroll-locked"),n.classList.remove("thread-detail-scroll-locked")}},[]),o.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(max-width: 639px)"),n=()=>Qs(s.matches);return n(),s.addEventListener("change",n),()=>{s.removeEventListener("change",n)}},[]),o.useEffect(()=>{var n,d;if(typeof window>"u")return;const s=()=>{const b=window.visualViewport,j=b?Math.max(0,Math.round(window.innerHeight-b.height-b.offsetTop)):0;sr(j),document.documentElement.style.setProperty("--thread-detail-keyboard-inset",`${j}px`)};return s(),(n=window.visualViewport)==null||n.addEventListener("resize",s),(d=window.visualViewport)==null||d.addEventListener("scroll",s),window.addEventListener("resize",s),()=>{var b,j;(b=window.visualViewport)==null||b.removeEventListener("resize",s),(j=window.visualViewport)==null||j.removeEventListener("scroll",s),window.removeEventListener("resize",s),document.documentElement.style.removeProperty("--thread-detail-keyboard-inset")}},[]),o.useEffect(()=>{if(typeof document>"u")return;const s=()=>{const n=document.activeElement,d=P.current,b=d==null?void 0:d.querySelector('[aria-label="Prompt"]');rr(!!(n&&b&&(n===b||b.contains(n))))};return s(),document.addEventListener("focusin",s),document.addEventListener("focusout",s),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",s)}},[v,i==null?void 0:i.thread.id,Je]),o.useEffect(()=>{const s=P.current;if(!s||typeof ResizeObserver>"u")return;const n=s.querySelector("form")??s,d=()=>{tr(Math.max(s.getBoundingClientRect().height,n.getBoundingClientRect().height))};d();const b=new ResizeObserver(()=>{d()});return b.observe(n),()=>{b.disconnect()}},[v,Je]),o.useEffect(()=>{var b,j;const s=P.current;if(!s||!Je||v!=="chat"){la(0);return}const n=()=>{const A=s.getBoundingClientRect();la(Math.max(0,Math.ceil(window.innerHeight-A.top)))};n(),window.addEventListener("resize",n),(b=window.visualViewport)==null||b.addEventListener("resize",n),(j=window.visualViewport)==null||j.addEventListener("scroll",n);let d=null;return typeof ResizeObserver<"u"&&(d=new ResizeObserver(n),d.observe(s)),()=>{var A,_;window.removeEventListener("resize",n),(A=window.visualViewport)==null||A.removeEventListener("resize",n),(_=window.visualViewport)==null||_.removeEventListener("scroll",n),d==null||d.disconnect()}},[v,i==null?void 0:i.thread.id,Je,ia,da]),o.useEffect(()=>{_e({showLoading:!0,limit:fs})},[_e]),o.useEffect(()=>{let s=!1,n=null;const d=()=>{_e({showLoading:!1,clearError:!1,reportError:!1})},b=()=>{x.current!==null&&(window.clearTimeout(x.current),x.current=null)},j=()=>{s||!p.current||x.current!==null||(x.current=window.setTimeout(()=>{x.current=null,!s&&S()},sl),pe())},A=()=>{const f=m.current;if(m.current=null,f)try{f.close()}catch{}},_=f=>{if(f.threadId===t){if(f.type==="thread.output.delta"&&typeof f.payload.delta=="string"){const k=typeof f.payload.turnId=="string"?f.payload.turnId:null,U=typeof f.payload.itemId=="string"?f.payload.itemId:null,le=typeof f.payload.sequence=="number"&&Number.isFinite(f.payload.sequence)?f.payload.sequence:null;k&&U?Ta(k,U,f.payload.delta,le):ka(f.payload.delta),k&&Te(Z=>Z&&(Z.serverTurnId===null||Z.serverTurnId===k)?{...Z,serverTurnId:k,id:k,status:Z.status==="failed"?Z.status:"inProgress",tokenUsage:Z.tokenUsage}:Z)}if(f.type==="thread.context.updated"){const k=f.payload.contextUsage&&typeof f.payload.contextUsage=="object"?f.payload.contextUsage:null;if(k){const U=k;B(le=>le&&{...le,thread:{...le.thread,contextUsage:U}}),F(le=>le.map(Z=>Z.id===t?{...Z,contextUsage:U}:Z))}}if(f.type==="thread.turn.token.updated"&&typeof f.payload.turnId=="string"&&f.payload.tokenUsage&&typeof f.payload.tokenUsage=="object"){const k=f.payload.turnId,U=f.payload.tokenUsage,le=f.payload.priceEstimate&&typeof f.payload.priceEstimate=="object"?f.payload.priceEstimate:null;B(Z=>{if(!Z)return Z;const ve=tl(Z.turns,k,U,le);return ve===Z.turns?Z:{...Z,turns:ve}}),Te(Z=>Z&&(Z.serverTurnId===k||Z.id===k)?{...Z,tokenUsage:U,priceEstimate:le}:Z)}if(f.type==="thread.turn.started"||f.type==="thread.turn.completed"||f.type==="thread.turn.failed"||f.type==="thread.updated"||f.type==="thread.goal.updated"||f.type==="thread.goal.cleared"||f.type==="thread.request.created"||f.type==="thread.request.resolved"){if(f.type==="thread.goal.updated"){const k=f.payload.goal&&typeof f.payload.goal=="object"?f.payload.goal:null,U=Array.isArray(f.payload.goalHistory)?f.payload.goalHistory:null;we({status:"ready",data:k,error:null}),B(le=>le&&(U?{...le,goal:k,goalHistory:U}:k?{...le,goal:k,goalHistory:yt(le.goalHistory??[],k)}:{...le,goal:k}))}if(f.type==="thread.goal.cleared"){const k=Array.isArray(f.payload.goalHistory)?f.payload.goalHistory:null;we({status:"ready",data:null,error:null}),B(U=>U&&(k?{...U,goal:null,goalHistory:k}:{...U,goal:null}))}if(d(),f.type==="thread.turn.started"){Ce(),O(""),ue(null),ae.current=null;const k=typeof f.payload.turnId=="string"?f.payload.turnId:null;k&&Te(U=>U&&{...U,serverTurnId:k,id:k,status:U.status==="failed"?U.status:"inProgress",error:null,tokenUsage:U.tokenUsage})}if(f.type==="thread.turn.completed"||f.type==="thread.turn.failed"){Ce(),O("");const k=typeof f.payload.turnId=="string"?f.payload.turnId:null;k&&(ae.current=k,f.type==="thread.turn.failed"&&Te(U=>U&&(U.serverTurnId===k||U.id===k)?{...U,status:"failed",error:typeof f.payload.error=="string"?f.payload.error:"Unable to complete the turn.",tokenUsage:U.tokenUsage}:U))}}if(f.type==="thread.request.created"&&Vo(f.payload.request)&&(oe.current.delete(f.payload.request.id),B(k=>k&&zo(k,f.payload.request))),f.type==="thread.request.resolved"&&typeof f.payload.requestId=="string"){const k=f.payload.requestId;oe.current.add(k),B(U=>U&&Go(U,k))}if((f.type==="thread.item.started"||f.type==="thread.item.completed")&&f.payload.item&&typeof f.payload.item=="object"&&typeof f.payload.turnId=="string"){const k=f.payload.turnId,U=f.payload.item;typeof U.id=="string"&&typeof U.text=="string"&&Sa(k,U)}f.type==="thread.plan.updated"&&Array.isArray(f.payload.plan)&&X({turnId:String(f.payload.turnId??""),explanation:typeof f.payload.explanation=="string"?f.payload.explanation:null,plan:f.payload.plan})}},ce=()=>{const f=m.current;if(!(!f||f.readyState!==ze))try{f.send(JSON.stringify({type:"supervisor.ping",timestamp:new Date().toISOString()}))}catch{I.current=!0,A(),j(),pe()}},S=()=>{var U;if(s||!p.current){pe();return}const f=((U=m.current)==null?void 0:U.readyState)??wt;if(f===zt||f===ze){pe();return}const k=qs(_);m.current=k,pe(),k.addEventListener("message",le=>{if(m.current===k)try{const Z=JSON.parse(le.data);(Z.type==="supervisor.connected"||Z.type==="supervisor.pong")&&(C.current=Date.now(),pe())}catch{}}),k.addEventListener("open",()=>{m.current===k&&(I.current=!0,d(),ce(),pe())}),k.addEventListener("close",()=>{m.current===k&&(m.current=null),I.current=!0,j(),pe()}),k.addEventListener("error",()=>{m.current===k&&(m.current=null),I.current=!0,j(),pe()})},ge=async()=>{var f;if(!(s||!p.current||N.current)){N.current=!0,pe();try{await Fn();const k=I.current;y.current=new Date().toISOString(),k&&(I.current=!1,d()),(((f=m.current)==null?void 0:f.readyState)??wt)!==ze&&S()}catch{y.current=null,I.current=!0,j()}finally{N.current=!1,pe()}}},me=()=>{p.current=!0,I.current=!0,pe(),S(),ge()},he=()=>{p.current=!1,y.current=null,C.current=null,I.current=!0,b(),A(),pe()},ee=()=>{var U;if(s||!p.current){pe();return}const f=((U=m.current)==null?void 0:U.readyState)??wt,k=C.current===null?null:Date.now()-C.current;f===ze&&k!==null&&k>Wt?(I.current=!0,A(),j()):f===ze?ce():f!==zt&&S(),ge(),pe()};return window.addEventListener("online",me),window.addEventListener("offline",he),S(),ge(),n=window.setInterval(ee,rl),()=>{s=!0,window.removeEventListener("online",me),window.removeEventListener("offline",he),b(),n!==null&&window.clearInterval(n),Ce(),A()}},[Ta,Ce,t,_e,ka,pe,Sa]),o.useEffect(()=>{if(!((i==null?void 0:i.thread.activeTurnId)!==null||(i==null?void 0:i.thread.status)==="running"||re!==null||lt.length>0||be.length>0||K!==null||de!==null))return;const n=window.setInterval(()=>{_e({showLoading:!1,clearError:!1,reportError:!1})},nl);return()=>{window.clearInterval(n)}},[i==null?void 0:i.thread.activeTurnId,i==null?void 0:i.thread.status,be.length,de,K,_e,lt.length,re]);const Pa=o.useCallback(async()=>{var s;if(!(!i||i.turns.length===0||Ue)){Fe(!0),Q(null);try{const n=(s=i.turns[0])==null?void 0:s.id,d=await os(t,{limit:al,...n?{beforeTurnId:n}:{}});B(b=>b?{...d,turns:Wo(b.turns,d.turns)}:d),F(b=>b.map(j=>j.id===d.thread.id?d.thread:j))}catch(n){Q(n instanceof Error?n.message:"Unable to load earlier turns.")}finally{Fe(!1)}}},[i,t,Ue]);async function Aa(s){var ge,me,he;if(v==="shell"){if((i==null?void 0:i.thread.isLoaded)===!1)return await At({attachShell:!0}),!1;let ee=!1;if((q==null?void 0:q.shellInputEnabled)!==!0&&((q==null?void 0:q.loading)===!1&&(q==null?void 0:q.isConnecting)!==!0&&(q==null?void 0:q.status)!=="creating"&&(q==null?void 0:q.status)!=="workspace_missing"&&(await((ge=w.current)==null?void 0:ge.toggleConnection()),ee=!0),(q==null?void 0:q.isConnecting)===!0))return Q("Connecting to the shell. Try again after it attaches."),!1;if(((me=w.current)==null?void 0:me.sendCommand(s.prompt))??!1)Q(null);else return Q(ee?"Shell is still attaching. Try again after it connects.":"Connect the shell before sending commands."),!1;return!0}g(!0),Q(null),tt(ee=>ee+1);const n=V.current,d=n?{...n.thread,...D.current??{}}:null,b=(d==null?void 0:d.model)??null,j=(d==null?void 0:d.reasoningEffort)??null,A=Qo(),_=`optimistic-${Date.now()}`,ce=`optimistic-steer-${A}`,S=new Date().toISOString();try{let ee=V.current;if(ee&&!ee.thread.isLoaded){const ie={...ee.thread,...D.current??{}},je=await ls(t,{...ee.thread.model?{model:ee.thread.model}:{},...ee.thread.sandboxMode?{sandboxMode:ee.thread.sandboxMode}:{}}),ye={...je,thread:{...je.thread,model:ie.model??je.thread.model,reasoningEffort:ie.reasoningEffort??je.thread.reasoningEffort,collaborationMode:ie.collaborationMode??je.thread.collaborationMode,sandboxMode:ie.sandboxMode??je.thread.sandboxMode??null}};ee=ye,V.current=ye,B(vt=>vt?{...ye,turns:De(vt.turns,ye.turns)}:ye),F(vt=>vt.map(ss=>ss.id===ye.thread.id?ye.thread:ss))}const f=ee?{...ee.thread,...D.current??{}}:null,k=(f==null?void 0:f.status)==="running"?f.activeTurnId:null,U=v==="chat"&&!!k;U&&k?qe(ie=>[...ie,{id:ce,clientRequestId:A,turnId:k,prompt:s.prompt,createdAt:S,status:"steering"}]):(Ce(),O(""),Te({id:_,serverTurnId:null,startedAt:S,status:"sending",error:null,prompt:s.prompt,model:b,reasoningEffort:j,reasoningEffortAvailable:ms(Y,b),tokenUsage:null,priceEstimate:null}));const le={prompt:s.prompt,clientRequestId:A,...f!=null&&f.model?{model:f.model}:{},...f!=null&&f.reasoningEffort?{reasoningEffort:f.reasoningEffort}:{},...f!=null&&f.collaborationMode?{collaborationMode:f.collaborationMode}:{},...f!=null&&f.sandboxMode?{sandboxMode:f.sandboxMode}:{},...(he=s.attachments)!=null&&he.length?{attachments:s.attachments}:{}},Z=await lo(t,le),ve=D.current&&Object.keys(D.current).length>0?{...Z,...D.current}:Z;B(ie=>ie&&{...ie,thread:ve}),F(ie=>ie.map(je=>je.id===ve.id?ve:je)),U&&k?ve.activeTurnId!==null&&ve.activeTurnId!==k&&ve.lastTurnStartedAt!==(f==null?void 0:f.lastTurnStartedAt)?(Ce(),O(""),X(null),qe(je=>je.filter(ye=>ye.id!==ce)),Te({id:_,serverTurnId:ve.activeTurnId,startedAt:ve.lastTurnStartedAt??S,status:"inProgress",error:null,prompt:s.prompt,model:b,reasoningEffort:j,reasoningEffortAvailable:ms(Y,b),tokenUsage:null,priceEstimate:null})):qe(je=>je.map(ye=>ye.id===ce?{...ye,turnId:ve.activeTurnId??ye.turnId,status:"accepted"}:ye)):(Te(ie=>ie&&ie.id===_?{...ie,id:ve.activeTurnId??ie.id,serverTurnId:ve.activeTurnId??ie.serverTurnId,status:"inProgress",error:null,tokenUsage:ie.tokenUsage,priceEstimate:ie.priceEstimate}:ie),X(null)),Oe({prompt:"",attachments:[]})}catch(ee){const f=ee instanceof G?ee.payload.message:ee instanceof Error?ee.message:"Unable to send prompt.";ee instanceof G?Q(ee.payload.message):Q(f),qe(k=>k.filter(U=>U.clientRequestId!==A)),Te(k=>k&&k.id===_?{...k,status:"failed",error:f}:k)}finally{g(!1)}}async function Rr(){const s=i==null?void 0:i.thread.providerSessionId;if(s)try{await navigator.clipboard.writeText(s),ot("copied")}catch{ot("failed")}}async function At(s){if(i){g(!0),Q(null),Ce(),O("");try{if(i.thread.isLoaded){const d=await oo(t);B(b=>b?{...d,turns:De(b.turns,d.turns)}:d),ca(null),F(b=>b.map(j=>j.id===d.thread.id?d.thread:j)),Ke(!1);return}const n=await ls(t,{...i.thread.model?{model:i.thread.model}:{},...i.thread.sandboxMode?{sandboxMode:i.thread.sandboxMode}:{}});B(d=>d?{...n,turns:De(d.turns,n.turns)}:n),F(d=>d.map(b=>b.id===n.thread.id?n.thread:b)),s!=null&&s.attachShell&&v==="shell"&&Ke(!0)}catch(n){Q(n instanceof Error?n.message:"Unable to change connection state.")}finally{g(!1)}}}async function pt(){var s;if(v==="shell"){const n=((s=w.current)==null?void 0:s.sendControl("ctrl_c"))??!1;Q(n?null:"Connect the shell before sending Ctrl-C.");return}g(!0),Q(null);try{const n=i!=null&&i.thread.activeTurnId?await is(t,{turnId:i.thread.activeTurnId}):await is(t);B(d=>d&&{...d,thread:n}),F(d=>d.map(b=>b.id===n.id?n:b)),Ce(),O("")}catch(n){Q(n instanceof Error?n.message:"Unable to interrupt turn.")}finally{g(!1)}}async function gt(s){if(!i)return;const n=i,d={...D.current??{},...s.model!==void 0?{model:s.model}:{},...s.reasoningEffort!==void 0?{reasoningEffort:s.reasoningEffort}:{},...s.fastMode!==void 0?{fastMode:s.fastMode}:{},...s.collaborationMode!==void 0?{collaborationMode:s.collaborationMode}:{},...s.sandboxMode!==void 0?{sandboxMode:s.sandboxMode}:{}},b={...i.thread,...d};ha(!0),D.current=d,V.current={...i,thread:b},B(j=>j&&{...j,thread:b}),F(j=>j.map(A=>A.id===b.id?{...A,...b}:A));try{const j=await io(t,{...s.model!==void 0?{model:s.model}:{},...s.reasoningEffort!==void 0?{reasoningEffort:s.reasoningEffort}:{},...s.fastMode!==void 0?{fastMode:s.fastMode}:{},...s.collaborationMode!==void 0?{collaborationMode:s.collaborationMode}:{},...s.sandboxMode!==void 0?{sandboxMode:s.sandboxMode}:{}});D.current=null,V.current=n?{...n,thread:j}:null,B(A=>A&&{...A,thread:j}),F(A=>A.map(_=>_.id===j.id?j:_))}catch(j){D.current=null,V.current=n,B(n),F(A=>A.map(_=>_.id===n.thread.id?n.thread:_)),Q(j instanceof Error?j.message:"Unable to update thread settings.")}finally{ha(!1)}}const Ma=o.useCallback(async(s,n)=>{ga(s),Q(null);try{const d=await jo(t,s,n);B(b=>b?{...d,turns:De(b.turns,d.turns)}:d),X(d.livePlan??null),ue(d.liveItems??null)}catch(d){Q(d instanceof Error?d.message:"Unable to answer this request.")}finally{ga(null)}},[t]),Ua=o.useCallback(s=>Vn(t,s),[t]);async function Mt(){if(i){fa(!0),Q(null);try{const s=await co(t);B(n=>n&&{...n,thread:s}),F(n=>n.map(d=>d.id===s.id?s:d))}catch(s){Q(s instanceof Error?s.message:"Unable to compact this thread context.")}finally{fa(!1)}}}async function La(s,n){try{const d=await Bs(s,{title:n});F(b=>b.map(j=>j.id===d.id?{...j,title:d.title,updatedAt:d.updatedAt}:j)),B(b=>b&&b.thread.id===d.id?{...b,thread:{...b.thread,title:d.title,updatedAt:d.updatedAt}}:b)}catch(d){throw Q(d instanceof Error?d.message:"Unable to rename thread."),d}}async function Or(){if(Ie){ja(!0),Q(null);try{await Fs(Ie.id),F(n=>n.filter(d=>d.id!==Ie.id));const s=Ie.id===(i==null?void 0:i.thread.id);if(Ot(null),s){const n=ne.find(d=>d.id!==Ie.id&&d.workspaceId===(i==null?void 0:i.thread.workspaceId))??ne.find(d=>d.id!==Ie.id);a(n?`/threads/${n.id}`:"/threads")}}catch(s){Q(s instanceof Error?s.message:"Unable to delete thread.")}finally{ja(!1)}}}function $a(){L(s=>s==="chat"?(i!=null&&i.thread.isLoaded&&Ke(!0),"shell"):"chat")}async function Da(){var n;const s=await((n=w.current)==null?void 0:n.copyLastCommandOutput());Q(s?null:"Unable to copy the last shell command output.")}function Ha(s){var d,b;const n=s==="clear"?((d=w.current)==null?void 0:d.sendCommand("clear"))??!1:((b=w.current)==null?void 0:b.sendControl(s))??!1;Q(n?null:"Connect the shell before sending control input.")}o.useEffect(()=>{if(!(!ua||v!=="shell"||!w.current||(i==null?void 0:i.thread.isLoaded)===!1||(q==null?void 0:q.loading)!==!1)){if((q==null?void 0:q.status)==="attached"){Ke(!1);return}Ke(!1),w.current.toggleConnection()}},[v,i==null?void 0:i.thread.isLoaded,ua,q==null?void 0:q.loading,q==null?void 0:q.status]),o.useEffect(()=>{if(v!=="shell")return;const s=window.requestAnimationFrame(()=>{var n;(n=w.current)==null||n.refreshLayout({syncBackendSize:!1})});return()=>{window.cancelAnimationFrame(s)}},[v]);const Ut=i&&i.workspacePathStatus==="missing"?"Restore this workspace path on the current machine before continuing.":null,Lt=Je&&v==="chat",Ba=Lt&&da?ia:0,Pr=Math.max(er,144),Ar=Math.max(ar,Pr+Ba),Fa=Lt?Ar+12:0,Mr=i?e.jsxs("dl",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"relative pr-9",children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Session ID"}),e.jsx("dd",{className:"mt-1 break-all text-[var(--theme-fg)]",children:i.thread.providerSessionId??"Unavailable"}),i.thread.providerSessionId&&e.jsx("button",{type:"button","aria-label":"Copy session ID",title:$e==="copied"?"Copied":$e==="failed"?"Copy failed":"Copy session ID",onClick:()=>void Rr(),className:`thread-mobile-hit-target absolute bottom-0 right-0 inline-flex h-5 w-5 items-center justify-center rounded-full border shadow-sm shadow-stone-950/25 backdrop-blur transition ${$e==="copied"?"ui-status-info":$e==="failed"?"ui-status-danger":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg-soft)] hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]"}`,children:e.jsx("span",{className:"scale-[0.72]",children:e.jsx(ul,{})})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Source"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:i.thread.source==="local_codex_import"?`Imported local ${i.thread.provider} session`:`${i.thread.provider} supervisor thread`})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Status"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:Qr(i.thread.status)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Created"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:$t(i.thread.createdAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Workspace"}),e.jsx("dd",{className:"mt-1 break-words text-[var(--theme-fg)]",children:i.workspace.absPath})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Workspace path"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:i.workspacePathStatus==="present"?"Present":"Missing on this machine"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Active turn"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:i.thread.activeTurnId??"None"})]})]}):null,Ur=i&&(E!=null&&E.controls.sandboxMode)?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Sandbox Mode"}),e.jsx("div",{className:"mt-2 space-y-1.5",children:ol.map(s=>{const n=_o(i.thread)===s;return e.jsx("button",{type:"button",disabled:ma,onClick:()=>void gt({sandboxMode:s}),className:`block w-full rounded-xl border px-3 py-2 text-left text-sm transition ${n?"ui-status-warning":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg-soft)] hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]"} disabled:cursor-not-allowed disabled:opacity-60`,children:s},s)})})]})}):null,qa=(re==null?void 0:re.serverTurnId)??null,_a=re&&i?i.turns.find(s=>(Qe(s,re.prompt)||re.prompt.includes("[PHOTO ")&&(kt(s,re.prompt)||_t(s)))&&(qa&&s.id===qa||s.id===re.id||Qe(s,re.prompt)||re.prompt.includes("[PHOTO ")&&kt(s,re.prompt)))??null:null,Wa=o.useMemo(()=>re&&!_a?{id:re.id,startedAt:re.startedAt,status:re.status,error:re.error,model:re.model,reasoningEffort:re.reasoningEffort,reasoningEffortAvailable:re.reasoningEffortAvailable,tokenUsage:re.tokenUsage,priceEstimate:re.priceEstimate,items:[{id:`${re.id}-user-message`,kind:"userMessage",text:re.prompt}]}:null,[_a,re]),Ze=(i==null?void 0:i.thread.isLoaded)??!1,xt=Ze?Pe.status==="connected"?"ui-action-success shadow-lg shadow-stone-950/20":Pe.status==="reconnecting"?"thread-live-connection-reconnecting ui-status-success shadow-lg shadow-stone-950/20":Pe.status==="offline"?"ui-status-danger shadow-lg shadow-stone-950/20":"ui-status-warning shadow-lg shadow-stone-950/20":"host-icon-button border shadow-lg shadow-black/10",za=hl(Ze,Pe),bt=[za,Ze?null:"Tap to connect this thread",Pe.lastHealthyAt?`Last healthy ${$t(Pe.lastHealthyAt)}`:null].filter(Boolean).join(" · "),Lr=Ze?e.jsx("div",{role:"status","aria-live":"polite","aria-label":za,title:bt,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition ${xt}`,children:e.jsx(jt,{status:Pe.status})}):e.jsx("button",{type:"button",onClick:()=>void At(),disabled:h||!i,"aria-label":h?"Connecting thread":"Connect thread",title:h?"Connecting thread":bt,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition ${xt}`,children:e.jsx(jt,{status:"detached"})}),$r=Ze?e.jsx("div",{title:bt,className:`hidden lg:inline-flex h-9 w-9 items-center justify-center rounded-full transition ${xt}`,children:e.jsx(jt,{status:Pe.status})}):e.jsx("button",{type:"button",onClick:()=>void At(),disabled:h||!i,title:h?"Connecting thread":bt,className:`hidden lg:inline-flex h-9 w-9 items-center justify-center rounded-full transition ${xt}`,children:e.jsx(jt,{status:"detached"})}),Ga=ut.data??(i==null?void 0:i.goal)??null,Va=(i==null?void 0:i.goalHistory)??[],Ja=Ga?yt(Va,Ga):Js(Va),Ka=(E==null?void 0:E.controls.goals)??!1,Dr=e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"}),e.jsx("path",{d:"M8 1.7v2M8 12.3v2M1.7 8h2M12.3 8h2"})]}),Hr=cr&&Ka?e.jsxs("div",{className:"host-dialog w-96 max-w-[calc(100vw-1.5rem)] rounded-3xl border p-3 text-left shadow-2xl shadow-black/20 backdrop-blur-xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-title text-sm font-semibold",children:"Goal monitor"}),e.jsx("p",{className:"host-muted text-xs",children:"Current thread only"})]}),e.jsx("button",{type:"button",onClick:()=>ba(!1),className:"host-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Close"})]}),ut.error?e.jsx("p",{className:"host-error mt-3 rounded-2xl border px-3 py-2 text-xs",children:ut.error}):null,e.jsx("div",{className:"mt-3 max-h-[28rem] space-y-2 overflow-auto pr-1",children:Ja.length===0?e.jsx("p",{className:"host-empty-state rounded-2xl border px-3 py-3 text-sm",children:"No goals in this thread yet."}):Ja.map(s=>{const n=`${s.threadId}:${s.objective}:${s.createdAt}`,d=ur.has(n),b=["active","paused","budgetLimited"].includes(s.status);return e.jsxs("div",{className:`rounded-2xl border px-3 py-3 ${b?"ui-status-info":"host-surface-strong"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("button",{type:"button",onClick:()=>mr(j=>{const A=new Set(j);return A.has(n)?A.delete(n):A.add(n),A}),className:"min-w-0 flex-1 text-left",children:e.jsx("p",{className:`text-sm font-medium leading-5 ${d?"":"line-clamp-2"}`,children:s.objective})}),e.jsx("span",{className:"host-muted shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] uppercase tracking-[0.14em]",children:s.status})]}),e.jsxs("div",{className:"host-muted mt-2 flex flex-wrap gap-2 text-[11px]",children:[e.jsx("span",{children:Xo(s.timeUsedSeconds)}),e.jsx("span",{children:Yo(s)}),e.jsxs("span",{title:$t(s.updatedAt),children:["Updated ",new Date(s.updatedAt).toLocaleTimeString()]})]}),b?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",disabled:Rt||s.status==="active",onClick:()=>void Ea("active"),className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",disabled:Rt||s.status==="paused",onClick:()=>void Ea("paused"),className:"host-secondary-button rounded-full border px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-50",children:"Pause"}),e.jsx("button",{type:"button",disabled:Rt,onClick:()=>void vr(),className:"rounded-full border border-[var(--status-danger-border)] px-3 py-1.5 text-xs text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-50",children:"Terminate"})]}):null]},n)})})]}):null,Za=Ka?e.jsx("button",{type:"button","aria-label":"Open goal monitor",title:"Open goal monitor",onClick:()=>{ba(s=>!s),Ca()},className:"ui-status-info inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full shadow-lg shadow-stone-950/20 transition lg:h-9 lg:w-9",children:Dr}):null,Ya=e.jsx("button",{type:"button","aria-label":"Export transcript",title:"Export transcript",onClick:()=>ht(!0),disabled:!i,className:"host-icon-button inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border shadow-lg shadow-black/10 transition disabled:cursor-not-allowed disabled:opacity-50 lg:h-9 lg:w-9",children:e.jsx(ml,{})}),Br=e.jsxs("div",{className:"relative flex items-center justify-end gap-1.5",children:[Ya,Za,Lr]}),Fr=e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ya,Za,$r]}),qr=o.useMemo(()=>({livePlan:K,liveItems:de,respondingRequestId:pa,onRespondToRequest:Ma,scrollRequestKey:et,bottomSpacer:Fa,className:"thread-timeline-surface min-h-0 flex-1",onTailVisibilityChange:Et,loadingEarlier:Ue,onLoadEarlier:Pa,onOpenThread:Se,answeredRequestNotes:(i==null?void 0:i.answeredRequestNotes)??ll,activityNotes:(i==null?void 0:i.activityNotes)??il,pendingSteers:(i==null?void 0:i.pendingSteers)??dl,optimisticSteers:lt,optimisticTurn:Wa}),[i==null?void 0:i.answeredRequestNotes,i==null?void 0:i.activityNotes,i==null?void 0:i.pendingSteers,Pa,Ma,de,K,Ue,Se,lt,pa,et,Fa,Wa]),Xa=i?{busy:v==="chat"?h:!1,settingsBusy:ma,error:null,model:i.thread.model,reasoningEffort:i.thread.reasoningEffort,fastMode:i.thread.fastMode??!1,collaborationMode:i.thread.collaborationMode,modelOptions:Y,contextUsage:i.thread.contextUsage,capabilities:E,toolboxItems:(H==null?void 0:H.toolboxItems)??[],hookCommandTemplates:(H==null?void 0:H.hookCommandTemplates)??[],mcpConfigFormat:(H==null?void 0:H.mcpConfigFormat)??"none",followTail:It,threadConnected:i.thread.isLoaded,shellAvailable:se,disabled:!!Ut,...Ut?{disabledPlaceholder:Ut}:{},shellControlState:q,draftPrompt:nt.prompt,draftAttachments:nt.attachments,onDraftChange:Oe,canInterrupt:!!i.thread.activeTurnId,onInterrupt:pt,onCompact:Mt,onOpenForkTurns:Cr,onForkLatest:Ir,onForkTurn:Er,onOpenSkills:yr,onOpenMcp:wr,onOpenHooks:jr,onCreateHook:Nr,onUpdateHook:kr,onTrustHook:Sr,onUntrustHook:Tr,goalState:ut,onOpenGoal:Ca,onUpdateGoal:Ia,...Pt?{onReadProviderConfig:()=>$s(i.thread.provider,Pt),onWriteProviderConfig:s=>Ds(i.thread.provider,Pt,{content:s})}:{},onToggleFollow:()=>tt(s=>s+1),onUpdateSettings:gt,onToggleView:$a,onShellCopy:Da,onShellControl:Ha,compactBusy:nr,skillsState:or,mcpState:lr,hooksState:ir,forkTurnOptionsState:dr}:null,Qa=i?{busy:h,settingsBusy:!1,error:i.thread.isLoaded?(q==null?void 0:q.error)??null:null,followTail:!1,capabilities:E,toolboxItems:(H==null?void 0:H.toolboxItems)??[],hookCommandTemplates:(H==null?void 0:H.hookCommandTemplates)??[],mcpConfigFormat:(H==null?void 0:H.mcpConfigFormat)??"none",threadConnected:i.thread.isLoaded,shellAvailable:se,shellControlState:q,canInterrupt:!!(i.thread.isLoaded&&(q!=null&&q.isCommandRunning)),onInterrupt:pt,onToggleView:$a,onShellCopy:Da,onShellControl:Ha}:null,es=o.useCallback(s=>i?Le({threadId:i.thread.id,path:s}):"",[i==null?void 0:i.thread.id,Le]),ts=o.useMemo(()=>{const s=(i==null?void 0:i.workspace.id)??null;return s?{listTree:()=>qn(s),readFile:n=>_n(s,{path:n.path,...n.offset!==void 0?{offset:n.offset}:{},...n.limit!==void 0?{limit:n.limit}:{}}),getRawFileUrl:n=>Wn(s,{path:n.path}),uploadFile:n=>Gn(s,{file:n.file}),downloadNode:async n=>{if(n.kind!=="file")return;const d=await zn(s,{path:n.path}),b=URL.createObjectURL(d.blob),j=document.createElement("a");j.href=b,j.download=d.filename,document.body.append(j),j.click(),j.remove(),URL.revokeObjectURL(b)}}:null},[i==null?void 0:i.workspace.id]),_r=o.useMemo(()=>({openThread:Se,getThreadHref:Re,getNewThreadHref:rt,renameThread:La,deleteThread:Ot,sendPrompt:Aa,interrupt:pt,compact:Mt,updateSettings:gt,loadHistoryItemDetail:Ua,getImageAssetUrl:es,workspace:ts,shell:xe}),[es,rt,Re,Mt,pt,Ua,Aa,La,gt,xe,Se,ts]),Wr=i!=null&&i.thread.workspaceId?`/threads?workspaceId=${encodeURIComponent(i.thread.workspaceId)}`:"/workspaces",zr=e.jsxs(e.Fragment,{children:[e.jsx(en,{open:hr,busy:va,turnsState:fr,onCancel:()=>{va||ht(!1)},onLoadTurns:gr,onExport:xr}),e.jsx(aa,{open:Ie!==null,title:"Delete Thread",description:Ie?`Delete ${ks(Ie.title)} from supervisor. The backend session id will no longer appear in this workspace list.`:"",confirmLabel:"Delete Thread",busy:wa,onCancel:()=>{wa||Ot(null)},onConfirm:()=>void Or()})]});return e.jsx(tn,{threads:ne,detail:i,status:R,loading:at,error:at?null:pr,plugins:l,adapter:_r,metaContent:Mr,settingsContent:Ur,globalSettingsContent:e.jsx(na,{embedded:!0}),mobileHeaderAction:Br,workspaceReturnHref:Wr,onCloseAppNavigation:(r==null?void 0:r.closeNav)??(()=>{}),surfaceActions:Fr,floatingPanel:Hr,workspaceFeatures:cl,activeView:v,liveOutput:be,timelineProps:qr,timelineComponent:sn,useFloatingMobileComposer:Lt,floatingMobileComposerBottomOffset:Ba,composerHostRef:P,shellPanelRef:w,shellPanelComponent:an,shellEffectiveTheme:(r==null?void 0:r.effectiveTheme)??"dark",shellThemeMode:(r==null?void 0:r.themeMode)??"system",...r!=null&&r.setThemeMode?{onShellThemeModeChange:r.setThemeMode}:{},onShellStateChange:ca,loadingContent:e.jsx("div",{className:"host-muted flex flex-1 items-center justify-center px-6 py-12 text-center",children:"Loading thread detail..."}),emptyContent:e.jsx("div",{className:"host-muted flex flex-1 items-center justify-center px-6 py-12 text-center",children:"Unable to resolve this thread."}),dialogs:zr,...Xa?{composerProps:Xa}:{},...Qa?{shellComposerProps:Qa}:{}})}function pl(){const t=Ee(),[a,r]=o.useState(""),[l,c]=o.useState(!1),[u,m]=o.useState(null);async function x(N){N.preventDefault();const y=a.trim();if(!y){m("Session ID is required.");return}c(!0),m(null);try{const C=await ao(y);t(`/threads/${C.thread.id}`)}catch(C){C instanceof G?m(C.payload.message):m(C instanceof Error?C.message:"Unable to import session.")}finally{c(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"Import Session"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Bring in a local Codex session"}),e.jsx("p",{className:"host-page-description mt-3 max-w-3xl text-sm leading-6",children:"Paste a session ID from this machine. Supervisor will recover the workspace path, reuse an existing workspace when possible, or create one with the last folder name as the default label."}),e.jsx("p",{className:"host-muted mt-2 max-w-3xl text-sm leading-6",children:"Imported history appears immediately, but sending a new prompt still requires a manual Resume / Connect."})]}),e.jsxs("form",{onSubmit:x,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"session-id",className:"host-form-label text-sm font-medium",children:"Local session ID"}),e.jsx("input",{id:"session-id",value:a,onChange:N=>r(N.target.value),placeholder:"019d6fb7-7033-7a30-a2c7-74d0919e87d4",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),u&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:u}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("button",{type:"submit",disabled:l,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:l?"Importing...":"Import Session"})})]})]})}function St(t){return t.enabled&&t.capabilities.sessions.resume&&t.capabilities.turns.start}function gl(t,a){var l;const r=t.find(c=>c.provider===a);return r&&St(r)?r.provider:((l=t.find(St))==null?void 0:l.provider)??Me}function xl(){const t=Ee(),a=Be(),[r]=vs(),[l,c]=o.useState([]),[u,m]=o.useState([]),[x,N]=o.useState([]),[y,C]=o.useState((a==null?void 0:a.defaultBackend)??Me),[p,I]=o.useState(""),[w,P]=o.useState(""),M=r.get("title"),[$,te]=o.useState(()=>M??""),[ae,V]=o.useState("yolo"),[D,oe]=o.useState(!0),[i,B]=o.useState(!1),[ne,F]=o.useState(null),Y=r.get("workspaceId"),J=(a==null?void 0:a.defaultBackend)??Me;o.useEffect(()=>{let E=!1;return Promise.all([ra(),Us()]).then(async([z,H])=>{var K,X,de;if(E)return;const Ne=gl(H,J);C(Ne),m(H);const be=await Qt(Ne);if(E)return;c(z),N(be);const O=z.some(ue=>ue.id===Y)?Y:((K=z[0])==null?void 0:K.id)??"";I(O),P(((X=be.find(ue=>ue.isDefault))==null?void 0:X.model)??((de=be[0])==null?void 0:de.model)??"")}).catch(z=>{E||F(z instanceof Error?z.message:"Unable to load creation form data.")}).finally(()=>{E||oe(!1)}),()=>{E=!0}},[J,Y]),o.useEffect(()=>{if(!y)return;let E=!1;return N([]),P(""),F(null),Qt(y).then(z=>{var H,Ne;E||(N(z),P(((H=z.find(be=>be.isDefault))==null?void 0:H.model)??((Ne=z[0])==null?void 0:Ne.model)??""))}).catch(z=>{E||(N([]),P(""),F(z instanceof Error?z.message:"Unable to load backend models."))}),()=>{E=!0}},[y]);function R(){if(window.history.length>1){t(-1);return}if(Y){t(`/threads?workspaceId=${encodeURIComponent(Y)}`);return}t("/workspaces")}async function W(E){E.preventDefault(),B(!0),F(null);try{const z=await to($.trim()?{workspaceId:p,provider:y,model:w,approvalMode:ae,title:$.trim()}:{workspaceId:p,provider:y,model:w,approvalMode:ae});t(`/threads/${z.id}`)}catch(z){z instanceof G?F(z.payload.message):F(z instanceof Error?z.message:"Unable to create thread.")}finally{B(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"New Thread"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Start a backend session"}),e.jsx("p",{className:"host-page-description mt-3 max-w-2xl text-sm leading-6",children:"Choose the workspace, model, and approval mode that should back the new thread."})]}),D?e.jsx("div",{className:"host-empty-state rounded-3xl border px-6 py-12 text-center",children:"Loading creation form..."}):e.jsxs("form",{onSubmit:W,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-backend",children:"Backend"}),e.jsx("select",{id:"thread-backend",value:y,onChange:E=>{const z=E.target.value;C(z)},className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:u.map(E=>e.jsxs("option",{value:E.provider,disabled:!St(E),children:[E.displayName,St(E)?"":" (not available)"]},E.provider))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-workspace",children:"Workspace"}),e.jsx("select",{id:"thread-workspace",value:p,onChange:E=>I(E.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:l.map(E=>e.jsxs("option",{value:E.id,children:[E.label," · ",E.absPath]},E.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-model",children:"Model"}),e.jsxs("select",{id:"thread-model",value:w,onChange:E=>P(E.target.value),disabled:x.length===0,className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:[x.length===0?e.jsx("option",{value:"",children:"No models available"}):null,x.map(E=>e.jsxs("option",{value:E.model,children:[E.displayName," · ",E.model]},E.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-title",children:"Title"}),e.jsx("input",{id:"thread-title",value:$,onChange:E=>te(E.target.value),placeholder:"Optional. Falls back to first prompt.",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-approval-mode",children:"Approval mode"}),e.jsxs("select",{id:"thread-approval-mode",value:ae,onChange:E=>V(E.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:[e.jsx("option",{value:"yolo",children:"yolo"}),e.jsx("option",{value:"guarded",children:"guarded"})]})]}),ne&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:ne}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"submit",disabled:i||!p||!w,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:i?"Creating...":"Create Thread"}),e.jsx("button",{type:"button",onClick:R,disabled:i,className:"host-secondary-button rounded-full border px-5 py-3 font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"})]})]})]})}function bl(t){return t?`/threads/new?workspaceId=${encodeURIComponent(t)}`:"/threads/new"}function vl({getThreadHref:t,onOpenThread:a,getNewThreadHref:r,renderThreadLink:l,onCloseAppNavigation:c,...u}){const m=Ee(),x=Be(),N=c??(x==null?void 0:x.closeNav),y=u.effectiveTheme??(x==null?void 0:x.effectiveTheme),C=u.themeMode??(x==null?void 0:x.themeMode),p=u.onThemeModeChange??(x==null?void 0:x.setThemeMode);return e.jsx(rn,{...u,workspaceReturnHref:u.workspaceReturnHref??"/workspaces",globalSettingsContent:u.globalSettingsContent??e.jsx(na,{embedded:!0}),...y?{effectiveTheme:y}:{},...C?{themeMode:C}:{},...p?{onThemeModeChange:p}:{},getThreadHref:t??(I=>`/threads/${I}`),onOpenThread:a??(I=>m(`/threads/${I}`)),getNewThreadHref:r??bl,renderThreadLink:l??(({thread:I,children:w,className:P,onClick:M})=>e.jsx(Ae,{to:`/threads/${I.id}`,className:P,onClick:M,children:w})),...N?{onCloseAppNavigation:N}:{}})}function Ks({open:t,title:a,label:r,value:l,busy:c=!1,onChange:u,onCancel:m,onSubmit:x}){if(o.useEffect(()=>{if(!t)return;function y(C){C.key==="Escape"&&!c&&m()}return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[c,m,t]),!t)return null;function N(y){y.preventDefault(),x()}return Vr.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[e.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:m,disabled:c,className:"ui-overlay-scrim absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),e.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":a,onSubmit:N,className:"host-dialog relative z-[1] w-full max-w-md rounded-[1.6rem] border p-5 shadow-2xl shadow-black/20 sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"host-page-title text-sm font-medium",children:a}),e.jsx("p",{className:"host-muted mt-1 text-sm",children:"Changes are saved only after confirmation."})]}),e.jsx("button",{type:"button","aria-label":"Close dialog",onClick:m,disabled:c,className:"host-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("label",{htmlFor:"rename-dialog-input",className:"host-form-label text-sm font-medium",children:r}),e.jsx("input",{id:"rename-dialog-input","aria-label":r,autoFocus:!0,value:l,onChange:y=>u(y.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:m,disabled:c,className:"host-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:c||!l.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function yl(){const[t]=vs(),a=Ee(),r=Be(),l=t.get("workspaceId"),[c,u]=o.useState([]),[m,x]=o.useState([]),[N,y]=o.useState(null),[C,p]=o.useState(!0),[I,w]=o.useState(null),[P,M]=o.useState(null),[$,te]=o.useState(""),[ae,V]=o.useState(null),[D,oe]=o.useState(null),[i,B]=o.useState(!1),ne=(r==null?void 0:r.defaultBackend)??Me,F=o.useCallback(async()=>{p(!0),w(null);try{const[O,K,X]=await Promise.all([Ls(ne).then(de=>de.status),Hs(),ra()]);y(O),u(K),x(X)}catch(O){w(O instanceof Error?O.message:"Unable to load threads.")}finally{p(!1)}},[ne]);o.useEffect(()=>{if(l===null)return;F();const O=qs(K=>{u(X=>X.map(de=>de.id===K.threadId?{...de,status:K.type==="thread.updated"&&typeof K.payload.status=="string"?K.payload.status:de.status,lastError:(K.type==="thread.turn.failed"||K.type==="thread.turn.completed")&&typeof K.payload.error=="string"?K.payload.error:de.lastError,title:K.type==="thread.updated"&&typeof K.payload.title=="string"?K.payload.title:de.title}:de))});return()=>{O.close()}},[F,l]);const Y=Object.fromEntries(m.map(O=>[O.id,O.label])),J=m.find(O=>O.id===l)??null,R=o.useMemo(()=>l?c.filter(O=>O.workspaceId===l):[],[l,c]),W=R.filter(O=>O.status==="running").length,E=l?`/threads/new?workspaceId=${encodeURIComponent(l)}`:"/threads/new";if(l===null)return e.jsx(Jr,{to:"/workspaces",replace:!0});function z(){switch(N==null?void 0:N.state){case"ready":return"bg-emerald-400 shadow-[0_0_0_3px_rgba(52,211,153,0.14)]";case"starting":return"bg-amber-300 shadow-[0_0_0_3px_rgba(252,211,77,0.12)]";case"degraded":case"failed":return"bg-rose-400 shadow-[0_0_0_3px_rgba(251,113,133,0.14)]";default:return"bg-stone-500 shadow-[0_0_0_3px_rgba(120,113,108,0.14)]"}}async function H(O,K){try{const X=await Bs(O,{title:K});u(de=>de.map(ue=>ue.id===X.id?{...ue,title:X.title,updatedAt:X.updatedAt}:ue))}catch(X){throw w(X instanceof Error?X.message:"Unable to rename thread."),X}}async function Ne(){if(!P)return;const O=$.trim();if(O){V(P);try{await H(P,O),M(null),te("")}finally{V(null)}}}async function be(){if(D){B(!0);try{await Fs(D.id),u(O=>O.filter(K=>K.id!==D.id)),oe(null)}catch(O){w(O instanceof Error?O.message:"Unable to delete thread.")}finally{B(!1)}}}return e.jsx(vl,{threads:c,workspaceLabels:Y,status:N,loading:C,error:I,viewportConstrained:l!==null,showMobileAppMenu:!0,showMobileThreadNavToggle:!1,showMobileNewThreadShortcut:!1,currentWorkspaceId:l,currentWorkspaceLabel:(J==null?void 0:J.label)??null,onRenameThread:H,onDeleteThread:oe,children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"host-panel flex min-h-0 flex-1 flex-col overflow-hidden rounded-[2rem] border shadow-2xl shadow-black/10",children:[e.jsx("div",{className:"border-b border-[var(--theme-border)] px-4 py-3 sm:px-6 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"host-page-title min-w-0 truncate text-base font-semibold sm:text-lg",title:J?`${J.label} threads`:"All threads",children:J?J.label:"All Threads"}),e.jsx(Ae,{to:E,className:"ui-action-primary inline-flex h-9 shrink-0 items-center rounded-full px-3.5 text-xs font-medium uppercase tracking-[0.18em] transition",children:"New Thread"})]})}),e.jsx("div",{className:"px-4 py-3 sm:px-6 sm:py-4",children:e.jsxs("article",{className:"host-surface-strong inline-flex min-w-[12rem] max-w-full items-center gap-3 rounded-[1.25rem] border px-3.5 py-2.5",children:[e.jsx("span",{"aria-hidden":"true",className:`h-2.5 w-2.5 shrink-0 rounded-full ${z()}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"host-muted truncate text-[11px] uppercase tracking-[0.22em]",children:"Supervisor"}),e.jsx("p",{className:"host-soft truncate text-sm",children:(N==null?void 0:N.lastError)??((N==null?void 0:N.state)==="ready"?"Ready":(N==null?void 0:N.state)??"Checking")})]})]})}),!C&&!I&&R.length>0&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col border-t border-[var(--theme-border)] px-4 py-4 sm:px-6 sm:py-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"host-muted text-xs uppercase tracking-[0.28em]",children:"Recent Threads"}),e.jsxs("span",{className:"host-warning-pill rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase tracking-[0.18em]",children:[R.length," total"]}),W>0&&e.jsxs("span",{className:"host-muted text-xs",children:["· ",W," running"]})]}),e.jsx("div",{className:"mt-3 min-h-0 flex-1",children:e.jsx(nn,{threads:R,currentWorkspaceId:l,workspaceLabels:Y,onOpenThread:O=>a(`/threads/${O}`),onBeginRenameThread:O=>{M(O.id),te(O.title)},onDeleteThread:O=>oe(O),scrollable:!0,maxHeightClassName:"max-h-full",showDeleteButton:!0,showSessionCopyButton:!0})})]}),!C&&!I&&R.length===0&&e.jsx("div",{className:"host-muted border-t border-[var(--theme-border)] px-4 py-6 text-sm sm:px-6",children:"No threads available in this workspace."})]}),e.jsx(Ks,{open:P!==null,title:"Rename Thread",label:"Thread Title",value:$,busy:ae!==null,onChange:te,onCancel:()=>{M(null),te("")},onSubmit:()=>void Ne()}),e.jsx(aa,{open:D!==null,title:"Delete Thread",description:D?`Delete ${ks(D.title)} from supervisor. The backend session id will no longer appear in this workspace list.`:"",confirmLabel:"Delete Thread",busy:i,onCancel:()=>{i||oe(null)},onConfirm:()=>void be()})]})})}function ps(t){const a=t.trim(),r=a.replace(/[\\/]+$/,"");if(!r)return"";if(Zs(a)){const c=(r.split(/[?#]/)[0]??r).split(/[/:]/).filter(Boolean).at(-1)??"";return c.endsWith(".git")?c.slice(0,-4):c}return r.split(/[\\/]/).filter(Boolean).at(-1)??""}function Zs(t){const a=t.trim();return/^https?:\/\/.+/i.test(a)||/^ssh:\/\/.+/i.test(a)||/^git@[^:]+:.+/.test(a)}function wl({initialPath:t="",initialLabel:a="",submitLabel:r="Save Workspace",error:l,busy:c=!1,onSubmit:u}){const m=ps(t),[x,N]=o.useState(t),[y,C]=o.useState(a||m),[p,I]=o.useState(null),w=o.useRef(m);o.useEffect(()=>{const M=ps(x);C($=>!$.trim()||$===w.current?M:$),w.current=M},[x]);async function P(M){M.preventDefault();const $=x.trim();if(!$){I("Workspace path or Git URL is required.");return}I(null);const te=y.trim(),ae=Zs($)?"gitUrl":"absPath";await u(te?{[ae]:$,label:te}:{[ae]:$})}return e.jsxs("form",{onSubmit:P,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"workspace-path",className:"host-form-label text-sm font-medium",children:"Path or Git URL"}),e.jsx("input",{id:"workspace-path",name:"absPath",value:x,onChange:M=>N(M.target.value),placeholder:"/Users/name/project or https://github.com/owner/repo.git",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"}),e.jsx("p",{className:"host-muted mt-2 text-xs",children:"Absolute paths register local directories. Git URLs clone into the configured dev home."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"workspace-label",className:"host-form-label text-sm font-medium",children:"Display label"}),e.jsx("input",{id:"workspace-label",name:"label",value:y,onChange:M=>C(M.target.value),placeholder:"Optional override",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"}),e.jsx("p",{className:"host-muted mt-2 text-xs",children:"Defaults to the last folder name. You can override it."})]}),(p||l)&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:p??l}),e.jsx("button",{type:"submit",disabled:c,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:c?"Saving...":r})]})}function jl(){const t=Ee(),[a,r]=o.useState(null),[l,c]=o.useState(!1);async function u(m){c(!0),r(null);try{const x=await No(m);t(`/threads?workspaceId=${encodeURIComponent(x.id)}`)}catch(x){x instanceof G?r(x.payload.message):r(x instanceof Error?x.message:"Unable to create workspace.")}finally{c(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"Add Workspace"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Create a workspace"}),e.jsx("p",{className:"host-page-description mt-3 max-w-2xl text-sm leading-6",children:"Register an existing local directory, create one missing child directory under dev home, or clone a Git repository into dev home."})]}),e.jsx(wl,{busy:l,error:a,submitLabel:"Create Workspace",onSubmit:u})]})}function gs(t){return Date.parse(t.lastOpenedAt??t.createdAt)}function Nl(t,a){return t.isFavorite!==a.isFavorite?t.isFavorite?-1:1:gs(a)-gs(t)}function kl(t){return t?new Date(t).toLocaleString():"Never opened"}function Sl(t,a=28){return t.length<=a?t:`...${t.slice(-(a-3))}`}function Tl({active:t}){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:`h-3.5 w-3.5 fill-current ${t?"rotate-[18deg]":"rotate-[8deg]"}`,children:e.jsx("path",{d:"M10.7 1.75c.34 0 .62.28.62.63v1.24l1.43 1.42c.24.24.24.62 0 .86l-1.1 1.1v2.02c0 .17-.07.33-.19.45l-1.5 1.5v2.28c0 .28-.18.53-.44.6a.62.62 0 0 1-.69-.24L7.2 12.4l-2.83 2.83a.625.625 0 1 1-.88-.88l2.83-2.83-2.2-1.62a.62.62 0 0 1-.24-.69c.08-.26.32-.44.6-.44h2.28l1.5-1.5a.64.64 0 0 1 .45-.18h2.02l1.1-1.11-1.42-1.42H9.07a.63.63 0 0 1-.62-.63c0-.34.28-.62.62-.62h1.63Z"})})}function Cl(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-current",children:e.jsx("path",{d:"M6.1 1.75h3.8c.75 0 1.4.52 1.57 1.25h2.03c.35 0 .63.28.63.63 0 .34-.28.62-.63.62h-.66l-.62 8.03c-.08 1.09-.99 1.97-2.08 1.97H5.86c-1.09 0-2-.88-2.08-1.97l-.62-8.03H2.5a.62.62 0 1 1 0-1.25h2.03c.17-.73.82-1.25 1.57-1.25Zm0 1.25c-.07 0-.14.03-.19.08A.26.26 0 0 0 5.84 3h4.32a.26.26 0 0 0-.07-.17.26.26 0 0 0-.19-.08H6.1Zm-1.07 1.25.61 7.93c.03.44.4.79.84.79h3.04c.44 0 .81-.35.84-.79l.61-7.93H5.03Zm1.53 1.32c.35 0 .62.28.62.62v4.19a.62.62 0 1 1-1.24 0V6.19c0-.34.28-.62.62-.62Zm2.82 0c.34 0 .62.28.62.62v4.19a.62.62 0 1 1-1.24 0V6.19c0-.34.28-.62.62-.62Z"})})}function Il(){const t=Ee(),[a,r]=o.useState([]),[l,c]=o.useState(!0),[u,m]=o.useState(null),[x,N]=o.useState(null),[y,C]=o.useState(""),[p,I]=o.useState(null),[w,P]=o.useState(null),[M,$]=o.useState(null),[te,ae]=o.useState(!1);async function V(){c(!0),m(null);try{r(await ra())}catch(R){m(R instanceof Error?R.message:"Unable to load workspaces.")}finally{c(!1)}}o.useEffect(()=>{V()},[]);async function D(R){const W={...R,isFavorite:!R.isFavorite};r(E=>E.map(z=>z.id===R.id?W:z));try{const E=await To(R.id,{isFavorite:!R.isFavorite});r(z=>z.map(H=>H.id===E.id?E:H))}catch(E){r(z=>z.map(H=>H.id===R.id?R:H)),m(E instanceof Error?E.message:"Unable to update workspace.")}}async function oe(R){const W=y.trim();if(W){I(R);try{const E=await ko(R,{label:W});r(z=>z.map(H=>H.id===E.id?E:H)),N(null),C("")}catch(E){m(E instanceof Error?E.message:"Unable to rename workspace.")}finally{I(null)}}}function i(R){N(R.id),C(R.label)}function B(){N(null),C("")}function ne(R){t(`/threads?workspaceId=${encodeURIComponent(R)}`)}async function F(){if(M){ae(!0);try{await So(M.id),r(R=>R.filter(W=>W.id!==M.id)),$(null)}catch(R){m(R instanceof Error?R.message:"Unable to delete workspace.")}finally{ae(!1)}}}function Y(R,W){(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),ne(W))}const J=o.useMemo(()=>[...a].sort(Nl),[a]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"host-topbar sticky top-[env(safe-area-inset-top)] z-20 -mx-4 border-b px-2.5 py-2 backdrop-blur sm:mx-0 sm:rounded-[1.4rem] sm:border sm:px-4",children:e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:gap-2",children:[e.jsx(zs,{}),e.jsx(Ae,{to:"/threads/import",className:"host-info-pill inline-flex h-8 shrink-0 items-center rounded-full border px-2.5 text-[11px] font-medium uppercase tracking-[0.14em] transition sm:px-3 sm:text-xs sm:tracking-[0.18em]",children:"Import"}),e.jsx(Ae,{to:"/workspaces/new",className:"ui-action-primary inline-flex h-8 shrink-0 items-center rounded-full px-2.5 text-[11px] font-medium uppercase tracking-[0.14em] transition sm:px-3 sm:text-xs sm:tracking-[0.18em]",children:"Create"}),e.jsx("div",{className:"min-w-0 flex-1 text-right",children:e.jsx("p",{className:"host-page-eyebrow truncate text-[11px] uppercase tracking-[0.24em]",children:"Workspaces"})})]}),e.jsx(Gs,{className:"absolute left-0 top-[calc(100%+0.5rem)] z-30 w-[min(22rem,calc(100vw-1rem))]"})]})}),l&&e.jsx("div",{className:"host-empty-state rounded-[1.6rem] border px-6 py-12 text-center",children:"Loading workspace registry..."}),u&&e.jsx("div",{className:"host-error rounded-[1.4rem] border px-4 py-4",children:u}),!l&&!u&&a.length===0&&e.jsxs("div",{className:"host-empty-state rounded-[1.6rem] border border-dashed px-6 py-12 text-center",children:[e.jsx("p",{className:"host-page-title text-lg font-medium",children:"No workspaces yet"}),e.jsx("p",{className:"host-muted mt-2 text-sm",children:"Add a local directory inside the configured workspace root to start building the registry."})]}),!l&&J.length>0&&e.jsx("div",{className:"space-y-2 overflow-x-hidden",children:J.map(R=>e.jsxs("article",{role:"link",tabIndex:0,onClick:()=>ne(R.id),onKeyDown:W=>Y(W,R.id),className:"host-card relative overflow-hidden rounded-[1.35rem] border px-4 py-3 transition",children:[e.jsxs("div",{className:"absolute right-2.5 top-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":`Delete workspace ${R.label}`,title:"Delete workspace",onClick:W=>{W.stopPropagation(),$(R)},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-border)]",children:e.jsx(Cl,{})}),e.jsx("button",{type:"button","aria-label":R.isFavorite?`Unpin workspace ${R.label}`:`Pin workspace ${R.label}`,title:R.isFavorite?"Unpin workspace":"Pin workspace",onClick:W=>{W.stopPropagation(),D(R)},className:`inline-flex h-7 w-7 items-center justify-center rounded-full border transition ${R.isFavorite?"host-warning-pill":"host-icon-button"}`,children:e.jsx(Tl,{active:R.isFavorite})})]}),e.jsx("div",{className:"flex min-w-0 items-start gap-3 pr-[4.6rem]",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("p",{className:"host-page-title min-w-0 max-w-full truncate text-base font-semibold sm:text-lg",title:R.label,children:R.label}),e.jsx("button",{type:"button",onClick:W=>{W.stopPropagation(),i(R)},"aria-label":`Rename workspace ${R.label}`,className:"host-muted inline-flex h-4 w-4 shrink-0 items-center justify-center transition hover:text-[var(--theme-fg)]",children:e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3 w-3 fill-current",children:e.jsx("path",{d:"m11.9 1.6 2.5 2.5-8.2 8.2-3.3.7.7-3.3 8.3-8.1Zm-7.3 8.7-.3 1.3 1.3-.3 6.9-6.9-1-1-6.9 6.9Zm8.8-7.8-1-1-1 1 1 1 1-1Z"})})})]}),e.jsx("button",{type:"button","aria-label":R.absPath,title:R.absPath,onClick:W=>{W.stopPropagation(),P(R.absPath)},className:"host-muted mt-1 inline-block max-w-full overflow-hidden whitespace-nowrap text-left text-[9px] leading-4 transition hover:text-[var(--theme-fg-soft)]",children:Sl(R.absPath)}),e.jsx("div",{className:"host-muted mt-2 flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("span",{className:"min-w-0 truncate",children:["Last opened: ",kl(R.lastOpenedAt)]})})]})})]},R.id))}),e.jsx(Ks,{open:x!==null,title:"Rename Workspace",label:"Workspace Label",value:y,busy:p!==null,onChange:C,onCancel:B,onSubmit:()=>x?oe(x):void 0}),e.jsx(on,{open:w!==null,title:"Workspace Path",text:w??"",onClose:()=>P(null)}),e.jsx(aa,{open:M!==null,title:"Delete Workspace",description:M?`Delete ${M.label} from supervisor. This also removes its threads and local supervisor metadata.`:"",confirmLabel:"Delete Workspace",busy:te,onCancel:()=>{te||$(null)},onConfirm:()=>void F()})]})}const Ys="remote-codex-theme-mode",Xs="remote-codex-default-backend";function El(){if(typeof window>"u")return"system";const t=window.localStorage.getItem(Ys);return t==="light"||t==="dark"||t==="system"?t:"system"}function Rl(){if(typeof window>"u")return Me;const t=window.localStorage.getItem(Xs);return cn(t)??Me}function Ol(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Pl({themeMode:t,setThemeMode:a,effectiveTheme:r}){const[l,c]=o.useState(!1),[u,m]=o.useState(!1),[x,N]=o.useState(Rl),y=bs(),C=/^\/threads\/[^/]+$/.test(y.pathname),p=/^\/control-plane\/sessions\/[^/]+$/.test(y.pathname),I=y.pathname==="/threads",w=C||p||I,P=I||C||p,M=C||p,$=y.pathname==="/workspaces",te=y.pathname.startsWith("/control-plane"),ae=$||I||te;o.useEffect(()=>{c(!1)},[y.pathname,y.search]);function V(D){N(D),window.localStorage.setItem(Xs,D)}return e.jsxs(Ss.Provider,{value:{navOpen:l,openNav:()=>c(!0),toggleNav:()=>c(D=>!D),closeNav:()=>c(!1),settingsOpen:u,openSettings:()=>{c(!1),m(!0)},closeSettings:()=>m(!1),themeMode:t,setThemeMode:a,effectiveTheme:r,defaultBackend:x,setDefaultBackend:V},children:[e.jsxs("div",{className:`bg-[var(--app-bg)] text-[var(--app-fg)] ${w?"fixed inset-0 overflow-hidden overscroll-none":"min-h-screen"}`,children:[!ae&&!M&&e.jsxs("div",{className:"fixed left-4 top-4 z-50",children:[e.jsx(zs,{}),e.jsx(Gs,{className:"mt-3 w-[min(22rem,calc(100vw-2rem))]"})]}),e.jsx("main",{className:`mx-auto w-full ${P?"max-w-none":"max-w-[1600px]"} ${w?"absolute inset-0 pb-0 sm:pb-4":"pb-4"} ${P?C||p?"pt-0":I?"pt-[env(safe-area-inset-top)] sm:pt-4":"pt-[calc(env(safe-area-inset-top)+4rem)] sm:pt-4":$||te?"pt-[env(safe-area-inset-top)] sm:pt-4":"pt-4"} ${w?C||p?"overflow-hidden overscroll-none px-0":"overflow-hidden overscroll-none px-0 sm:px-6":"px-4 sm:px-6"}`,children:e.jsx("section",{className:`min-w-0 ${w?C||p?"h-full min-h-0 overflow-hidden overscroll-none":"h-full overflow-hidden overscroll-none":""}`,children:e.jsx(Zr,{})})})]}),e.jsx(na,{})]})}function Al({children:t}){const[a,r]=o.useState({status:"checking"});async function l(m){try{const x=await vn();if(m!=null&&m())return;r(!x.authRequired||x.authenticated?{status:"authenticated"}:{status:"loginRequired",session:x,error:null})}catch(x){if(m!=null&&m())return;if(x instanceof G&&x.statusCode===401){r({status:"loginRequired",session:{authenticated:!1,username:null,expiresAt:null,mode:"server",authRequired:!0},error:null});return}r({status:"unavailable",error:x instanceof Error?x.message:"Unable to check supervisor access."})}}o.useEffect(()=>{let m=!1;return l(()=>m),()=>{m=!0}},[]);async function c(m){await yn(m),r({status:"authenticated"})}function u(){r({status:"checking"}),l()}return a.status==="checking"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-sm text-[var(--theme-muted)]",children:"Checking supervisor access..."}):a.status==="unavailable"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-[var(--app-fg)]",children:e.jsxs("section",{className:"w-full max-w-md rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-2xl shadow-[color-mix(in_oklch,var(--app-fg)_14%,transparent)] sm:p-6",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-muted)]",children:"Supervisor Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-normal text-[var(--theme-fg)]",children:"Unable to reach supervisor"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-muted)]",children:a.error}),e.jsx("button",{className:"mt-5 h-11 rounded-xl bg-[var(--theme-accent-solid)] px-4 text-sm font-semibold text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-border)]",onClick:u,type:"button",children:"Retry"})]})}):a.status==="loginRequired"?e.jsxs(e.Fragment,{children:[a.error&&e.jsx("div",{className:"fixed left-1/2 top-4 z-50 w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 rounded-xl border border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] px-3 py-2 text-sm text-[var(--status-warning-fg)]",children:a.error}),e.jsx(Do,{onLogin:c})]}):t}function Ml({children:t}){const[a,r]=o.useState({status:"checking"});return o.useEffect(()=>{let l=!1;return Xt().then(c=>{l||r(c.authenticated?{status:"authenticated",session:c}:{status:"loginRequired"})}).catch(()=>{l||r({status:"loginRequired"})}),()=>{l=!0}},[]),a.status==="checking"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-sm text-[var(--theme-muted)]",children:"Checking relay access..."}):a.status==="loginRequired"?e.jsx(oa,{}):t}function xs({themeMode:t,setThemeMode:a,effectiveTheme:r}){return e.jsxs(ys,{children:[e.jsx(ke,{path:"/",element:Es()?e.jsx(oa,{}):e.jsx($o,{})}),e.jsxs(ke,{element:e.jsx(Pl,{themeMode:t,setThemeMode:a,effectiveTheme:r}),children:[e.jsx(ke,{path:"/workspaces",element:e.jsx(Il,{})}),e.jsx(ke,{path:"/workspaces/new",element:e.jsx(jl,{})}),e.jsx(ke,{path:"/threads",element:e.jsx(yl,{})}),e.jsx(ke,{path:"/threads/import",element:e.jsx(pl,{})}),e.jsx(ke,{path:"/threads/new",element:e.jsx(xl,{})}),e.jsx(ke,{path:"/threads/:id",element:e.jsx(fl,{})})]})]})}function Ul(){const[t,a]=o.useState(()=>El()),[r,l]=o.useState(()=>Ol()),c=t==="system"?r:t;return o.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const u=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{l(u.matches?"dark":"light")};return m(),typeof u.addEventListener=="function"?u.addEventListener("change",m):u.addListener(m),()=>{typeof u.removeEventListener=="function"?u.removeEventListener("change",m):u.removeListener(m)}},[]),o.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ys,t)},[t]),o.useEffect(()=>{const u=document.documentElement;u.dataset.themeMode=t,u.dataset.themeEffective=c,u.style.colorScheme=c},[c,t]),e.jsx("div",{className:"theme-shell theme-scrollbar",children:e.jsx(ln,{adapter:{fetchPlugins:Jn,importPlugin:Kn,updatePlugin:Zn},children:e.jsx(Kr,{children:e.jsxs(ys,{children:[e.jsx(ke,{path:"/relay-portal",element:e.jsx(oa,{})}),e.jsx(ke,{path:"/relay-admin",element:e.jsx(Ho,{})}),e.jsx(ke,{path:"/*",element:Es()?e.jsx(Ml,{children:e.jsx(xs,{themeMode:t,setThemeMode:a,effectiveTheme:c})}):e.jsx(Al,{children:e.jsx(xs,{themeMode:t,setThemeMode:a,effectiveTheme:c})})})]})})})})}Yr.createRoot(document.getElementById("root")).render(e.jsx(Xr.StrictMode,{children:e.jsx(Ul,{})}));
@@ -1 +0,0 @@
1
- .xyz-viewer-plugin{display:flex;min-height:0;height:100%;flex-direction:column;overflow:hidden;border:1px solid rgba(120,113,108,.28);border-radius:14px;background:#fff;color:#1c1917}.xyz-viewer-plugin__header{display:flex;flex:0 0 auto;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid rgba(120,113,108,.18);padding:12px 14px}.xyz-viewer-plugin__header h2{margin:0;font-size:14px;font-weight:650;line-height:20px}.xyz-viewer-plugin__header p,.xyz-viewer-plugin__header span{margin:0;color:#78716c;font-size:11px;line-height:16px}.xyz-viewer-plugin__toolbar{display:flex;flex:0 0 auto;align-items:center;justify-content:flex-end;gap:6px;overflow-x:auto;border-bottom:1px solid rgba(120,113,108,.14);padding:8px 10px}.xyz-viewer-plugin__toolbar button,.xyz-viewer-plugin__timeline button{display:inline-flex;width:30px;height:30px;flex:0 0 auto;align-items:center;justify-content:center;border:1px solid rgba(120,113,108,.24);border-radius:8px;background:#fff;color:#44403c;cursor:pointer}.xyz-viewer-plugin__toolbar button:hover,.xyz-viewer-plugin__timeline button:hover{background:#f5f5f4;color:#1c1917}.xyz-viewer-plugin__toolbar button:disabled,.xyz-viewer-plugin__timeline button:disabled{cursor:not-allowed;opacity:.42}.xyz-viewer-plugin__toolbar svg,.xyz-viewer-plugin__timeline svg{width:15px;height:15px}.xyz-viewer-plugin__toolbar-divider{width:1px;height:22px;flex:0 0 auto;background:#78716c2e}.xyz-viewer-plugin__stage{position:relative;min-height:260px;flex:1 1 auto;overflow:hidden;background:#fbfbfb}.xyz-viewer-plugin__canvas{position:absolute;top:0;right:0;bottom:0;left:0}.xyz-viewer-plugin__error,.xyz-viewer-plugin__empty{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;padding:20px;text-align:center;font-size:13px;line-height:20px}.xyz-viewer-plugin__error{background:#fff1f2;color:#be123c}.xyz-viewer-plugin__empty{color:#78716c}.xyz-viewer-plugin__tooltip{position:fixed;z-index:1000;display:grid;gap:2px;pointer-events:none;border:1px solid rgba(120,113,108,.28);border-radius:8px;background:#fffffff5;box-shadow:0 10px 28px #1c191729;padding:7px 8px;color:#292524;font-size:11px;line-height:15px}.xyz-viewer-plugin__tooltip span{color:#57534e}.xyz-viewer-plugin__timeline{display:grid;grid-template-columns:auto minmax(120px,1fr) auto auto;align-items:center;gap:8px;border-top:1px solid rgba(120,113,108,.14);padding:10px;color:#57534e;font-size:12px}.xyz-viewer-plugin__timeline input{width:100%}.xyz-viewer-plugin__timeline button.is-live{width:auto;padding:0 10px;color:#b91c1c}.xyz-viewer-plugin__status{display:flex;flex:0 0 auto;flex-wrap:wrap;justify-content:space-between;gap:8px 12px;border-top:1px solid rgba(120,113,108,.14);padding:9px 12px;color:#57534e;font-size:11px;line-height:16px}