agent-tempo 1.7.0-beta.1 → 1.7.0-beta.3
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.
- package/CLAUDE.md +3 -1
- package/README.md +1 -1
- package/dashboard/dist/assets/{index-jmYe6rmS.js → index-BbR7zIdK.js} +2 -2
- package/dashboard/dist/assets/index-BbR7zIdK.js.map +1 -0
- package/dashboard/dist/index.html +1 -1
- package/dashboard/package.json +1 -1
- package/dist/activities/outbox.d.ts +14 -1
- package/dist/activities/outbox.js +20 -3
- package/dist/adapters/pi/adapter.js +12 -0
- package/dist/cli/commands.js +8 -1
- package/dist/cli/ensure-infra.d.ts +9 -1
- package/dist/cli/ensure-infra.js +16 -4
- package/dist/client/core.js +41 -0
- package/dist/client/interface.d.ts +26 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.js +12 -0
- package/dist/daemon.js +22 -0
- package/dist/http/aggregate.d.ts +27 -0
- package/dist/http/aggregate.js +61 -0
- package/dist/http/coat-check.d.ts +36 -0
- package/dist/http/coat-check.js +110 -0
- package/dist/http/event-types.d.ts +16 -1
- package/dist/http/event-types.js +1 -0
- package/dist/http/gate-audit.js +1 -1
- package/dist/http/gate-registry.d.ts +126 -14
- package/dist/http/gate-registry.js +103 -13
- package/dist/http/inner-loop-routes.d.ts +12 -0
- package/dist/http/inner-loop-routes.js +15 -0
- package/dist/http/qa.d.ts +28 -0
- package/dist/http/qa.js +88 -0
- package/dist/http/server.d.ts +11 -0
- package/dist/http/server.js +58 -1
- package/dist/pi/extension.d.ts +11 -0
- package/dist/pi/extension.js +40 -19
- package/dist/pi/gate-client.d.ts +20 -3
- package/dist/pi/gate-client.js +57 -16
- package/dist/pi/headless.d.ts +3 -0
- package/dist/pi/headless.js +2 -1
- package/dist/pi/inner-loop-publisher.d.ts +9 -3
- package/dist/pi/mission-control/actions.d.ts +41 -0
- package/dist/pi/mission-control/actions.js +78 -0
- package/dist/pi/mission-control/extension.d.ts +41 -2
- package/dist/pi/mission-control/extension.js +219 -0
- package/dist/pi/mission-control/pi-ui.d.ts +53 -0
- package/dist/{pi → security}/tool-capability.js +1 -0
- package/dist/server-tools.js +4 -0
- package/dist/spawn.d.ts +7 -0
- package/dist/spawn.js +4 -0
- package/dist/tools/recruit.js +11 -0
- package/dist/tools/respond.d.ts +4 -0
- package/dist/tools/respond.js +45 -0
- package/dist/tui/index.js +3 -0
- package/dist/types.d.ts +91 -0
- package/dist/utils/validation.d.ts +12 -0
- package/dist/utils/validation.js +14 -1
- package/dist/workflows/maestro-signals.d.ts +25 -1
- package/dist/workflows/maestro-signals.js +15 -1
- package/dist/workflows/maestro.js +78 -0
- package/dist/workflows/session.js +12 -1
- package/dist/workflows/signals.d.ts +3 -1
- package/examples/agents/tempo-conductor.md +12 -0
- package/package.json +1 -1
- package/workflow-bundle.js +120 -4
- package/dashboard/dist/assets/index-jmYe6rmS.js.map +0 -1
- /package/dist/{pi → security}/tool-capability.d.ts +0 -0
package/CLAUDE.md
CHANGED
|
@@ -212,13 +212,15 @@ daemon worker notes, `npx ts-node` dev runner).
|
|
|
212
212
|
- **Claude Code headless adapter** (`agent: 'claude-code-headless'`, #520): Headless adapter that drives sessions via the official `claude` CLI as a per-turn `claude -p --output-format stream-json` subprocess. The whole point: turns bill against the host's existing Claude Code subscription extra-usage credits (Pro / Max plans) rather than a Console workspace API key — the only ToS-clean way for a third-party tool to tap that pool. Requires the `claude` binary on PATH AND a logged-in Claude Code session (`claude auth login`); recruit pre-flight rejects with an actionable error otherwise. Tool surface is the union of full Claude Code built-ins (Bash / Read / Write / Edit / Glob / Grep / WebSearch / WebFetch) and the agent-tempo MCP surface — registered via inline `--mcp-config` so `claude` spawns `dist/server.js` as its own MCP child (no in-process bridge). Recruit knobs: `permissionMode` (default `'acceptEdits'`) or `dangerouslySkipPermissions: true` (mutually exclusive). Sessions resume across restart via the existing `sessionId` metadata field — the same UUID is shared with the interactive `claude-code` adapter (per-cwd JSONL is per-cwd, not per-adapter). See `src/adapters/claude-code-headless/` and `examples/ensembles/tempo-headless-jam.yaml`.
|
|
213
213
|
- **Pi adapter** (`agent: 'pi'`, #632 / #666): Two modes. **(1) Interactive conductor** (#666): `agent-tempo up --agent pi --ensemble <name>` launches `pi` in a real terminal with the agent-tempo extension auto-loaded (`pi -e dist/pi/extension.js`); the Pi session self-bootstraps its Temporal workflow and attaches as a conductor/player — no separate recruiter step. From the TUI, `/recruit-conductor` relaunches the active ensemble's conductor — set `conductor.agent: pi` in that ensemble's lineup to make it a Pi conductor. Requires `@earendil-works/pi-coding-agent` on Node ≥ 22.19. Recommended: `ANTHROPIC_API_KEY` (without it the session falls back to Pi's own auth/default model). The `AGENT_TEMPO_*` env is auto-wired by `up`; power users can invoke the extension directly with `pi -e dist/pi/extension.js`. `--model provider/model` selector (e.g. `'github-copilot/gpt-4o'`) is a fast-follow. **(2) Headless player** (Phase 3a): `recruit` with `agent: 'pi'` — no terminal, no BaseAttachment; runs `createAgentSession` with an in-memory `SessionManager`; the module-scope singleton owns claim/heartbeat/tools/cue pump (MD-D). MD-C tool-access policy: `toolAccess: 'restricted'` (default — Bash/shell/exec HARD-BLOCKED) | `'standard'` (scoped Bash) | `'full'` (unsandboxed; requires `force: true`). `noExtensions: true` closes the S2 exec-tool-bypass gap. See `src/adapters/pi/` and `src/pi/headless.ts`.
|
|
214
214
|
- **Mission-control Pi extension** (3f): An observer-only Pi extension that turns one interactive Pi TUI into a live ensemble board + operator controller. HTTP-drives the daemon — coarse ensemble view via `/v1/events/:ensemble` SSE + fine per-player tail via `/inner` (T3); operator controls (cue/pause/play/restart/destroy + gate arm/disarm/decide) POST to the daemon write surface using `AGENT_TEMPO_HTTP_ADMIN_TOKEN`. **Never claims attachment or registers as a player** — invisible to the ensemble. ~200ms render throttle from an in-memory `BoardModel`. Requires an interactive Pi session with `ctx.hasUI`. See `src/pi/mission-control/`.
|
|
215
|
+
- **Command-center planner** (#700 P2): An inbox-less interactive Pi session (the operator's planning seat) that routes questions to players via correlated `cue` tags (`[Q <questionId>]`). Players answer with the `respond` MCP tool, which parks the answer on the per-ensemble maestro Q&A mailbox (TTL 1h, 20-slot cap). The planner is woken by an `answer` SSE event when the answer lands (`docs/SSE-PROTOCOL.md` §6). `/handoff` cues hand active work to a conductor (a registered player with a Temporal inbox). See `docs/concepts.md` for the Q&A mechanics.
|
|
216
|
+
- **Guardrail policy** (`guardrailPolicy` recruit arg, #700 P2): Per-player posture for the operator gate on headless Pi players. Four values — `'autonomous'` (default; no gate), `'monitored'` (gate engaged; fail-open: auto-allow after 45 s), `'supervised'` (gate engaged; fail-closed: auto-deny after 300 s; **client-cooperative in P2, not tamper-proof**; daemon-side enforcement is P2.1 #44), `'observe-only'` (non-`low-risk` tools hard-blocked outright). Persisted on `SessionMetadata`; re-sourced at each `(re)attach` from `getMetadata`. See `docs/concepts.md` for operator gate mechanics.
|
|
215
217
|
- **Mock adapter** (`agent: 'mock'`, dev mode only): Four modes: `echo` (echoes input), `scripted` (replays YAML scenario rules), `silent` (drains messages without replying — heartbeat-stale validation), `chaos` (probabilistic fail/crash injection via seeded PRNG). Only registered when `isDevMode()` is true; stripped from the npm tarball by `prepack`. See `src/adapters/mock/`.
|
|
216
218
|
- **Saveable state** (#334, ADR 0011): Per-player curated state slots — the player itself decides what context survives a restart. Three MCP tools: `save_state` (owner-only write, max 4 slots × 32 KiB), `fetch_state` (read self or peer; audit identity recorded on each entry's `savedBy`), `clear_state` (owner-only). `restart` accepts `loadFromState: true | 'someKey'` to seed the new session from a saved-state slot instead of (or, with `transcript: 'replay'`, alongside) transcript replay. Saved-state delivery uses `from: 'self-restart'` as a stable system identity. Empty-slot fallback: graceful — falls through to transcript replay with a log line. See [docs/design/334-player-saveable-state.md](docs/design/334-player-saveable-state.md).
|
|
217
219
|
- **Coat-check** (#318, ADR 0008): Per-ensemble transient content store on Maestro state. Solves the 100 KB cue body cap — stash a large artifact with `coat_check_put` (returns a ticket id) and attach the ticket to a `cue` via `attachmentTicket`; the recipient calls `coat_check_get` to pull the full body. Four MCP tools: `coat_check_put` (any player; max 32 KiB per entry, 20 slots per ensemble, TTL 7d default), `coat_check_get` (any player; bumps fetch-audit counters), `coat_check_list` (read-only survey; headers only, content omitted), `coat_check_evict` (owner or conductor). Saturation rejects with `CoatCheckSlotsFull` (no LRU eviction). See `src/tools/coat-check-*.ts` and [docs/adr/0008-coat-check-pattern.md](docs/adr/0008-coat-check-pattern.md).
|
|
218
220
|
- **Lineup examples**: Six pre-built ensemble YAML files in `examples/ensembles/` — `tempo-big-band`, `tempo-dev-team`, `tempo-review-squad`, `tempo-jam-session`, `tempo-mock-jam` (dev-mode all-mock ensemble), `tempo-headless-jam` (#520 — all-`claude-code-headless` subscription-billed ensemble). Load with `agent-tempo up --lineup <name>` or the `load_lineup` tool.
|
|
219
221
|
- **GitHub App identity** (`agent-tempo[bot]`): When a player writes to GitHub — issue comments, PR creation/merge, commits, labels, check runs — **use `./scripts/ensemble-gh`** instead of `gh`. The wrapper mints a short-lived installation token so the action is attributed to `agent-tempo[bot]`, not to the human maintainer, making the AI authorship visible. Plain `gh` is still correct for read-only local dev (`gh pr view`, `gh repo clone`, `gh auth status`). Every bot-authored comment/PR body must include the AI attribution footer documented in [docs/github-app.md](docs/github-app.md).
|
|
220
222
|
|
|
221
|
-
See [docs/concepts.md](docs/concepts.md) for the full glossary (Adapter, Attachment phases, Restart, Detach/Destroy, Migrate, Broadcast, Recall, Schedule, Lineup, Quality Gate, Worktree, Stage, Hold/Release, Pause/Resume, Maestro, TempoClient, and more).
|
|
223
|
+
See [docs/concepts.md](docs/concepts.md) for the full glossary (Adapter, Attachment phases, Restart, Detach/Destroy, Migrate, Broadcast, Recall, Schedule, Lineup, Quality Gate, Worktree, Stage, Hold/Release, Pause/Resume, Maestro, TempoClient, Guardrail policy, Command-center planner, and more).
|
|
222
224
|
|
|
223
225
|
## Commit Convention
|
|
224
226
|
|
package/README.md
CHANGED
|
@@ -277,7 +277,7 @@ From the TUI, `/recruit-conductor` relaunches the active ensemble's conductor
|
|
|
277
277
|
|
|
278
278
|
**Prerequisites:** `@earendil-works/pi-coding-agent` on Node ≥ 22.19. Recommended: `ANTHROPIC_API_KEY` (without it the session falls back to Pi's own auth/default model).
|
|
279
279
|
|
|
280
|
-
**Headless Pi players** — recruit as a background agent slot using `agent: 'pi'` (
|
|
280
|
+
**Headless Pi players** — recruit as a background agent slot using `agent: 'pi'`. Pass `guardrailPolicy: 'monitored' | 'supervised' | 'observe-only'` to control the operator gate (default `'autonomous'` — no gate). See [docs/concepts.md](docs/concepts.md#command-center-and-player-supervision) for the gate mechanics and the supervised caveat.
|
|
281
281
|
|
|
282
282
|
📖 [Pi integration reference → docs/design/pi-hardening-h1-h2-h3.md](docs/design/pi-hardening-h1-h2-h3.md)
|
|
283
283
|
|
|
@@ -13,7 +13,7 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
13
13
|
|
|
14
14
|
`))!==-1;){let e=s.slice(0,n);s=s.slice(n+2);let t=qo(e);t&&r(t)}}}finally{try{a.cancel()}catch{}}}function qo(e){if(!e||e.startsWith(`:`))return null;let t,n=[];for(let r of e.split(`
|
|
15
15
|
`))r.startsWith(`event: `)?t=r.slice(7):r.startsWith(`data: `)&&n.push(r.slice(6));if(!t||n.length===0)return null;try{let e=JSON.parse(n.join(`
|
|
16
|
-
`));return{v:1,type:t,eventId:e.eventId,payload:e.payload}}catch{return null}}var Jo=null;function Yo(){return Jo||=Bo(),Jo}var Xo=[`health`],Zo=[`ensembles`],Qo=[`hosts`],$o=[`orphans`];function es(e){return e?[...$o,e]:[...$o,`__all__`]}var ts=[`agent-types`],ns=[`lineups`],rs=[`ensemble`];function is(e){return[...rs,e]}function as(e,t,n,r={}){let{enabled:i,refetchOnWindowFocus:a=!0,...o}=r;return st({queryKey:e,queryFn:async()=>{try{return await t()}catch(e){throw W(`snapshot.error`,{resource:n,...o,error:e instanceof Error?e.message:String(e)},`warn`),e}},staleTime:5e3,refetchInterval:3e4,refetchOnWindowFocus:a,...i!==void 0&&{enabled:i}})}function os(e={}){let t=e.client??Yo();return as(Xo,()=>t.health(),`health`)}function ss(e={}){let t=e.client??Yo();return as(Zo,()=>t.listEnsembles(),`ensembles`)}function cs(e={}){let t=e.client??Yo();return as(Qo,()=>t.hosts(),`hosts`)}function ls(e,t={}){let n=t.client??Yo();return st({queryKey:es(e),queryFn:async()=>{try{return await n.orphans(e?{ensemble:e}:void 0)}catch(t){throw W(`snapshot.error`,{resource:`orphans`,...e?{ensemble:e}:{},error:t instanceof Error?t.message:String(t)},`warn`),t}},staleTime:1e4,refetchInterval:3e4,refetchOnWindowFocus:!0})}function us(e={}){let t=e.client??Yo();return st({queryKey:[...$o,`__count__`],queryFn:async()=>{try{return(await t.orphans()).orphans.length}catch(e){throw W(`snapshot.error`,{resource:`orphans-count`,error:e instanceof Error?e.message:String(e)},`warn`),e}},staleTime:3e4,refetchInterval:6e4,refetchOnWindowFocus:!0})}function ds(e={}){let t=e.client??Yo();return as(ts,()=>t.agentTypes(),`agent-types`)}function fs(e={}){let t=e.client??Yo();return as(ns,()=>t.lineups(),`lineups`)}function ps(e,t={}){let n=t.client??Yo();return st({queryKey:is(e??``),queryFn:async()=>{if(!e)throw Error(`ensemble required`);try{return await n.state(e)}catch(t){throw W(`snapshot.error`,{resource:`ensemble-snapshot`,ensemble:e,error:t instanceof Error?t.message:String(t)},`warn`),t}},enabled:!!e,staleTime:5e3,refetchOnWindowFocus:!1})}var ms=6e3,hs=Object.freeze({activeEnsemble:null,setActiveEnsemble:()=>{},unread:Object.freeze({}),markRead:()=>{},toasts:Object.freeze([]),dismissToast:()=>{},fire:()=>{}}),gs=(0,_.createContext)(null);function _s(){let{id:e}=Mi();return e??null}function vs(){return(0,_.useContext)(gs)??hs}function ys({children:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)({}),[a,o]=(0,_.useState)([]),s=(0,_.useRef)(1),c=(0,_.useRef)(null),l=(0,_.useCallback)(e=>{c.current=e,n(e),e!=null&&(i(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}),o(t=>t.filter(t=>t.ensembleId!==e)))},[]),u=_s();(0,_.useEffect)(()=>{l(u)},[u,l]);let d=(0,_.useCallback)(e=>{i(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),f=(0,_.useCallback)(e=>{o(t=>t.filter(t=>t.id!==e))},[]),p=(0,_.useCallback)(e=>{let t=e.ensembleId,n=e.ensembleName??t,r=t===c.current;r||i(e=>({...e,[t]:(e[t]??0)+1}));let a=Date.now(),l=s.current++;o(i=>{let o=i[i.length-1];if(o&&o.ensembleId===t&&o.sender===e.sender&&a-o.firstAt<8e3){let t={...o,body:e.body,count:o.count+1,ts:a,expiresAt:a+ms};return[...i.slice(0,-1),t]}if(r)return i;let s={id:l,ensembleId:t,ensembleName:n,sender:e.sender,senderType:e.senderType,body:e.body,firstAt:a,ts:a,expiresAt:a+ms,count:1};return[...i,s]})},[]);(0,_.useEffect)(()=>{if(a.length===0)return;let e=Date.now(),t=a.map(t=>{let n=Math.max(0,t.expiresAt-e);return setTimeout(()=>{o(e=>e.filter(e=>e.id!==t.id))},n)});return()=>t.forEach(clearTimeout)},[a]);let m=(0,_.useMemo)(()=>({activeEnsemble:t,setActiveEnsemble:l,unread:r,markRead:d,toasts:a,dismissToast:f,fire:p}),[t,l,r,d,a,f,p]);return(0,R.jsx)(gs.Provider,{value:m,children:e})}function bs(e){let t=ss().data;(0,_.useEffect)(()=>{if(!t||t.length===0)return;let n=Yo(),r=!1,i=t.map(t=>{let i=new AbortController;return(async()=>{try{for await(let a of n.subscribe(t.name,{signal:i.signal,topics:[`chat`]})){if(r)break;if(a.type!==`chat.appended`)continue;let n=a.payload;n.role===`maestro-in`&&e({ensembleId:t.name,ensembleName:t.name,sender:n.from,body:n.text})}}catch{}})(),i});return()=>{r=!0,i.forEach(e=>e.abort(`unmount`))}},[t,e])}function xs(){let{fire:e}=vs();return bs(e),null}var Ss=[{id:`overview`,icon:`◇`,label:`Overview`,to:`/`},{id:`loadouts`,icon:`≡`,label:`Loadouts`,to:`/loadouts`},{id:`types`,icon:`♪`,label:`Player types`,to:`/player-types`},{id:`hosts`,icon:`⌂`,label:`Hosts`,to:`/hosts`},{id:`orphans`,icon:`⚠`,label:`Orphans`,to:`/orphans`},{id:`schedules`,icon:`⧗`,label:`Schedules`,to:`/schedules`},{id:`settings`,icon:`⚙`,label:`Settings`,to:`/settings`}];function Cs(){let e=ss().data??[],{id:t}=Mi(),n=t,r=Ti().pathname.startsWith(`/ensemble/`),i=e.filter(e=>e.playerCount>0).length,{unread:a,markRead:o}=vs(),s=us().data??0;return(0,R.jsxs)(`aside`,{className:`sidebar`,"data-testid":`sidebar`,"aria-label":`Main navigation`,children:[(0,R.jsx)(`div`,{className:`sidebar-brand`,children:(0,R.jsx)(Ao,{size:`md`,running:!1})}),(0,R.jsxs)(`div`,{className:`sidebar-section`,"data-testid":`sidebar-section-ensembles`,children:[(0,R.jsxs)(`div`,{className:`sidebar-kicker`,children:[(0,R.jsx)(`span`,{children:`Ensembles`}),(0,R.jsxs)(`span`,{className:`count`,children:[i,` running`]})]}),e.length===0?(0,R.jsx)(`div`,{className:`dim`,"data-testid":`sidebar-ensembles-empty`,style:{padding:`6px 12px`,fontFamily:`var(--ff-mono)`,fontSize:11},children:`No ensembles`}):e.map(e=>{let t=a[e.name]??0;return(0,R.jsxs)(ao,{to:`/ensemble/${encodeURIComponent(e.name)}`,"data-testid":`sidebar-ensemble-${e.name}`,className:[`ensemble-row`,n===e.name?`is-active`:``,e.playerCount>0?`has-active`:``,t>0?`has-unread`:``].filter(Boolean).join(` `),style:{textDecoration:`none`},onClick:()=>{t>0&&o(e.name)},children:[(0,R.jsx)(`span`,{className:`er-dot`}),(0,R.jsx)(`span`,{className:`er-initial`,"aria-hidden":`true`,children:e.name.charAt(0).toUpperCase()}),(0,R.jsxs)(`span`,{className:`col`,style:{gap:0},children:[(0,R.jsx)(`span`,{className:`er-name`,children:e.name}),(0,R.jsxs)(`span`,{className:`er-meta mono`,children:[e.playerCount,` `,e.playerCount===1?`player`:`players`]})]}),(0,R.jsx)(No,{count:t}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`↵`})]},e.name)}),(0,R.jsxs)(ao,{to:`/create-ensemble`,"data-testid":`sidebar-new-ensemble`,className:`ensemble-row ensemble-row--new`,style:{marginTop:4,color:`var(--accent)`,textDecoration:`none`},children:[(0,R.jsx)(`span`,{className:`icon-g`,style:{color:`var(--accent)`},children:`+`}),(0,R.jsx)(`span`,{className:`er-name`,children:`New ensemble…`}),(0,R.jsx)(`span`,{})]})]}),(0,R.jsxs)(`div`,{className:`sidebar-section`,"data-testid":`sidebar-section-library`,children:[(0,R.jsx)(`div`,{className:`sidebar-kicker`,children:(0,R.jsx)(`span`,{children:`Library`})}),Ss.map(e=>(0,R.jsxs)(oo,{to:e.to,end:e.to===`/`,"data-testid":`nav-${e.id}`,className:({isActive:t})=>`nav-row`+(t&&!(e.id===`overview`&&r)?` is-active`:``),style:{textDecoration:`none`},children:[(0,R.jsx)(`span`,{className:`nav-icon`,children:e.icon}),(0,R.jsx)(`span`,{children:e.label}),e.id===`orphans`&&s>0&&(0,R.jsx)(`span`,{"data-testid":`sidebar-orphans-badge`,className:`notif-badge`,"aria-label":`${s} orphan${s===1?``:`s`}`,children:s})]},e.id))]}),(0,R.jsxs)(`div`,{className:`sidebar-maestro`,title:`You — the maestro`,children:[(0,R.jsx)(Mo,{size:32}),(0,R.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,lineHeight:1.15,marginLeft:8,flex:1,minWidth:0},children:[(0,R.jsx)(`span`,{style:{fontFamily:`var(--ff-display)`,fontSize:14,color:`var(--text)`},children:`maestro`}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`operator`})]})]}),(0,R.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`conn-ok`,children:`●`}),` localhost:7233`]}),(0,R.jsx)(`span`,{"data-testid":`sidebar-version`,children:`v0.28`})]})]})}var ws=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Ts=(e=>e?ws(e):ws),Es=e=>e;function Ds(e,t=Es){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Os=e=>{let t=Ts(e),n=e=>Ds(t,e);return Object.assign(n,t),n},ks=(e=>e?Os(e):Os),As=`agent-tempo:prefs`,js=`dark`,Ms=`terracotta`;function Ns(){if(typeof window>`u`||!window.localStorage)return{theme:js,density:6,accent:Ms};try{let e=window.localStorage.getItem(As);if(e){let t=JSON.parse(e);return{theme:t.theme===`light`?`light`:`dark`,density:Ps(t.density)?t.density:6,accent:Fs(t.accent)?t.accent:Ms}}}catch{}return{theme:js,density:6,accent:Ms}}function Ps(e){return typeof e==`number`&&e>=4&&e<=9&&Number.isInteger(e)}function Fs(e){return e===`terracotta`||e===`sage`||e===`plum`}function Is(e){if(!(typeof window>`u`||!window.localStorage))try{window.localStorage.setItem(As,JSON.stringify(e))}catch{}}function Ls(e){typeof document>`u`||(document.documentElement.dataset.theme=e.theme,document.documentElement.dataset.density=String(e.density),document.documentElement.dataset.accent=e.accent)}var Rs=ks()((e,t)=>{let n=Ns();Ls(n);let r=n=>{e(n);let r={theme:t().theme,density:t().density,accent:t().accent};Ls(r),Is(r)};return{...n,setTheme:e=>{r({theme:e}),W(`prefs-theme-set`,{theme:e})},setDensity:e=>{r({density:e}),W(`prefs-density-set`,{density:e})},setAccent:e=>{r({accent:e}),W(`prefs-accent-set`,{accent:e})},toggleTheme:()=>{let e=t().theme===`dark`?`light`:`dark`;r({theme:e}),W(`prefs-theme-toggled`,{theme:e})}}}),zs=[4,5,6,7,8,9];function Bs({title:e=`Maestro`,prefix:t,accent:n,pills:r,actions:i,subtitle:a}){return(0,R.jsxs)(`header`,{className:`page-header`,"data-testid":`page-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`page-title-row`,children:[(0,R.jsxs)(`h1`,{className:`page-title`,children:[t&&(0,R.jsx)(`span`,{className:`prefix mono`,children:t}),e,n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),n.startsWith(`@`)?n.slice(1):n]})]}),r&&(0,R.jsx)(`div`,{className:`page-pills`,children:r})]}),a&&(0,R.jsx)(`div`,{className:`page-subtitle`,children:a})]}),(0,R.jsx)(`div`,{className:`page-actions`,children:i??(0,R.jsx)(Vs,{})})]})}function Vs(){let e=Rs(e=>e.theme),t=Rs(e=>e.density),n=Rs(e=>e.toggleTheme),r=Rs(e=>e.setDensity);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,color:`var(--dim)`,fontSize:`var(--density-fs-sm)`},children:[(0,R.jsx)(`span`,{children:`Density`}),(0,R.jsx)(`input`,{type:`range`,min:4,max:9,step:1,value:t,"data-testid":`settings-density-slider`,"aria-label":`Density`,onChange:e=>{let t=Number(e.target.value);zs.includes(t)&&r(t)}}),(0,R.jsx)(`span`,{className:`num mono`,style:{minWidth:14,textAlign:`right`},children:t})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"data-testid":`settings-theme-toggle`,onClick:n,"aria-label":`Switch to ${e===`dark`?`light`:`dark`} theme`,children:e===`dark`?`☀ Light`:`☾ Dark`})]})}function Hs(){return(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,children:(0,R.jsx)(`path`,{d:`M4 7h16M4 12h16M4 17h16`})})}function Us(){return(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.5`}),(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,R.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.5`})]})}function Ws({activeEnsemble:e,lineup:t,onMenu:n,onAction:r,actionIcon:i,actionLabel:a=`More`,actionActive:o=!1,status:s}){return(0,R.jsxs)(`header`,{className:`phone-appbar`,"data-testid":`phone-appbar`,"aria-label":`Mobile top bar`,children:[(0,R.jsxs)(`div`,{className:`phone-appbar-row`,children:[(0,R.jsx)(`button`,{type:`button`,className:`phone-appbar-btn`,"aria-label":`Switch ensemble`,onClick:n,"data-testid":`phone-appbar-menu`,children:(0,R.jsx)(Hs,{})}),(0,R.jsxs)(`div`,{className:`phone-appbar-title`,children:[(0,R.jsx)(`span`,{className:`phone-appbar-kicker`,children:t?`lineup · ${t}`:`ensemble`}),e&&(0,R.jsxs)(`span`,{className:`phone-appbar-name`,"data-testid":`phone-appbar-ensemble-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e]})]}),(0,R.jsx)(`button`,{type:`button`,className:`phone-appbar-btn`+(o?` is-active`:``),"aria-label":a,"aria-pressed":o||void 0,onClick:r,"data-testid":`phone-appbar-action`,children:i??(0,R.jsx)(Us,{})})]}),s&&(0,R.jsxs)(`div`,{className:`phone-appbar-status mono`,"data-testid":`phone-appbar-status`,children:[s.active!=null&&(0,R.jsxs)(`span`,{className:`phone-stat ok`,children:[(0,R.jsx)(`span`,{className:`phone-stat-dot`}),` `,s.active,` active`]}),s.idle!=null&&(0,R.jsxs)(`span`,{className:`phone-stat dim`,children:[s.idle,` idle`]}),s.detached!=null&&s.detached>0&&(0,R.jsxs)(`span`,{className:`phone-stat warn`,children:[`◐ `,s.detached,` detached`]}),s.uptime&&(0,R.jsxs)(`span`,{className:`phone-stat dim`,children:[`up `,s.uptime]})]})]})}var Gs={workspace:(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,R.jsx)(`path`,{d:`M4 6h16M4 12h10M4 18h16`})}),overview:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`9`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`5`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`3`,y:`15`,width:`7`,height:`6`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`14`,y:`11`,width:`7`,height:`10`,rx:`1.5`})]}),library:(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,R.jsx)(`path`,{d:`M4 5v14M9 5v14M14 5l5 14M19 5l-5 14`})}),settings:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,R.jsx)(`path`,{d:`M19.4 15a1.6 1.6 0 0 0 .3 1.7l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-1.7-.3 1.6 1.6 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.7.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0 .3-1.7 1.6 1.6 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.7l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.7.3H9a1.6 1.6 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.7-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.7V9a1.6 1.6 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z`})]})},Ks=[{k:`workspace`,label:`Now`,icon:Gs.workspace},{k:`overview`,label:`Ensembles`,icon:Gs.overview},{k:`library`,label:`Library`,icon:Gs.library},{k:`settings`,label:`Settings`,icon:Gs.settings}],qs=[`/loadouts`,`/player-types`,`/schedules`,`/hosts`];function Js(e,t){return t?`workspace`:e.startsWith(`/settings`)?`settings`:qs.some(t=>e.startsWith(t))?`library`:`overview`}function Ys(){let e=Oi(),t=Ti(),{id:n}=Mi(),r=Js(t.pathname,!!n),i=t=>{switch(t){case`workspace`:e(n?`/ensemble/${encodeURIComponent(n)}`:`/`);return;case`overview`:e(`/`);return;case`library`:e(`/loadouts`);return;case`settings`:e(`/settings`);return}};return(0,R.jsx)(`nav`,{className:`phone-tabbar`,"data-testid":`phone-tabbar`,role:`navigation`,"aria-label":`Mobile primary navigation`,children:Ks.map(e=>{let t=e.k===r;return(0,R.jsxs)(`button`,{type:`button`,className:`phone-tab`+(t?` is-active`:``),"data-testid":`phone-tab-${e.k}`,"aria-current":t?`page`:void 0,onClick:()=>i(e.k),children:[(0,R.jsx)(`span`,{className:`phone-tab-icon`,children:e.icon}),(0,R.jsx)(`span`,{className:`phone-tab-label`,children:e.label})]},e.k)})})}function Xs({open:e,onClose:t,activeEnsemble:n}){let r=Oi(),i=ss().data??[];if(!e)return null;let a=e=>{r(`/ensemble/${encodeURIComponent(e)}`),t()};return(0,R.jsx)(`div`,{className:`ens-switcher`,role:`dialog`,"aria-modal":`true`,"aria-label":`Switch ensemble`,"data-testid":`ensemble-switcher`,onClick:()=>t(),children:(0,R.jsxs)(`div`,{className:`ens-switcher-sheet`,onClick:e=>e.stopPropagation(),"data-testid":`ensemble-switcher-sheet`,children:[(0,R.jsx)(`div`,{className:`ens-switcher-grip`}),(0,R.jsxs)(`div`,{className:`ens-switcher-head`,children:[(0,R.jsx)(`div`,{className:`ens-switcher-title`,children:`Switch ensemble`}),(0,R.jsx)(`button`,{type:`button`,className:`ens-switcher-close`,"aria-label":`Close`,onClick:t,"data-testid":`ensemble-switcher-close`,children:`×`})]}),(0,R.jsx)(`div`,{className:`ens-switcher-list`,children:i.length===0?(0,R.jsx)(`div`,{className:`dim`,"data-testid":`ensemble-switcher-empty`,style:{padding:`20px 12px`,textAlign:`center`,fontFamily:`var(--ff-mono)`,fontSize:12},children:`No ensembles yet`}):i.map(e=>{let t=e.name===n;return(0,R.jsxs)(`button`,{type:`button`,className:`ens-switcher-row`+(t?` is-active`:``),onClick:()=>a(e.name),"data-testid":`ensemble-switcher-row-${e.name}`,children:[(0,R.jsx)(`span`,{className:`ens-switcher-dot`+(e.playerCount>0?` on`:``)}),(0,R.jsxs)(`span`,{className:`ens-switcher-meta`,children:[(0,R.jsxs)(`span`,{className:`ens-switcher-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e.name]}),(0,R.jsxs)(`span`,{className:`ens-switcher-sub`,children:[e.playerCount,` `,e.playerCount===1?`player`:`players`]})]}),t&&(0,R.jsx)(`span`,{className:`ens-switcher-check`,"aria-hidden":`true`,children:`✓`})]},e.name)})}),(0,R.jsxs)(`button`,{type:`button`,className:`ens-switcher-new`,onClick:()=>{r(`/create-ensemble`),t()},"data-testid":`ensemble-switcher-new`,children:[(0,R.jsx)(`span`,{className:`ens-switcher-plus`,children:`+`}),(0,R.jsx)(`span`,{children:`New ensemble…`})]})]})})}var Zs=[`♩`,`♪`,`♫`,`♬`,`♭`,`♮`,`♯`,`𝅘𝅥`];function Qs(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return Zs[t%Zs.length]}var $s={"tempo-conductor":32,"tempo-composer":210,"tempo-soloist":18,"tempo-tuner":150,"tempo-critic":340,"tempo-roadie":260,"tempo-improv":48,"tempo-liner":190};function ec(e){return e?$s[e]??200:200}var tc={attached:{icon:`●`,label:`active`,color:`var(--ok)`,bucket:`active`},processing:{icon:`●`,label:`processing`,color:`var(--ok)`,bucket:`active`,pulse:!0},awaiting:{icon:`○`,label:`idle`,color:`var(--text)`,bucket:`idle`},draining:{icon:`◐`,label:`draining`,color:`var(--warn)`,bucket:`disconnected`},detached:{icon:`◐`,label:`detached`,color:`var(--warn)`,bucket:`disconnected`},booting:{icon:`◔`,label:`booting`,color:`var(--dim)`,bucket:`pending`},gone:{icon:`✕`,label:`gone`,color:`var(--dim)`,bucket:`gone`}};function nc(e){return tc[e??`booting`]??tc.booting}function rc({toast:e,stackIndex:t,onOpen:n,onDismiss:r}){let{id:i,ensembleName:a,sender:o,senderType:s,body:c,count:l}=e,u=ec(s),d=(o||`?`).charAt(0).toUpperCase();return(0,R.jsxs)(`div`,{className:`toast`,"data-testid":`toast-${i}`,"data-stack-index":t,role:`alert`,onClick:e=>{e.target.closest(`.toast-close`)||n()},children:[(0,R.jsx)(`div`,{className:`toast-avatar`,style:{background:`oklch(0.62 0.13 ${u})`,color:`#0F1117`},"aria-hidden":`true`,children:d}),(0,R.jsxs)(`div`,{className:`toast-body`,children:[(0,R.jsxs)(`div`,{className:`toast-head`,children:[(0,R.jsxs)(`span`,{className:`toast-sender mono`,children:[`@`,o]}),(0,R.jsx)(`span`,{className:`toast-divider`,children:`·`}),(0,R.jsx)(`span`,{className:`toast-ensemble`,children:a}),l>1&&(0,R.jsx)(`span`,{className:`toast-count mono`,children:l}),(0,R.jsx)(`span`,{className:`toast-time mono`,children:`just now`})]}),(0,R.jsx)(`div`,{className:`toast-message`,children:c}),(0,R.jsxs)(`div`,{className:`toast-actions`,children:[(0,R.jsx)(`button`,{type:`button`,className:`toast-action`,"data-testid":`toast-reply`,onClick:e=>{e.stopPropagation(),n()},children:`Reply →`}),(0,R.jsx)(`button`,{type:`button`,className:`toast-action toast-action--ghost`,"data-testid":`toast-dismiss`,onClick:e=>{e.stopPropagation(),r()},children:`Dismiss`})]})]}),(0,R.jsx)(`button`,{type:`button`,className:`toast-close`,"data-testid":`toast-dismiss`,"aria-label":`Close`,onClick:e=>{e.stopPropagation(),r()},children:`×`})]})}function ic({onOpen:e}){let{toasts:t,dismissToast:n}=vs();if(!t.length)return null;let r=[...t].reverse(),i=r.slice(0,3),a=r.length-i.length;return(0,R.jsxs)(`div`,{className:`toast-stack`,"data-testid":`toast-stack`,role:`region`,"aria-label":`Notifications`,children:[a>0&&(0,R.jsxs)(`div`,{className:`toast-overflow mono`,"data-testid":`toast-overflow`,children:[`+`,a,` more`]}),i.map((t,r)=>(0,R.jsx)(rc,{toast:t,stackIndex:r,onDismiss:()=>n(t.id),onOpen:()=>{e(t.ensembleId),n(t.id)}},t.id))]})}var ac=(0,_.createContext)({setRender:()=>{}});function oc(e){let{setRender:t}=(0,_.useContext)(ac);(0,_.useEffect)(()=>(t(e),()=>t(null)),[e,t])}var sc=(0,_.createContext)({setOverride:()=>{}});function cc(e){let{setOverride:t}=(0,_.useContext)(sc);(0,_.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function lc({children:e}){let t=Ti(),n=Oi(),r=t.pathname.startsWith(`/ensemble/`),{id:i}=Mi(),[a,o]=(0,_.useState)(!1),s=(0,_.useCallback)(e=>{n(`/ensemble/${encodeURIComponent(e)}`)},[n]),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(e=>{l(t=>e===null?t===null?t:null:t?.render===e?t:{render:e})},[]),d=(0,_.useMemo)(()=>({setRender:u}),[u]),[f,p]=(0,_.useState)(null),m=(0,_.useCallback)(e=>{p(t=>e===null?t===null?t:null:t===e?t:e)},[]),h=(0,_.useMemo)(()=>({setOverride:m}),[m]);return(0,R.jsx)(ac.Provider,{value:d,children:(0,R.jsx)(sc.Provider,{value:h,children:(0,R.jsx)(`div`,{className:`artboard-body`,children:(0,R.jsxs)(`div`,{className:`app-shell`+(r?` app-shell--workspace`:``),"data-testid":`app-shell`,children:[(0,R.jsx)(Cs,{}),(0,R.jsx)(Ws,{activeEnsemble:i,onMenu:()=>o(!0),lineup:f?.lineup,status:f?.status,onAction:f?.onAction,actionIcon:f?.actionIcon,actionLabel:f?.actionLabel,actionActive:f?.actionActive}),(0,R.jsx)(`main`,{className:`main`,"data-testid":`app-shell-main`,children:r?e:(0,R.jsxs)(R.Fragment,{children:[c?c.render():(0,R.jsx)(Bs,{title:`Maestro`}),(0,R.jsx)(`div`,{className:`page-pad scroll`,"data-testid":`app-shell-content`,style:{display:`flex`,flexDirection:`column`,gap:`var(--density-gap)`},children:e})]})}),(0,R.jsx)(Ys,{}),(0,R.jsx)(Xs,{open:a,onClose:()=>o(!1),activeEnsemble:i}),(0,R.jsx)(ic,{onOpen:s})]})})})})}function G({variant:e=`default`,size:t=`md`,icon:n,children:r,type:i=`button`,className:a,...o}){return(0,R.jsxs)(`button`,{type:i,className:[`btn`,e!==`default`&&`btn-${e}`,t!==`md`&&`btn-${t}`,a].filter(Boolean).join(` `),...o,children:[n&&(0,R.jsx)(`span`,{className:`btn-icon`,children:n}),r!==void 0&&(0,R.jsx)(`span`,{children:r})]})}function uc({label:e,onClose:t,testId:n,children:r}){let i=(0,_.useRef)(null),a=(0,_.useRef)(t);return a.current=t,(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),a.current())};document.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,i.current?.focus(),()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[]),(0,R.jsxs)(`div`,{"data-testid":n,role:`dialog`,"aria-modal":`true`,"aria-label":e,ref:i,tabIndex:-1,onClick:e=>{e.target===e.currentTarget&&t()},style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,padding:`60px 24px 24px`,background:`rgba(8, 6, 5, 0.55)`,backdropFilter:`blur(2px)`,zIndex:100},children:[e&&(0,R.jsx)(`div`,{style:{position:`absolute`,top:18,left:0,right:0,textAlign:`center`,pointerEvents:`none`},children:(0,R.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,letterSpacing:`0.16em`,color:`rgba(255,255,255,0.55)`,textTransform:`uppercase`,background:`rgba(0,0,0,0.45)`,padding:`4px 10px`,borderRadius:999,border:`1px solid rgba(255,255,255,0.1)`},children:e})}),r]})}function dc({title:e,step:t,totalSteps:n,stepLabel:r,children:i,footer:a,testId:o}){let s=t!==void 0&&n!==void 0?`STEP ${t} / ${n}${r?` · ${r}`:``}`:null;return(0,R.jsxs)(`div`,{"data-testid":o,className:`dialog`,style:{maxWidth:720,boxShadow:`0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--rule-strong)`},onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`dialog-head`,children:[(0,R.jsx)(`div`,{className:`dialog-title`,children:e}),s&&(0,R.jsx)(`div`,{className:`steps`,children:s})]}),(0,R.jsx)(`div`,{className:`dialog-body`,children:i}),(0,R.jsx)(`div`,{className:`dialog-foot`,children:a})]})}function fc({testId:e,options:t,value:n,onChange:r,style:i}){return(0,R.jsx)(`div`,{className:`picker-list`,"data-testid":e,role:`radiogroup`,style:i,children:t.map(t=>{let i=t.value===n;return(0,R.jsxs)(`button`,{type:`button`,"data-testid":`${e}-option-${t.value}`,"data-state":i?`active`:void 0,role:`radio`,"aria-checked":i,className:`picker-row`+(i?` is-active`:``),onClick:()=>r(t.value),style:{all:`unset`,display:`grid`,gridTemplateColumns:`18px 1fr auto`,gap:10,alignItems:`center`,borderRadius:6,cursor:`pointer`,fontSize:13,...i?{background:`var(--accent-soft)`,color:`var(--text)`}:t.accent?{color:`var(--accent)`}:null},children:[(0,R.jsx)(`span`,{className:`marker`,"aria-hidden":`true`,style:{color:`var(--accent)`,fontFamily:`var(--ff-mono)`,fontSize:11},children:t.accent?`+`:i?`▸`:``}),(0,R.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:0},children:[(0,R.jsx)(`span`,{className:`name`,style:{fontWeight:500},children:t.name}),t.desc&&(0,R.jsx)(`span`,{className:`desc`,style:{fontSize:11.5,color:`var(--dim)`,fontFamily:`var(--ff-mono)`},children:t.desc})]}),t.right??(0,R.jsx)(`span`,{})]},t.value)})})}function pc({testId:e,options:t,value:n,onChange:r}){return(0,R.jsx)(`div`,{className:`chipset`,"data-testid":e,role:`radiogroup`,children:t.map(t=>{let i=t.value===n;return(0,R.jsx)(`button`,{type:`button`,"data-testid":`${e}-chip-${t.value}`,"data-state":i?`active`:void 0,role:`radio`,"aria-checked":i,className:`chip`+(i?` is-active`:``),onClick:()=>r(t.value),style:{border:`none`,cursor:`pointer`},children:t.label},t.value)})})}function mc({id:e,label:t,hint:n,error:r,children:i}){return(0,R.jsxs)(`div`,{className:`field`,children:[(0,R.jsxs)(`label`,{htmlFor:e,className:`field-label`,children:[(0,R.jsx)(`span`,{children:t}),n&&(0,R.jsxs)(`span`,{className:`mono dim`,children:[`· `,n]})]}),i,r&&(0,R.jsx)(`span`,{"data-testid":`${e}-error`,style:{fontSize:11,color:`var(--err)`,fontFamily:`var(--ff-mono)`},children:r})]})}function hc({testId:e,label:t,value:n}){return(0,R.jsxs)(`div`,{"data-testid":e,style:{display:`grid`,gridTemplateColumns:`140px 1fr`,gap:12,fontSize:13,padding:`6px 0`,borderBottom:`1px dashed var(--rule)`},children:[(0,R.jsx)(`span`,{className:`dim`,style:{fontFamily:`var(--ff-mono)`},children:t}),(0,R.jsx)(`span`,{style:{fontFamily:`var(--ff-mono)`,wordBreak:`break-word`},children:n})]})}var gc=`optimistic-`,_c=()=>`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;function vc(e,t={}){let n=Ke(),r=t.client??Yo(),i=is(e);return ct({mutationFn:({to:t,message:n})=>r.cue(e,t,n),onMutate:async({to:t,message:r})=>{let a=`${gc}${_c()}`;W(`mutation.cue.started`,{ensemble:e,target:t,optimisticId:a}),await n.cancelQueries({queryKey:i});let o=n.getQueryData(i),s={id:a,from:`maestro`,to:t,text:r,timestamp:new Date().toISOString(),role:`maestro-out`};return n.setQueryData(i,e=>e&&{...e,chat:{...e.chat,messages:[...e.chat.messages,s],total:e.chat.total+1}}),{optimisticId:a,previousSnapshot:o}},onSuccess:(t,n,r)=>{W(`mutation.cue.succeeded`,{ensemble:e,target:n.to,optimisticId:r?.optimisticId})},onError:(t,r,a)=>{W(`mutation.cue.failed`,{ensemble:e,target:r.to,error:t instanceof Error?t.message:String(t)},`warn`),a?.previousSnapshot?n.setQueryData(i,a.previousSnapshot):a&&n.setQueryData(i,e=>e&&{...e,chat:{...e.chat,messages:e.chat.messages.filter(e=>e.id!==a.optimisticId),total:Math.max(0,e.chat.total-1)}})}})}function yc(e,t={}){let n=t.client??Yo();return ct({mutationFn:()=>n.pause(e),onMutate:()=>{W(`mutation.pause.started`,{ensemble:e})},onSuccess:()=>{W(`mutation.pause.succeeded`,{ensemble:e})},onError:t=>{W(`mutation.pause.failed`,{ensemble:e,error:wc(t)},`warn`)}})}function bc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.play(e,t??void 0),onMutate:t=>{W(`mutation.play.started`,{ensemble:e,release:t?.release===!0})},onSuccess:(t,n)=>{W(`mutation.play.succeeded`,{ensemble:e,release:n?.release===!0})},onError:t=>{W(`mutation.play.failed`,{ensemble:e,error:wc(t)},`warn`)}})}function xc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.release(e,t?.playerId),onMutate:t=>{W(`mutation.release.started`,{ensemble:e,playerId:t?.playerId})},onSuccess:(t,n)=>{W(`mutation.release.succeeded`,{ensemble:e,playerId:n?.playerId,released:t.released.length})},onError:(t,n)=>{W(`mutation.release.failed`,{ensemble:e,playerId:n?.playerId,error:wc(t)},`warn`)}})}function Sc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.recruit(e,t),onMutate:t=>{W(`mutation.recruit.started`,{ensemble:e,name:t.name,agent:t.agent})},onSuccess:(t,n)=>{W(`mutation.recruit.succeeded`,{ensemble:e,name:n.name,playerId:t.playerId,entryId:t.entryId})},onError:(t,n)=>{W(`mutation.recruit.failed`,{ensemble:e,name:n.name,error:wc(t)},`warn`)}})}function Cc(e={}){let t=Ke(),n=e.client??Yo();return ct({mutationFn:e=>n.createEnsemble(e),onMutate:e=>{W(`mutation.createEnsemble.started`,{name:e.name,lineup:e.lineup,startMode:e.startMode})},onSuccess:e=>{W(`mutation.createEnsemble.succeeded`,{ensemble:e.ensemble,conductorPlayerId:e.conductorPlayerId,recruitedPlayers:e.recruitedPlayers,playerErrors:e.playerErrors?.length??0}),t.invalidateQueries({queryKey:Zo})},onError:(e,t)=>{W(`mutation.createEnsemble.failed`,{name:t.name,error:wc(e)},`warn`)}})}function wc(e){return e instanceof Error?e.message:String(e)}function Tc(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.restart(e,t),onMutate:t=>{W(`mutation.restart.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.restart.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.restart.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Ec(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.destroy(e,t),onMutate:t=>{W(`mutation.destroy.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.destroy.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.destroy.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Dc(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.detach(e,t),onMutate:t=>{W(`mutation.detach.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.detach.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.detach.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Oc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.recall(e,t),onMutate:t=>{W(`mutation.recall.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,n)=>{W(`mutation.recall.succeeded`,{ensemble:e,playerId:n.playerId,messages:t.messages})},onError:(t,n)=>{W(`mutation.recall.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}var kc=[{name:`tempo-conductor`,description:`Orchestrates the ensemble — breaks down tasks, delegates, synthesizes.`,source:`shipped`},{name:`tempo-composer`,description:`Software architect — designs system structure, defines interfaces.`,source:`shipped`},{name:`tempo-critic`,description:`Code reviewer — evaluates changes for correctness and quality.`,source:`shipped`},{name:`tempo-improv`,description:`Researcher and explorer — investigates unknowns, runs spikes.`,source:`shipped`},{name:`tempo-liner`,description:`Documentation specialist — README, CHANGELOG, PR descriptions.`,source:`shipped`},{name:`tempo-roadie`,description:`DevOps engineer — CI/CD, deployments, infrastructure.`,source:`shipped`},{name:`tempo-soloist`,description:`Senior engineer — implements features, fixes bugs, writes tests.`,source:`shipped`},{name:`tempo-tuner`,description:`QA engineer — designs test strategies, finds bugs, validates edges.`,source:`shipped`}],Ac=[{name:`tempo-dev-team`,description:`Conductor + composer + soloist + tuner + critic — full dev cycle.`,players:5,source:`shipped`},{name:`tempo-big-band`,description:`Every shipped player type — the maximum ensemble.`,players:8,source:`shipped`},{name:`tempo-review-squad`,description:`Conductor + critic + tuner — focused on code review and QA.`,players:3,source:`shipped`},{name:`tempo-jam-session`,description:`Conductor + 2 soloists + critic — quick exploratory work.`,players:4,source:`shipped`},{name:`tempo-mock-jam`,description:`Dev-mode all-mock ensemble for adapter testing.`,players:4,source:`shipped`}],jc=`__blank__`,Mc={1:`lineup`,2:`customize`,3:`review`},Nc=[{value:`hold`,label:`hold`},{value:`release-immediately`,label:`release immediately`}],Pc=/^[a-z0-9][a-z0-9-]*$/,Fc=64;function Ic(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`create-ensemble`})},[]);let e=Oi(),t=cs(),n=fs(),r=Cc(),i=n.data??Ac,[a,o]=(0,_.useState)(1),[s,c]=(0,_.useState)(()=>({name:``,lineup:Ac[0]?.name??`__blank__`,host:``,startMode:`hold`,conductorInstructions:``}));(0,_.useEffect)(()=>{!s.host&&t.data&&t.data.length>0&&c(e=>({...e,host:t.data[0].hostname}))},[s.host,t.data]);let l=zc(s.name),u=l===null&&s.lineup.length>0,d=()=>e(`/`),f=()=>{if(a===3||a===1&&!u)return;let e=a+1;o(e),W(`create-ensemble-wizard.advance`,{from:a,to:e})},p=()=>{a!==1&&o(a-1)},m=()=>{if(!u)return;let t=s.lineup===`__blank__`?void 0:s.lineup,n=s.startMode===`hold`?`hold`:`release`;r.mutate({name:s.name,...t?{lineup:t}:{},...s.host?{host:s.host}:{},startMode:n,...s.conductorInstructions?{conductorInstructions:s.conductorInstructions}:{}},{onSuccess:t=>e(`/ensemble/${encodeURIComponent(t.ensemble)}`)})},h=(0,_.useMemo)(()=>[...i.map(Rc),{value:jc,name:`Blank ensemble (recruit manually)`,desc:`Start with no players — use Recruit later from the Workspace.`,accent:!0}],[i]);return(0,R.jsx)(uc,{label:`modal · create ensemble · esc to close`,onClose:d,testId:`create-ensemble-modal`,children:(0,R.jsxs)(dc,{testId:`screen-create-ensemble`,title:`Create ensemble`,step:a,totalSteps:3,stepLabel:Mc[a],footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`hint`,children:`3 steps: lineup → customize → review`}),(0,R.jsxs)(`div`,{className:`row`,style:{display:`flex`,gap:8},children:[(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`create-ensemble-cancel`,onClick:d,children:`Cancel`}),a>1&&(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`create-ensemble-back`,onClick:p,children:`Back`}),a<3?(0,R.jsxs)(G,{variant:`primary`,size:`md`,"data-testid":`create-ensemble-next`,onClick:f,disabled:a===1&&!u,"aria-disabled":a===1&&!u,children:[`Next: `,Mc[a+1]]}):(0,R.jsx)(G,{variant:`primary`,size:`md`,"data-testid":`create-ensemble-submit`,onClick:m,disabled:r.isPending||!u,"aria-disabled":r.isPending||!u,children:r.isPending?`Creating…`:`Create ensemble`})]})]}),children:[a===1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(mc,{id:`create-ensemble-input-name`,label:`Name`,error:s.name.length>0?l:null,children:(0,R.jsx)(`input`,{id:`create-ensemble-input-name`,"data-testid":`create-ensemble-input-name`,className:`input`,placeholder:`my-feature`,value:s.name,onChange:e=>c(t=>({...t,name:e.target.value}))})}),(0,R.jsx)(mc,{id:`create-ensemble-lineup`,label:`Starting lineup`,hint:n.isError?`showing local catalog (daemon unreachable)`:void 0,children:(0,R.jsx)(fc,{testId:`create-ensemble-lineup`,options:h,value:s.lineup,onChange:e=>c(t=>({...t,lineup:e})),style:{maxHeight:220,overflow:`auto`}})})]}),a===2&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`field-grid-2`,children:[(0,R.jsx)(mc,{id:`create-ensemble-host`,label:`Default host`,children:(0,R.jsx)(`select`,{id:`create-ensemble-host`,"data-testid":`create-ensemble-input-host`,className:`select`,value:s.host,onChange:e=>c(t=>({...t,host:e.target.value})),disabled:t.isLoading,children:t.data&&t.data.length>0?t.data.map(e=>(0,R.jsx)(`option`,{value:e.hostname,children:e.hostname},e.hostname)):(0,R.jsx)(`option`,{value:``,children:t.isLoading?`Loading…`:`No hosts`})})}),(0,R.jsx)(mc,{id:`create-ensemble-start-mode`,label:`Start mode`,children:(0,R.jsx)(pc,{testId:`create-ensemble-start-mode`,options:Nc,value:s.startMode,onChange:e=>c(t=>({...t,startMode:e}))})})]}),(0,R.jsx)(mc,{id:`create-ensemble-input-instructions`,label:`Conductor instructions`,hint:`optional override`,children:(0,R.jsx)(`textarea`,{id:`create-ensemble-input-instructions`,"data-testid":`create-ensemble-input-instructions`,className:`textarea`,rows:3,placeholder:`Coordinate the rebuild. Gate phases; don't advance until the current phase is complete.`,value:s.conductorInstructions,onChange:e=>c(t=>({...t,conductorInstructions:e.target.value}))})})]}),a===3&&(0,R.jsxs)(`div`,{"data-testid":`create-ensemble-review`,children:[(0,R.jsx)(hc,{testId:`create-ensemble-summary-name`,label:`Name`,value:s.name}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-lineup`,label:`Lineup`,value:s.lineup===`__blank__`?`blank ensemble`:s.lineup}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-host`,label:`Default host`,value:s.host||`—`}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-start-mode`,label:`Start mode`,value:s.startMode===`hold`?`hold`:`release immediately`}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-instructions`,label:`Instructions`,value:s.conductorInstructions||`—`}),r.isError&&r.error&&(0,R.jsx)(Lc,{name:s.name,err:r.error})]})]})})}function Lc({name:e,err:t}){let n=t instanceof Vo?t.status:null,r,i;return n===409?(r=`Ensemble "${e}" already exists`,i=`Pick a different name or open the existing one from Overview.`):n===400?(r=`Couldn't create ${e}`,i=`Validation failed: ${t.message}`):(r=`Failed to create ${e}`,i=t.message),(0,R.jsxs)(`div`,{"data-testid":`create-ensemble-error`,role:`alert`,style:{marginTop:12,padding:`8px 12px`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,fontSize:12.5,lineHeight:1.4},children:[(0,R.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500},children:r}),(0,R.jsx)(`div`,{style:{marginTop:3,color:`var(--dim)`},children:i})]})}function Rc(e){return{value:e.name,name:(0,R.jsxs)(R.Fragment,{children:[e.name,` `,(0,R.jsxs)(`span`,{className:`mono dim`,style:{fontWeight:400,fontSize:11},children:[`· `,e.players,` player`,e.players===1?``:`s`]})]}),...e.description!==void 0&&{desc:e.description},right:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:e.source.toUpperCase()})}}function zc(e){return e.length===0?`Required`:e.length>Fc?`Too long (≤${Fc} chars)`:Pc.test(e)?null:`Lowercase letters, digits, and dashes only; cannot start with a dash`}function Bc({testId:e,action:t,reason:n,children:r,className:i}){return(0,R.jsx)(`button`,{type:`button`,"data-testid":e,"data-disabled-reason":n,"aria-disabled":`true`,title:n,className:i,onClick:e=>{e.preventDefault(),W(`disabled-action.attempted`,{action:t,reason:n})},style:{background:`var(--bg-2)`,border:`1px solid var(--rule)`,borderRadius:6,padding:`6px 14px`,fontFamily:`var(--ff-display)`,fontSize:14,color:`var(--dim)`,cursor:`not-allowed`,opacity:.7},children:r})}var Vc={padding:`var(--density-pad)`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,color:`var(--accent)`},Hc={padding:`var(--density-pad)`,background:`var(--bg-1)`,border:`1px dashed var(--rule)`,borderRadius:8},Uc={fontFamily:`var(--ff-mono)`};function Wc(e){try{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return`??:??`}}function Gc(e,t=Date.now()){if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return`—`;let r=Math.max(0,t-n),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Kc(e){if(e===void 0||!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/1e3);if(t<60)return`<1m`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;if(r<24)return i?`${r}h ${i}m`:`${r}h`;let a=Math.floor(r/24),o=r%24;return o?`${a}d ${o}h`:`${a}d`}function qc(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/1e3);if(r<60)return`expires in ${r}s`;let i=Math.floor(r/60);return i<60?`expires in ${i}m`:`expires in ${Math.floor(i/60)}h`}function Jc(e){if(!e)return`—`;let t=e.trim();return t.length===0?`—`:t.length<=8?t:`${t.slice(0,4)}·${t.slice(-4)}`}function Yc(e,t=Date.now()){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Kc(t-n);return r===`—`?null:r}function Xc(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`hosts`})},[]);let e=cs(),t=Ke(),[n,r]=(0,_.useState)(!1),i=(0,_.useCallback)(()=>{W(`hosts.rescan`,{}),t.invalidateQueries({queryKey:Qo})},[t]),a=(0,_.useCallback)(()=>{r(e=>{let t=!e;return W(`hosts.show-stale`,{value:t}),t})},[]);if(oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Hosts`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Daemons polling this Temporal namespace. Recruits with`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`host=`}),` route to these task queues.`]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`⟳`,"data-testid":`hosts-rescan`,onClick:i,children:`Re-scan`}),(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`hosts-show-stale`,"data-state":n?`on`:`off`,onClick:a,"aria-pressed":n,children:n?`Hide stale`:`Show stale`})]})}),[i,a,n])),e.isLoading)return(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`hosts`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading hosts…`})});if(e.isError)return(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-hosts`,style:Vc,children:e.error?.message??`Failed to load hosts`})});let o=e.data??[],s=n?o:o.filter(e=>e.freshness===`live`);return s.length===0?(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{"data-testid":`hosts-empty`,className:`dim`,style:Hc,children:o.length===0?(0,R.jsxs)(R.Fragment,{children:[`No daemons reporting. Run`,` `,(0,R.jsx)(`code`,{style:Uc,children:`agent-tempo daemon start`}),` on a host.`]}):(0,R.jsxs)(R.Fragment,{children:[`No live daemons. `,o.length,` stale host`,o.length===1?``:`s`,` `,`hidden — toggle `,(0,R.jsx)(`span`,{className:`mono`,children:`Show stale`}),` to view.`]})})}):(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`hosts-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Host`}),(0,R.jsx)(`th`,{children:`Platform`}),(0,R.jsx)(`th`,{className:`num`,children:`Sessions`}),(0,R.jsx)(`th`,{className:`num`,children:`Player types`}),(0,R.jsx)(`th`,{children:`Daemon`}),(0,R.jsx)(`th`,{children:`Uptime`}),(0,R.jsx)(`th`,{children:`Heartbeat`}),(0,R.jsx)(`th`,{})]})}),(0,R.jsx)(`tbody`,{children:s.map(e=>(0,R.jsx)(Zc,{host:e},e.hostname))})]})})})}function Zc({host:e}){let t=e.hostname,n=e.instances.length>0?e.instances.reduce((e,t)=>e.lastAccessTime>t.lastAccessTime?e:t):null,r=n?.version??e.profile?.version??`—`,i=e.profile?.platform??`—`,a=e.profile?.availablePlayerTypes?.length??0,o=Gc(n?.lastAccessTime),s=e.freshness===`live`,c=s&&e.profile?.daemonStartedAt!==void 0?Kc(Date.now()-e.profile.daemonStartedAt):`—`;return(0,R.jsxs)(`tr`,{"data-testid":`host-row-${t}`,"data-freshness":e.freshness,children:[(0,R.jsxs)(`td`,{className:`mono`,title:t,children:[(0,R.jsx)(`span`,{style:{color:s?`var(--ok)`:`var(--warn)`},children:`●`}),` `,t]}),(0,R.jsx)(`td`,{"data-label":`Platform`,"data-testid":`host-row-${t}-platform`,className:`mono`,style:{color:`var(--text-2)`},children:i}),(0,R.jsx)(`td`,{"data-label":`Sessions`,"data-testid":`host-row-${t}-sessions`,className:`num`,children:`—`}),(0,R.jsx)(`td`,{"data-label":`Types`,"data-testid":`host-row-${t}-types`,className:`num`,children:a}),(0,R.jsx)(`td`,{"data-label":`Daemon`,"data-testid":`host-row-${t}-daemon`,className:`mono`,children:r}),(0,R.jsx)(`td`,{"data-label":`Uptime`,"data-testid":`host-row-${t}-uptime`,className:`mono dim`,children:c}),(0,R.jsx)(`td`,{"data-label":`Heartbeat`,"data-testid":`host-row-${t}-heartbeat`,className:`mono`,style:{color:s?`var(--text-2)`:`var(--warn)`},children:o}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Bc,{testId:`host-row-${t}-logs`,action:`hosts.logs`,reason:`Streaming daemon logs into the dashboard requires a daemon endpoint that hasn't shipped yet.`,children:`Logs`})}),(0,R.jsx)(`td`,{hidden:!0,"data-testid":`host-row-${t}-version`,children:r}),(0,R.jsx)(`td`,{hidden:!0,"data-testid":`host-row-${t}-freshness`,children:e.freshness})]})}function Qc({children:e}){return(0,R.jsx)(`section`,{"data-testid":`screen-hosts`,style:{display:`flex`,flexDirection:`column`},children:e})}var $c=[{name:`tempo-big-band`,description:`Full-lifecycle development ensemble — design, implement, test, review, and ship.`,players:9,source:`shipped`},{name:`tempo-dev-team`,description:`Development team — conductor, composer, two soloists, and a tuner for feature work.`,players:5,source:`shipped`},{name:`tempo-jam-session`,description:`Exploratory ensemble for spikes, research, and problems where the path forward is unclear.`,players:4,source:`shipped`},{name:`tempo-mock-jam`,description:`All-mock ensemble for autonomous validation harnesses (dev mode only).`,players:4,source:`shipped`},{name:`tempo-review-squad`,description:`Three critics with different focus areas for thorough parallel code review.`,players:3,source:`shipped`}],el=[`Name`,`Summary`,`Players`,`Source`,`Last used`],tl=`Editing lineup files requires a daemon endpoint that hasn’t shipped yet.`;function nl(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`loadouts`})},[]);let e=fs().data??$c;return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Loadouts`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Reusable ensemble lineups. Loaded via`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`agent-tempo up --lineup`}),` or from here.`]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Bc,{testId:`loadouts-action-import`,action:`loadouts.import-yaml`,reason:tl,children:`↑ Import YAML`}),(0,R.jsx)(Bc,{testId:`loadouts-action-new`,action:`loadouts.new`,reason:tl,children:`+ New loadout`})]})}),[])),(0,R.jsx)(`section`,{"data-testid":`screen-loadouts`,children:(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`loadouts-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[el.map(e=>(0,R.jsx)(`th`,{className:e===`Players`?`num`:void 0,children:e},e)),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.length===0?(0,R.jsx)(`tr`,{"data-testid":`loadouts-empty`,children:(0,R.jsx)(`td`,{colSpan:el.length+1,className:`dim`,style:{textAlign:`center`,padding:18},children:`No loadouts available yet.`})}):e.map(e=>(0,R.jsx)(rl,{l:e},e.name))})]})})})}function rl({l:e}){return(0,R.jsxs)(`tr`,{"data-testid":`loadouts-row-${e.name}`,children:[(0,R.jsxs)(`td`,{className:`mono`,children:[(0,R.jsx)(`span`,{className:`accent`,children:`≡`}),` `,e.name]}),(0,R.jsx)(`td`,{"data-label":`Summary`,style:{color:`var(--text-2)`,fontSize:12.5,maxWidth:320},children:e.description??`—`}),(0,R.jsx)(`td`,{"data-label":`Players`,className:`num`,children:e.players}),(0,R.jsx)(`td`,{"data-label":`Source`,children:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11},children:e.source})}),(0,R.jsx)(`td`,{"data-label":`Last used`,className:`mono dim`,style:{fontSize:11.5},children:`—`}),(0,R.jsxs)(`td`,{style:{textAlign:`right`},children:[(0,R.jsx)(Bc,{testId:`loadouts-row-${e.name}-edit`,action:`loadouts.edit`,reason:tl,children:`Edit`}),(0,R.jsx)(Bc,{testId:`loadouts-row-${e.name}-load`,action:`loadouts.load`,reason:tl,children:`▶ Load`})]})]})}var il={live:`●`,stale:`◐`,missing:`✗`},al={live:`var(--ok)`,stale:`var(--warn)`,missing:`var(--err, var(--warn))`},ol={border:`1px solid var(--warn-border, var(--warn))`,borderRadius:`var(--radius, 6px)`,background:`var(--warn-bg, transparent)`};function sl(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`orphans`})},[]);let e=ls(),t=Ke(),n=(0,_.useCallback)(()=>{W(`orphans.rescan`,{}),t.invalidateQueries({queryKey:$o})},[t]);if(oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Orphans`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Cross-host orphan sessions — adapters that left the cluster without an orderly destroy. Paste the `,(0,R.jsx)(`span`,{className:`mono`,children:`/migrate`}),` `,`command into a local session to recover.`]}),actions:(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`⟳`,"data-testid":`orphans-rescan`,onClick:n,children:`Re-scan`})}),[n])),e.isLoading)return(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`orphans`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading orphans…`})});if(e.isError)return(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`orphans-error`,style:Vc,children:e.error?.message??`Failed to load orphans`})});let r=e.data?.orphans??[];return r.length===0?(0,R.jsx)(ll,{children:(0,R.jsxs)(`div`,{"data-testid":`orphans-empty`,className:`dim`,style:Hc,children:[`No cross-host orphans. The cluster is tidy.`,` `,(0,R.jsx)(`a`,{href:`/docs/ops/cross-host-orphans.md`,className:`mono dim`,children:`(what's an orphan?)`})]})}):(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{className:`panel`,style:ol,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`orphans-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Player`}),(0,R.jsx)(`th`,{children:`Ensemble`}),(0,R.jsx)(`th`,{children:`Host`}),(0,R.jsx)(`th`,{children:`Status`}),(0,R.jsx)(`th`,{children:`Action`})]})}),(0,R.jsx)(`tbody`,{children:r.map(e=>(0,R.jsx)(cl,{orphan:e},e.workflowId))})]})})})}function cl({orphan:e}){let t=e.workflowId,n=(0,_.useCallback)(()=>{typeof navigator<`u`&&navigator.clipboard&&navigator.clipboard.writeText(e.migrateCommand),W(`orphans.copy-migrate`,{workflowId:e.workflowId,ensemble:e.ensemble})},[e.migrateCommand,e.workflowId,e.ensemble]),r=e.workflowId.length>28?`…`+e.workflowId.slice(-26):e.workflowId;return(0,R.jsxs)(`tr`,{"data-testid":`orphan-row-${t}`,"data-liveness":e.hostLiveness,children:[(0,R.jsxs)(`td`,{"data-label":`Player`,"data-testid":`orphan-row-${t}-player`,className:`mono`,children:[(0,R.jsx)(`div`,{children:e.playerId}),(0,R.jsx)(`div`,{className:`mono dim`,style:{fontSize:`0.85em`},title:e.workflowId,children:r})]}),(0,R.jsx)(`td`,{"data-label":`Ensemble`,"data-testid":`orphan-row-${t}-ensemble`,className:`mono`,children:e.ensemble}),(0,R.jsx)(`td`,{"data-label":`Host`,"data-testid":`orphan-row-${t}-host`,className:`mono`,children:e.preferredHost??(0,R.jsx)(`span`,{className:`dim`,children:`(unknown)`})}),(0,R.jsxs)(`td`,{"data-label":`Status`,"data-testid":`orphan-row-${t}-liveness`,className:`mono`,children:[(0,R.jsx)(`span`,{style:{color:al[e.hostLiveness]},"aria-label":`host ${e.hostLiveness}`,children:il[e.hostLiveness]}),` `,e.hostLiveness,` `,e.detachedSince&&(0,R.jsxs)(`span`,{className:`dim`,style:{fontSize:`0.85em`},children:[`(`,Gc(e.detachedSince),`)`]})]}),(0,R.jsx)(`td`,{"data-label":`Action`,children:(0,R.jsxs)(G,{variant:`ghost`,size:`sm`,"data-testid":`orphan-row-${t}-migrate-copy`,title:e.migrateCommand,onClick:n,children:[`📋 Copy `,(0,R.jsx)(`span`,{style:Uc,children:`/migrate`})]})})]})}function ll({children:e}){return(0,R.jsx)(`section`,{"data-testid":`screen-orphans`,style:{display:`flex`,flexDirection:`column`},children:e})}function ul(e,t){if(t.type===`snapshot`)return t.payload;if(!e)return e;switch(t.type){case`heartbeat`:case`throttled`:return e;case`gap`:return e;case`ensemble.created`:return e;case`ensemble.destroyed`:return{...e,state:`offline`,hasConductor:!1,players:[],chat:{messages:[],total:0,hasMore:!1}};case`player.added`:{let n=t.payload,r=e.players.filter(e=>e.playerId!==n.playerId);return{...e,players:[...r,n],hasConductor:e.hasConductor||n.isConductor}}case`player.removed`:{let{playerId:n}=t.payload,r=e.players.find(e=>e.playerId===n),i=e.players.filter(e=>e.playerId!==n),a=i.some(e=>e.isConductor);return{...e,players:i,hasConductor:a,...r?.isConductor?{state:e.state}:{}}}case`player.phase_changed`:{let{playerId:n,phase:r,lastHeartbeatAt:i,processingSince:a}=t.payload,o=e.players.map(e=>e.playerId===n?{...e,phase:r,...i===void 0?{}:{lastHeartbeatAt:i},...a===void 0?{}:{processingSince:a}}:e);return{...e,players:o}}case`chat.appended`:{let n=t.payload,r=e.chat.messages,i=r;if(n.role===`maestro-out`){let e=r.findIndex(e=>e.id.startsWith(`optimistic-`)&&e.from===n.from&&e.to===n.to&&e.text===n.text);e!==-1&&(i=[...r.slice(0,e),...r.slice(e+1)])}let a=[...i,n],o=a.length>200?a.slice(a.length-200):a,s=+(i===r);return{...e,chat:{messages:o,total:e.chat.total+s,hasMore:e.chat.hasMore||o.length<a.length}}}case`chat.compressed`:{let{dropped:n}=t.payload;return{...e,chat:{messages:[],total:Math.max(0,e.chat.total-n),hasMore:!0}}}case`flags.changed`:{let{paused:n,held:r}=t.payload;return{...e,flags:{paused:n,held:r},state:n?`paused`:e.state===`paused`?`online`:e.state}}case`schedules.changed`:return{...e,schedules:t.payload.schedules};case`host_profile.changed`:{let n=t.payload;return{...e,hostProfiles:{...e.hostProfiles,[n.hostname]:n}}}case`player.activity`:return e}return t}function dl(e,t={}){let n=Ke();(0,_.useEffect)(()=>{if(!e||t.enabled===!1)return;let r=t.client??Yo(),i=new AbortController,a=is(e),o=!1;return W(`sse.connected`,{ensemble:e}),(async()=>{try{for await(let t of r.subscribe(e,{signal:i.signal})){if(o)break;if(t.type===`gap`){W(`sse.gap`,{ensemble:e,lastEventId:t.eventId}),n.invalidateQueries({queryKey:a});continue}if(n.setQueryData(a,e=>ul(e,t)),t.type===`snapshot`){let n=t.payload;W(`snapshot.applied`,{ensemble:e,playerCount:n.players.length,hasConductor:n.hasConductor})}}W(`sse.disconnected`,{ensemble:e,reason:`stream-end`})}catch(t){o||W(`sse.disconnected`,{ensemble:e,reason:t instanceof Error?t.message:String(t)},`warn`)}})(),()=>{o=!0,i.abort(`unmount`)}},[e,t.client,t.enabled,n])}function fl(e,t){return e.isConductor&&!t.isConductor?-1:!e.isConductor&&t.isConductor?1:e.playerId.localeCompare(t.playerId)}function pl(e){return[...e].sort(fl)}function ml({playerId:e,playerType:t,isConductor:n=!1,size:r=32}){let i=n||t===`tempo-conductor`||e===`conductor`,a=i?75:ec(t),o=i?`oklch(0.26 0.06 ${a})`:`oklch(0.24 0.045 ${a})`,s=i?`oklch(0.86 0.14 ${a})`:`oklch(0.82 0.13 ${a})`,c=i?`oklch(0.55 0.13 ${a})`:`oklch(0.35 0.05 ${a})`,l=i?`𝄞`:Qs(e);return(0,R.jsx)(`span`,{"data-testid":`player-avatar-${e}`,"data-conductor":i||void 0,"aria-label":e,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,background:o,color:s,fontSize:r*(i?.72:.55),border:`1px solid ${c}`,borderRadius:6,lineHeight:1,flexShrink:0},children:l})}function hl({ensemble:e}){let t=ps(e.name);dl(e.name);let n=t.data,r=(0,_.useMemo)(()=>pl(n?.players??[]),[n?.players]),i=r.length||e.playerCount,a=n?.state??e.state??`online`,o=n?.flags,s=i===0,c=r.filter(e=>e.phase===`attached`||e.phase===`processing`).length,l=Yc(n?.startedAt)??`—`,u=n?.currentBpm,d=n?.description?.trim()??``;return(0,R.jsx)(`article`,{"data-testid":`ensemble-card-${e.name}`,"data-state":a,className:`ensemble-card`+(s?` is-empty`:``),children:(0,R.jsxs)(ao,{to:`/ensemble/${encodeURIComponent(e.name)}`,"data-testid":`ensemble-card-${e.name}-link`,onClick:()=>W(`ensemble-card.click`,{ensemble:e.name}),style:{color:`inherit`,textDecoration:`none`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,R.jsxs)(`div`,{className:`ec-head`,children:[(0,R.jsxs)(`div`,{className:`ec-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e.name]}),(0,R.jsxs)(`div`,{className:`ec-tempo`,children:[(0,R.jsx)(`span`,{className:`bpm`,"data-testid":`ensemble-card-${e.name}-bpm`,children:u===void 0?`—`:u}),(0,R.jsx)(`span`,{children:`bpm`})]})]}),t.isLoading&&!t.data?(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`ensemble-snapshot-${e.name}`,className:`dim ec-desc`,children:`Loading…`}):t.isError?(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-ensemble-snapshot-${e.name}`,className:`ec-desc`,style:{color:`var(--accent)`},children:t.error?.message??`Snapshot unavailable`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`ec-desc`,"data-testid":`ensemble-card-${e.name}-desc`,children:d||null}),(0,R.jsxs)(`div`,{className:`ec-stats`,"data-testid":`ensemble-card-${e.name}-stats`,children:[(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,"data-testid":`ensemble-card-${e.name}-player-count`,children:i}),(0,R.jsx)(`div`,{className:`l`,children:i===1?`player`:`players`})]}),(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,style:{color:c>0?`var(--ok)`:`var(--dim)`},children:c}),(0,R.jsx)(`div`,{className:`l`,children:`active`})]}),(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,"data-testid":`ensemble-card-${e.name}-uptime`,style:{fontFamily:`var(--ff-mono)`,fontSize:12},children:l}),(0,R.jsx)(`div`,{className:`l`,children:`uptime`})]})]}),(0,R.jsxs)(`div`,{className:`ec-meta mono dim`,children:[(0,R.jsx)(`span`,{"data-testid":`ensemble-card-${e.name}-lineup`,children:`—`}),(0,R.jsx)(`span`,{"data-testid":`ensemble-card-${e.name}-host`,children:`—`})]}),(a===`paused`||o?.held)&&(0,R.jsxs)(`div`,{className:`ec-flags`,children:[a===`paused`&&(0,R.jsx)(gl,{testId:`ensemble-card-${e.name}-flag-paused`,label:`paused`}),o?.held&&(0,R.jsx)(gl,{testId:`ensemble-card-${e.name}-flag-held`,label:`held`})]}),i>0&&(0,R.jsxs)(`div`,{className:`ec-roster`,children:[r.slice(0,5).map(e=>(0,R.jsx)(ml,{playerId:e.playerId,playerType:e.playerType,isConductor:e.isConductor,size:22},e.playerId)),i>5&&(0,R.jsxs)(`span`,{className:`mono dim`,style:{alignSelf:`center`,marginLeft:4,fontSize:11},children:[`+`,i-5]})]})]})]})})}function gl({testId:e,label:t}){return(0,R.jsx)(`span`,{"data-testid":e,className:`ec-flag`,children:t})}function _l({kicker:e,title:t,right:n,tight:r=!1}){return(0,R.jsxs)(`div`,{className:`section-head${r?` is-tight`:``}`,children:[(0,R.jsxs)(`div`,{children:[e&&(0,R.jsx)(`div`,{className:`section-kicker mono`,children:e}),(0,R.jsx)(`div`,{className:`section-title`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`section-head-right`,children:n})]})}function vl(e,t,n=`${t}s`){return e===1?t:n}function yl({testId:e,count:t,label:n,pluralLabel:r,showDot:i}){return(0,R.jsxs)(`span`,{className:`page-pill`,"data-testid":e,children:[i&&(0,R.jsx)(`span`,{className:`pill-dot`}),(0,R.jsx)(`span`,{className:`pill-num`,children:t}),vl(t,n,r)]})}function bl(){let e=ss(),t=cs(),n=Oi(),r=Ke(),i=e.data,a=(0,_.useMemo)(()=>{let e=i??[];return{ensembles:e.length,players:e.reduce((e,t)=>e+(t.playerCount??0),0),hosts:t.data?.length??0,hasRunning:e.some(e=>e.playerCount>0)}},[i,t.data]),o=(0,_.useCallback)(()=>{W(`overview.refresh`,{}),r.invalidateQueries({queryKey:Zo}),r.invalidateQueries({queryKey:Qo})},[r]),s=(0,_.useCallback)(()=>{W(`overview.new-ensemble.click`,{}),n(`/create-ensemble`)},[n]);return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Overview`,pills:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yl,{testId:`overview-stat-ensembles`,count:a.ensembles,label:`ensemble`,showDot:a.hasRunning}),(0,R.jsx)(yl,{testId:`overview-stat-players`,count:a.players,label:`player`}),(0,R.jsx)(yl,{testId:`overview-stat-hosts`,count:a.hosts,label:`host`})]}),subtitle:`All ensembles, rolled up. Tap one to dive in.`,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`↻`,"data-testid":`overview-refresh`,onClick:o,"aria-label":`Refresh`,children:`Refresh`}),(0,R.jsx)(G,{variant:`primary`,size:`sm`,icon:`+`,"data-testid":`overview-new-ensemble`,onClick:s,"aria-label":`New ensemble`,children:`New ensemble`})]})}),[a,o,s])),e.isLoading?(0,R.jsx)(`section`,{"data-testid":`screen-overview`,children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`ensemble-list`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading ensembles…`})}):e.isError?(0,R.jsx)(`section`,{"data-testid":`screen-overview`,children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-ensemble-list`,style:Vc,children:e.error?.message??`Failed to load ensembles`})}):(0,R.jsxs)(`section`,{"data-testid":`screen-overview`,children:[(0,R.jsx)(_l,{kicker:`I / RUNNING`,title:`Active ensembles`}),a.ensembles===0?(0,R.jsxs)(`div`,{"data-testid":`overview-empty`,className:`dim`,style:Hc,children:[`No ensembles are running. Open a terminal and run`,` `,(0,R.jsx)(`code`,{style:Uc,children:`agent-tempo up <name>`}),` to start one.`]}):(0,R.jsx)(`div`,{className:`ensemble-grid`,children:(i??[]).map(e=>(0,R.jsx)(hl,{ensemble:e},e.name))}),(0,R.jsx)(xl,{})]})}function xl(){return(0,R.jsxs)(`div`,{style:{marginTop:`calc(var(--density-gap) * 1.5)`},"data-testid":`overview-recent-activity`,children:[(0,R.jsx)(_l,{kicker:`II / RECENT`,title:`Recent activity`,right:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11},children:`across all ensembles`})}),(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsx)(`div`,{className:`panel-body flush event-log`,children:(0,R.jsx)(`div`,{className:`event-row`,"data-testid":`overview-recent-activity-empty`,style:{display:`flex`,justifyContent:`center`,color:`var(--dim)`},children:(0,R.jsx)(`span`,{children:`No recent activity. Cross-ensemble event stream coming soon.`})})})})]})}function Sl(e){let t=[],n=``,r=!1,i=!1,a=!1,o=()=>{(n.length>0||a)&&(t.push(n),n=``,a=!1)};for(let t=0;t<e.length;t++){let s=e[t];if(s===`"`&&!r){i=!i,a=!0;continue}if(s===`'`&&!i){r=!r,a=!0;continue}if(/\s/.test(s)&&!r&&!i){o();continue}n+=s,a=!0}return o(),{tokens:t,unterminatedQuote:r||i}}function Cl(e){let t=e.trim();if(!t.startsWith(`/`))return null;let{tokens:n,unterminatedQuote:r}=Sl(t.slice(1));if(n.length===0)return null;let i=n[0].toLowerCase(),a=n.slice(1);return r?{name:i,args:a,raw:t,unterminatedQuote:!0}:{name:i,args:a,raw:t}}var wl=new Set([`worktree`,`restart`,`destroy`,`attachment-info`]);function Tl(e){let t=e.trimStart();if(!t)return null;if(t.startsWith(`/`)&&!t.includes(` `))return{mode:`command`,partial:t.slice(1).toLowerCase(),replacePrefix:`/`};if(t.startsWith(`@`)&&!t.includes(` `))return{mode:`player`,partial:t.slice(1).toLowerCase(),replacePrefix:`@`};if(t.startsWith(`/`)&&t.includes(` `)){let e=t.indexOf(` `),n=t.slice(1,e).toLowerCase(),r=t.slice(e+1);if(r.includes(` `))return null;if(wl.has(n))return{mode:`player-arg`,partial:r.toLowerCase(),replacePrefix:`/${n} `}}return null}function El(e){return e===`player`?`@`:`/`}function Dl(e,t){let n=t.startsWith(`/`)?t.slice(1):t;if(!n)return[...e];let r=n.toLowerCase();return e.filter(e=>e.name.toLowerCase().startsWith(r))}function Ol(e,t){let n=t.toLowerCase();return n?e.filter(e=>{let t=e.toLowerCase();return t===n?!1:t.startsWith(n)||t.split(`-`).some(e=>e.startsWith(n))}):[...e]}var kl=/^@([a-zA-Z0-9_-]+)(?:\s+([\s\S]*))?$/;function Al(e){let t=e.trim();if(t.startsWith(`/`)){let e=Cl(t);return e?{kind:`slash`,name:e.name,args:e.args,raw:e.raw}:{kind:`plain`,text:t}}if(t.startsWith(`@`)){let e=kl.exec(t);return e?{kind:`cue`,target:e[1],text:(e[2]??``).trim()}:{kind:`plain`,text:t}}return{kind:`plain`,text:t}}var jl=[{name:`help`,description:`Show available slash commands`,usage:`/help`},{name:`clear`,description:`Clear the local chat scrollback (does not affect server history)`,usage:`/clear`},{name:`pause`,description:`Pause every session + scheduler + maestro in this ensemble`,usage:`/pause`},{name:`play`,description:`Resume a paused ensemble`,usage:`/play`},{name:`release`,description:`Release all held players (or a single player when given)`,usage:`/release [player]`},{name:`recall`,description:`Read a player's message history`,usage:`/recall <player>`}];jl.map(e=>e.name);function Ml(e){let t=Ke(),n=yc(e),r=bc(e),i=xc(e),a=Oc(e);return(0,_.useCallback)(o=>{let s=o.name;switch(W(`slash.dispatched`,{ensemble:e,verb:s,args:o.args.length}),s){case`help`:return{handled:!0,verb:s,status:{level:`info`,message:`Slash commands`,description:jl.map(e=>` ${e.usage.padEnd(28)} ${e.description}`).join(`
|
|
16
|
+
`));return{v:1,type:t,eventId:e.eventId,payload:e.payload}}catch{return null}}var Jo=null;function Yo(){return Jo||=Bo(),Jo}var Xo=[`health`],Zo=[`ensembles`],Qo=[`hosts`],$o=[`orphans`];function es(e){return e?[...$o,e]:[...$o,`__all__`]}var ts=[`agent-types`],ns=[`lineups`],rs=[`ensemble`];function is(e){return[...rs,e]}function as(e,t,n,r={}){let{enabled:i,refetchOnWindowFocus:a=!0,...o}=r;return st({queryKey:e,queryFn:async()=>{try{return await t()}catch(e){throw W(`snapshot.error`,{resource:n,...o,error:e instanceof Error?e.message:String(e)},`warn`),e}},staleTime:5e3,refetchInterval:3e4,refetchOnWindowFocus:a,...i!==void 0&&{enabled:i}})}function os(e={}){let t=e.client??Yo();return as(Xo,()=>t.health(),`health`)}function ss(e={}){let t=e.client??Yo();return as(Zo,()=>t.listEnsembles(),`ensembles`)}function cs(e={}){let t=e.client??Yo();return as(Qo,()=>t.hosts(),`hosts`)}function ls(e,t={}){let n=t.client??Yo();return st({queryKey:es(e),queryFn:async()=>{try{return await n.orphans(e?{ensemble:e}:void 0)}catch(t){throw W(`snapshot.error`,{resource:`orphans`,...e?{ensemble:e}:{},error:t instanceof Error?t.message:String(t)},`warn`),t}},staleTime:1e4,refetchInterval:3e4,refetchOnWindowFocus:!0})}function us(e={}){let t=e.client??Yo();return st({queryKey:[...$o,`__count__`],queryFn:async()=>{try{return(await t.orphans()).orphans.length}catch(e){throw W(`snapshot.error`,{resource:`orphans-count`,error:e instanceof Error?e.message:String(e)},`warn`),e}},staleTime:3e4,refetchInterval:6e4,refetchOnWindowFocus:!0})}function ds(e={}){let t=e.client??Yo();return as(ts,()=>t.agentTypes(),`agent-types`)}function fs(e={}){let t=e.client??Yo();return as(ns,()=>t.lineups(),`lineups`)}function ps(e,t={}){let n=t.client??Yo();return st({queryKey:is(e??``),queryFn:async()=>{if(!e)throw Error(`ensemble required`);try{return await n.state(e)}catch(t){throw W(`snapshot.error`,{resource:`ensemble-snapshot`,ensemble:e,error:t instanceof Error?t.message:String(t)},`warn`),t}},enabled:!!e,staleTime:5e3,refetchOnWindowFocus:!1})}var ms=6e3,hs=Object.freeze({activeEnsemble:null,setActiveEnsemble:()=>{},unread:Object.freeze({}),markRead:()=>{},toasts:Object.freeze([]),dismissToast:()=>{},fire:()=>{}}),gs=(0,_.createContext)(null);function _s(){let{id:e}=Mi();return e??null}function vs(){return(0,_.useContext)(gs)??hs}function ys({children:e}){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)({}),[a,o]=(0,_.useState)([]),s=(0,_.useRef)(1),c=(0,_.useRef)(null),l=(0,_.useCallback)(e=>{c.current=e,n(e),e!=null&&(i(t=>{if(!t[e])return t;let n={...t};return delete n[e],n}),o(t=>t.filter(t=>t.ensembleId!==e)))},[]),u=_s();(0,_.useEffect)(()=>{l(u)},[u,l]);let d=(0,_.useCallback)(e=>{i(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]),f=(0,_.useCallback)(e=>{o(t=>t.filter(t=>t.id!==e))},[]),p=(0,_.useCallback)(e=>{let t=e.ensembleId,n=e.ensembleName??t,r=t===c.current;r||i(e=>({...e,[t]:(e[t]??0)+1}));let a=Date.now(),l=s.current++;o(i=>{let o=i[i.length-1];if(o&&o.ensembleId===t&&o.sender===e.sender&&a-o.firstAt<8e3){let t={...o,body:e.body,count:o.count+1,ts:a,expiresAt:a+ms};return[...i.slice(0,-1),t]}if(r)return i;let s={id:l,ensembleId:t,ensembleName:n,sender:e.sender,senderType:e.senderType,body:e.body,firstAt:a,ts:a,expiresAt:a+ms,count:1};return[...i,s]})},[]);(0,_.useEffect)(()=>{if(a.length===0)return;let e=Date.now(),t=a.map(t=>{let n=Math.max(0,t.expiresAt-e);return setTimeout(()=>{o(e=>e.filter(e=>e.id!==t.id))},n)});return()=>t.forEach(clearTimeout)},[a]);let m=(0,_.useMemo)(()=>({activeEnsemble:t,setActiveEnsemble:l,unread:r,markRead:d,toasts:a,dismissToast:f,fire:p}),[t,l,r,d,a,f,p]);return(0,R.jsx)(gs.Provider,{value:m,children:e})}function bs(e){let t=ss().data;(0,_.useEffect)(()=>{if(!t||t.length===0)return;let n=Yo(),r=!1,i=t.map(t=>{let i=new AbortController;return(async()=>{try{for await(let a of n.subscribe(t.name,{signal:i.signal,topics:[`chat`]})){if(r)break;if(a.type!==`chat.appended`)continue;let n=a.payload;n.role===`maestro-in`&&e({ensembleId:t.name,ensembleName:t.name,sender:n.from,body:n.text})}}catch{}})(),i});return()=>{r=!0,i.forEach(e=>e.abort(`unmount`))}},[t,e])}function xs(){let{fire:e}=vs();return bs(e),null}var Ss=[{id:`overview`,icon:`◇`,label:`Overview`,to:`/`},{id:`loadouts`,icon:`≡`,label:`Loadouts`,to:`/loadouts`},{id:`types`,icon:`♪`,label:`Player types`,to:`/player-types`},{id:`hosts`,icon:`⌂`,label:`Hosts`,to:`/hosts`},{id:`orphans`,icon:`⚠`,label:`Orphans`,to:`/orphans`},{id:`schedules`,icon:`⧗`,label:`Schedules`,to:`/schedules`},{id:`settings`,icon:`⚙`,label:`Settings`,to:`/settings`}];function Cs(){let e=ss().data??[],{id:t}=Mi(),n=t,r=Ti().pathname.startsWith(`/ensemble/`),i=e.filter(e=>e.playerCount>0).length,{unread:a,markRead:o}=vs(),s=us().data??0;return(0,R.jsxs)(`aside`,{className:`sidebar`,"data-testid":`sidebar`,"aria-label":`Main navigation`,children:[(0,R.jsx)(`div`,{className:`sidebar-brand`,children:(0,R.jsx)(Ao,{size:`md`,running:!1})}),(0,R.jsxs)(`div`,{className:`sidebar-section`,"data-testid":`sidebar-section-ensembles`,children:[(0,R.jsxs)(`div`,{className:`sidebar-kicker`,children:[(0,R.jsx)(`span`,{children:`Ensembles`}),(0,R.jsxs)(`span`,{className:`count`,children:[i,` running`]})]}),e.length===0?(0,R.jsx)(`div`,{className:`dim`,"data-testid":`sidebar-ensembles-empty`,style:{padding:`6px 12px`,fontFamily:`var(--ff-mono)`,fontSize:11},children:`No ensembles`}):e.map(e=>{let t=a[e.name]??0;return(0,R.jsxs)(ao,{to:`/ensemble/${encodeURIComponent(e.name)}`,"data-testid":`sidebar-ensemble-${e.name}`,className:[`ensemble-row`,n===e.name?`is-active`:``,e.playerCount>0?`has-active`:``,t>0?`has-unread`:``].filter(Boolean).join(` `),style:{textDecoration:`none`},onClick:()=>{t>0&&o(e.name)},children:[(0,R.jsx)(`span`,{className:`er-dot`}),(0,R.jsx)(`span`,{className:`er-initial`,"aria-hidden":`true`,children:e.name.charAt(0).toUpperCase()}),(0,R.jsxs)(`span`,{className:`col`,style:{gap:0},children:[(0,R.jsx)(`span`,{className:`er-name`,children:e.name}),(0,R.jsxs)(`span`,{className:`er-meta mono`,children:[e.playerCount,` `,e.playerCount===1?`player`:`players`]})]}),(0,R.jsx)(No,{count:t}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`↵`})]},e.name)}),(0,R.jsxs)(ao,{to:`/create-ensemble`,"data-testid":`sidebar-new-ensemble`,className:`ensemble-row ensemble-row--new`,style:{marginTop:4,color:`var(--accent)`,textDecoration:`none`},children:[(0,R.jsx)(`span`,{className:`icon-g`,style:{color:`var(--accent)`},children:`+`}),(0,R.jsx)(`span`,{className:`er-name`,children:`New ensemble…`}),(0,R.jsx)(`span`,{})]})]}),(0,R.jsxs)(`div`,{className:`sidebar-section`,"data-testid":`sidebar-section-library`,children:[(0,R.jsx)(`div`,{className:`sidebar-kicker`,children:(0,R.jsx)(`span`,{children:`Library`})}),Ss.map(e=>(0,R.jsxs)(oo,{to:e.to,end:e.to===`/`,"data-testid":`nav-${e.id}`,className:({isActive:t})=>`nav-row`+(t&&!(e.id===`overview`&&r)?` is-active`:``),style:{textDecoration:`none`},children:[(0,R.jsx)(`span`,{className:`nav-icon`,children:e.icon}),(0,R.jsx)(`span`,{children:e.label}),e.id===`orphans`&&s>0&&(0,R.jsx)(`span`,{"data-testid":`sidebar-orphans-badge`,className:`notif-badge`,"aria-label":`${s} orphan${s===1?``:`s`}`,children:s})]},e.id))]}),(0,R.jsxs)(`div`,{className:`sidebar-maestro`,title:`You — the maestro`,children:[(0,R.jsx)(Mo,{size:32}),(0,R.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,lineHeight:1.15,marginLeft:8,flex:1,minWidth:0},children:[(0,R.jsx)(`span`,{style:{fontFamily:`var(--ff-display)`,fontSize:14,color:`var(--text)`},children:`maestro`}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`operator`})]})]}),(0,R.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`conn-ok`,children:`●`}),` localhost:7233`]}),(0,R.jsx)(`span`,{"data-testid":`sidebar-version`,children:`v0.28`})]})]})}var ws=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Ts=(e=>e?ws(e):ws),Es=e=>e;function Ds(e,t=Es){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Os=e=>{let t=Ts(e),n=e=>Ds(t,e);return Object.assign(n,t),n},ks=(e=>e?Os(e):Os),As=`agent-tempo:prefs`,js=`dark`,Ms=`terracotta`;function Ns(){if(typeof window>`u`||!window.localStorage)return{theme:js,density:6,accent:Ms};try{let e=window.localStorage.getItem(As);if(e){let t=JSON.parse(e);return{theme:t.theme===`light`?`light`:`dark`,density:Ps(t.density)?t.density:6,accent:Fs(t.accent)?t.accent:Ms}}}catch{}return{theme:js,density:6,accent:Ms}}function Ps(e){return typeof e==`number`&&e>=4&&e<=9&&Number.isInteger(e)}function Fs(e){return e===`terracotta`||e===`sage`||e===`plum`}function Is(e){if(!(typeof window>`u`||!window.localStorage))try{window.localStorage.setItem(As,JSON.stringify(e))}catch{}}function Ls(e){typeof document>`u`||(document.documentElement.dataset.theme=e.theme,document.documentElement.dataset.density=String(e.density),document.documentElement.dataset.accent=e.accent)}var Rs=ks()((e,t)=>{let n=Ns();Ls(n);let r=n=>{e(n);let r={theme:t().theme,density:t().density,accent:t().accent};Ls(r),Is(r)};return{...n,setTheme:e=>{r({theme:e}),W(`prefs-theme-set`,{theme:e})},setDensity:e=>{r({density:e}),W(`prefs-density-set`,{density:e})},setAccent:e=>{r({accent:e}),W(`prefs-accent-set`,{accent:e})},toggleTheme:()=>{let e=t().theme===`dark`?`light`:`dark`;r({theme:e}),W(`prefs-theme-toggled`,{theme:e})}}}),zs=[4,5,6,7,8,9];function Bs({title:e=`Maestro`,prefix:t,accent:n,pills:r,actions:i,subtitle:a}){return(0,R.jsxs)(`header`,{className:`page-header`,"data-testid":`page-header`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`page-title-row`,children:[(0,R.jsxs)(`h1`,{className:`page-title`,children:[t&&(0,R.jsx)(`span`,{className:`prefix mono`,children:t}),e,n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),n.startsWith(`@`)?n.slice(1):n]})]}),r&&(0,R.jsx)(`div`,{className:`page-pills`,children:r})]}),a&&(0,R.jsx)(`div`,{className:`page-subtitle`,children:a})]}),(0,R.jsx)(`div`,{className:`page-actions`,children:i??(0,R.jsx)(Vs,{})})]})}function Vs(){let e=Rs(e=>e.theme),t=Rs(e=>e.density),n=Rs(e=>e.toggleTheme),r=Rs(e=>e.setDensity);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:6,color:`var(--dim)`,fontSize:`var(--density-fs-sm)`},children:[(0,R.jsx)(`span`,{children:`Density`}),(0,R.jsx)(`input`,{type:`range`,min:4,max:9,step:1,value:t,"data-testid":`settings-density-slider`,"aria-label":`Density`,onChange:e=>{let t=Number(e.target.value);zs.includes(t)&&r(t)}}),(0,R.jsx)(`span`,{className:`num mono`,style:{minWidth:14,textAlign:`right`},children:t})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"data-testid":`settings-theme-toggle`,onClick:n,"aria-label":`Switch to ${e===`dark`?`light`:`dark`} theme`,children:e===`dark`?`☀ Light`:`☾ Dark`})]})}function Hs(){return(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,children:(0,R.jsx)(`path`,{d:`M4 7h16M4 12h16M4 17h16`})})}function Us(){return(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`20`,height:`20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.5`}),(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,R.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.5`})]})}function Ws({activeEnsemble:e,lineup:t,onMenu:n,onAction:r,actionIcon:i,actionLabel:a=`More`,actionActive:o=!1,status:s}){return(0,R.jsxs)(`header`,{className:`phone-appbar`,"data-testid":`phone-appbar`,"aria-label":`Mobile top bar`,children:[(0,R.jsxs)(`div`,{className:`phone-appbar-row`,children:[(0,R.jsx)(`button`,{type:`button`,className:`phone-appbar-btn`,"aria-label":`Switch ensemble`,onClick:n,"data-testid":`phone-appbar-menu`,children:(0,R.jsx)(Hs,{})}),(0,R.jsxs)(`div`,{className:`phone-appbar-title`,children:[(0,R.jsx)(`span`,{className:`phone-appbar-kicker`,children:t?`lineup · ${t}`:`ensemble`}),e&&(0,R.jsxs)(`span`,{className:`phone-appbar-name`,"data-testid":`phone-appbar-ensemble-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e]})]}),(0,R.jsx)(`button`,{type:`button`,className:`phone-appbar-btn`+(o?` is-active`:``),"aria-label":a,"aria-pressed":o||void 0,onClick:r,"data-testid":`phone-appbar-action`,children:i??(0,R.jsx)(Us,{})})]}),s&&(0,R.jsxs)(`div`,{className:`phone-appbar-status mono`,"data-testid":`phone-appbar-status`,children:[s.active!=null&&(0,R.jsxs)(`span`,{className:`phone-stat ok`,children:[(0,R.jsx)(`span`,{className:`phone-stat-dot`}),` `,s.active,` active`]}),s.idle!=null&&(0,R.jsxs)(`span`,{className:`phone-stat dim`,children:[s.idle,` idle`]}),s.detached!=null&&s.detached>0&&(0,R.jsxs)(`span`,{className:`phone-stat warn`,children:[`◐ `,s.detached,` detached`]}),s.uptime&&(0,R.jsxs)(`span`,{className:`phone-stat dim`,children:[`up `,s.uptime]})]})]})}var Gs={workspace:(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,R.jsx)(`path`,{d:`M4 6h16M4 12h10M4 18h16`})}),overview:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`9`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`5`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`3`,y:`15`,width:`7`,height:`6`,rx:`1.5`}),(0,R.jsx)(`rect`,{x:`14`,y:`11`,width:`7`,height:`10`,rx:`1.5`})]}),library:(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,R.jsx)(`path`,{d:`M4 5v14M9 5v14M14 5l5 14M19 5l-5 14`})}),settings:(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`22`,height:`22`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,R.jsx)(`path`,{d:`M19.4 15a1.6 1.6 0 0 0 .3 1.7l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-1.7-.3 1.6 1.6 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.7.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0 .3-1.7 1.6 1.6 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.7l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.7.3H9a1.6 1.6 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.7-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.7V9a1.6 1.6 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z`})]})},Ks=[{k:`workspace`,label:`Now`,icon:Gs.workspace},{k:`overview`,label:`Ensembles`,icon:Gs.overview},{k:`library`,label:`Library`,icon:Gs.library},{k:`settings`,label:`Settings`,icon:Gs.settings}],qs=[`/loadouts`,`/player-types`,`/schedules`,`/hosts`];function Js(e,t){return t?`workspace`:e.startsWith(`/settings`)?`settings`:qs.some(t=>e.startsWith(t))?`library`:`overview`}function Ys(){let e=Oi(),t=Ti(),{id:n}=Mi(),r=Js(t.pathname,!!n),i=t=>{switch(t){case`workspace`:e(n?`/ensemble/${encodeURIComponent(n)}`:`/`);return;case`overview`:e(`/`);return;case`library`:e(`/loadouts`);return;case`settings`:e(`/settings`);return}};return(0,R.jsx)(`nav`,{className:`phone-tabbar`,"data-testid":`phone-tabbar`,role:`navigation`,"aria-label":`Mobile primary navigation`,children:Ks.map(e=>{let t=e.k===r;return(0,R.jsxs)(`button`,{type:`button`,className:`phone-tab`+(t?` is-active`:``),"data-testid":`phone-tab-${e.k}`,"aria-current":t?`page`:void 0,onClick:()=>i(e.k),children:[(0,R.jsx)(`span`,{className:`phone-tab-icon`,children:e.icon}),(0,R.jsx)(`span`,{className:`phone-tab-label`,children:e.label})]},e.k)})})}function Xs({open:e,onClose:t,activeEnsemble:n}){let r=Oi(),i=ss().data??[];if(!e)return null;let a=e=>{r(`/ensemble/${encodeURIComponent(e)}`),t()};return(0,R.jsx)(`div`,{className:`ens-switcher`,role:`dialog`,"aria-modal":`true`,"aria-label":`Switch ensemble`,"data-testid":`ensemble-switcher`,onClick:()=>t(),children:(0,R.jsxs)(`div`,{className:`ens-switcher-sheet`,onClick:e=>e.stopPropagation(),"data-testid":`ensemble-switcher-sheet`,children:[(0,R.jsx)(`div`,{className:`ens-switcher-grip`}),(0,R.jsxs)(`div`,{className:`ens-switcher-head`,children:[(0,R.jsx)(`div`,{className:`ens-switcher-title`,children:`Switch ensemble`}),(0,R.jsx)(`button`,{type:`button`,className:`ens-switcher-close`,"aria-label":`Close`,onClick:t,"data-testid":`ensemble-switcher-close`,children:`×`})]}),(0,R.jsx)(`div`,{className:`ens-switcher-list`,children:i.length===0?(0,R.jsx)(`div`,{className:`dim`,"data-testid":`ensemble-switcher-empty`,style:{padding:`20px 12px`,textAlign:`center`,fontFamily:`var(--ff-mono)`,fontSize:12},children:`No ensembles yet`}):i.map(e=>{let t=e.name===n;return(0,R.jsxs)(`button`,{type:`button`,className:`ens-switcher-row`+(t?` is-active`:``),onClick:()=>a(e.name),"data-testid":`ensemble-switcher-row-${e.name}`,children:[(0,R.jsx)(`span`,{className:`ens-switcher-dot`+(e.playerCount>0?` on`:``)}),(0,R.jsxs)(`span`,{className:`ens-switcher-meta`,children:[(0,R.jsxs)(`span`,{className:`ens-switcher-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e.name]}),(0,R.jsxs)(`span`,{className:`ens-switcher-sub`,children:[e.playerCount,` `,e.playerCount===1?`player`:`players`]})]}),t&&(0,R.jsx)(`span`,{className:`ens-switcher-check`,"aria-hidden":`true`,children:`✓`})]},e.name)})}),(0,R.jsxs)(`button`,{type:`button`,className:`ens-switcher-new`,onClick:()=>{r(`/create-ensemble`),t()},"data-testid":`ensemble-switcher-new`,children:[(0,R.jsx)(`span`,{className:`ens-switcher-plus`,children:`+`}),(0,R.jsx)(`span`,{children:`New ensemble…`})]})]})})}var Zs=[`♩`,`♪`,`♫`,`♬`,`♭`,`♮`,`♯`,`𝅘𝅥`];function Qs(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return Zs[t%Zs.length]}var $s={"tempo-conductor":32,"tempo-composer":210,"tempo-soloist":18,"tempo-tuner":150,"tempo-critic":340,"tempo-roadie":260,"tempo-improv":48,"tempo-liner":190};function ec(e){return e?$s[e]??200:200}var tc={attached:{icon:`●`,label:`active`,color:`var(--ok)`,bucket:`active`},processing:{icon:`●`,label:`processing`,color:`var(--ok)`,bucket:`active`,pulse:!0},awaiting:{icon:`○`,label:`idle`,color:`var(--text)`,bucket:`idle`},draining:{icon:`◐`,label:`draining`,color:`var(--warn)`,bucket:`disconnected`},detached:{icon:`◐`,label:`detached`,color:`var(--warn)`,bucket:`disconnected`},booting:{icon:`◔`,label:`booting`,color:`var(--dim)`,bucket:`pending`},gone:{icon:`✕`,label:`gone`,color:`var(--dim)`,bucket:`gone`}};function nc(e){return tc[e??`booting`]??tc.booting}function rc({toast:e,stackIndex:t,onOpen:n,onDismiss:r}){let{id:i,ensembleName:a,sender:o,senderType:s,body:c,count:l}=e,u=ec(s),d=(o||`?`).charAt(0).toUpperCase();return(0,R.jsxs)(`div`,{className:`toast`,"data-testid":`toast-${i}`,"data-stack-index":t,role:`alert`,onClick:e=>{e.target.closest(`.toast-close`)||n()},children:[(0,R.jsx)(`div`,{className:`toast-avatar`,style:{background:`oklch(0.62 0.13 ${u})`,color:`#0F1117`},"aria-hidden":`true`,children:d}),(0,R.jsxs)(`div`,{className:`toast-body`,children:[(0,R.jsxs)(`div`,{className:`toast-head`,children:[(0,R.jsxs)(`span`,{className:`toast-sender mono`,children:[`@`,o]}),(0,R.jsx)(`span`,{className:`toast-divider`,children:`·`}),(0,R.jsx)(`span`,{className:`toast-ensemble`,children:a}),l>1&&(0,R.jsx)(`span`,{className:`toast-count mono`,children:l}),(0,R.jsx)(`span`,{className:`toast-time mono`,children:`just now`})]}),(0,R.jsx)(`div`,{className:`toast-message`,children:c}),(0,R.jsxs)(`div`,{className:`toast-actions`,children:[(0,R.jsx)(`button`,{type:`button`,className:`toast-action`,"data-testid":`toast-reply`,onClick:e=>{e.stopPropagation(),n()},children:`Reply →`}),(0,R.jsx)(`button`,{type:`button`,className:`toast-action toast-action--ghost`,"data-testid":`toast-dismiss`,onClick:e=>{e.stopPropagation(),r()},children:`Dismiss`})]})]}),(0,R.jsx)(`button`,{type:`button`,className:`toast-close`,"data-testid":`toast-dismiss`,"aria-label":`Close`,onClick:e=>{e.stopPropagation(),r()},children:`×`})]})}function ic({onOpen:e}){let{toasts:t,dismissToast:n}=vs();if(!t.length)return null;let r=[...t].reverse(),i=r.slice(0,3),a=r.length-i.length;return(0,R.jsxs)(`div`,{className:`toast-stack`,"data-testid":`toast-stack`,role:`region`,"aria-label":`Notifications`,children:[a>0&&(0,R.jsxs)(`div`,{className:`toast-overflow mono`,"data-testid":`toast-overflow`,children:[`+`,a,` more`]}),i.map((t,r)=>(0,R.jsx)(rc,{toast:t,stackIndex:r,onDismiss:()=>n(t.id),onOpen:()=>{e(t.ensembleId),n(t.id)}},t.id))]})}var ac=(0,_.createContext)({setRender:()=>{}});function oc(e){let{setRender:t}=(0,_.useContext)(ac);(0,_.useEffect)(()=>(t(e),()=>t(null)),[e,t])}var sc=(0,_.createContext)({setOverride:()=>{}});function cc(e){let{setOverride:t}=(0,_.useContext)(sc);(0,_.useEffect)(()=>(t(e),()=>t(null)),[e,t])}function lc({children:e}){let t=Ti(),n=Oi(),r=t.pathname.startsWith(`/ensemble/`),{id:i}=Mi(),[a,o]=(0,_.useState)(!1),s=(0,_.useCallback)(e=>{n(`/ensemble/${encodeURIComponent(e)}`)},[n]),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(e=>{l(t=>e===null?t===null?t:null:t?.render===e?t:{render:e})},[]),d=(0,_.useMemo)(()=>({setRender:u}),[u]),[f,p]=(0,_.useState)(null),m=(0,_.useCallback)(e=>{p(t=>e===null?t===null?t:null:t===e?t:e)},[]),h=(0,_.useMemo)(()=>({setOverride:m}),[m]);return(0,R.jsx)(ac.Provider,{value:d,children:(0,R.jsx)(sc.Provider,{value:h,children:(0,R.jsx)(`div`,{className:`artboard-body`,children:(0,R.jsxs)(`div`,{className:`app-shell`+(r?` app-shell--workspace`:``),"data-testid":`app-shell`,children:[(0,R.jsx)(Cs,{}),(0,R.jsx)(Ws,{activeEnsemble:i,onMenu:()=>o(!0),lineup:f?.lineup,status:f?.status,onAction:f?.onAction,actionIcon:f?.actionIcon,actionLabel:f?.actionLabel,actionActive:f?.actionActive}),(0,R.jsx)(`main`,{className:`main`,"data-testid":`app-shell-main`,children:r?e:(0,R.jsxs)(R.Fragment,{children:[c?c.render():(0,R.jsx)(Bs,{title:`Maestro`}),(0,R.jsx)(`div`,{className:`page-pad scroll`,"data-testid":`app-shell-content`,style:{display:`flex`,flexDirection:`column`,gap:`var(--density-gap)`},children:e})]})}),(0,R.jsx)(Ys,{}),(0,R.jsx)(Xs,{open:a,onClose:()=>o(!1),activeEnsemble:i}),(0,R.jsx)(ic,{onOpen:s})]})})})})}function G({variant:e=`default`,size:t=`md`,icon:n,children:r,type:i=`button`,className:a,...o}){return(0,R.jsxs)(`button`,{type:i,className:[`btn`,e!==`default`&&`btn-${e}`,t!==`md`&&`btn-${t}`,a].filter(Boolean).join(` `),...o,children:[n&&(0,R.jsx)(`span`,{className:`btn-icon`,children:n}),r!==void 0&&(0,R.jsx)(`span`,{children:r})]})}function uc({label:e,onClose:t,testId:n,children:r}){let i=(0,_.useRef)(null),a=(0,_.useRef)(t);return a.current=t,(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),a.current())};document.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,i.current?.focus(),()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[]),(0,R.jsxs)(`div`,{"data-testid":n,role:`dialog`,"aria-modal":`true`,"aria-label":e,ref:i,tabIndex:-1,onClick:e=>{e.target===e.currentTarget&&t()},style:{position:`fixed`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,padding:`60px 24px 24px`,background:`rgba(8, 6, 5, 0.55)`,backdropFilter:`blur(2px)`,zIndex:100},children:[e&&(0,R.jsx)(`div`,{style:{position:`absolute`,top:18,left:0,right:0,textAlign:`center`,pointerEvents:`none`},children:(0,R.jsx)(`span`,{className:`mono`,style:{fontSize:10.5,letterSpacing:`0.16em`,color:`rgba(255,255,255,0.55)`,textTransform:`uppercase`,background:`rgba(0,0,0,0.45)`,padding:`4px 10px`,borderRadius:999,border:`1px solid rgba(255,255,255,0.1)`},children:e})}),r]})}function dc({title:e,step:t,totalSteps:n,stepLabel:r,children:i,footer:a,testId:o}){let s=t!==void 0&&n!==void 0?`STEP ${t} / ${n}${r?` · ${r}`:``}`:null;return(0,R.jsxs)(`div`,{"data-testid":o,className:`dialog`,style:{maxWidth:720,boxShadow:`0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--rule-strong)`},onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`dialog-head`,children:[(0,R.jsx)(`div`,{className:`dialog-title`,children:e}),s&&(0,R.jsx)(`div`,{className:`steps`,children:s})]}),(0,R.jsx)(`div`,{className:`dialog-body`,children:i}),(0,R.jsx)(`div`,{className:`dialog-foot`,children:a})]})}function fc({testId:e,options:t,value:n,onChange:r,style:i}){return(0,R.jsx)(`div`,{className:`picker-list`,"data-testid":e,role:`radiogroup`,style:i,children:t.map(t=>{let i=t.value===n;return(0,R.jsxs)(`button`,{type:`button`,"data-testid":`${e}-option-${t.value}`,"data-state":i?`active`:void 0,role:`radio`,"aria-checked":i,className:`picker-row`+(i?` is-active`:``),onClick:()=>r(t.value),style:{all:`unset`,display:`grid`,gridTemplateColumns:`18px 1fr auto`,gap:10,alignItems:`center`,borderRadius:6,cursor:`pointer`,fontSize:13,...i?{background:`var(--accent-soft)`,color:`var(--text)`}:t.accent?{color:`var(--accent)`}:null},children:[(0,R.jsx)(`span`,{className:`marker`,"aria-hidden":`true`,style:{color:`var(--accent)`,fontFamily:`var(--ff-mono)`,fontSize:11},children:t.accent?`+`:i?`▸`:``}),(0,R.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:0},children:[(0,R.jsx)(`span`,{className:`name`,style:{fontWeight:500},children:t.name}),t.desc&&(0,R.jsx)(`span`,{className:`desc`,style:{fontSize:11.5,color:`var(--dim)`,fontFamily:`var(--ff-mono)`},children:t.desc})]}),t.right??(0,R.jsx)(`span`,{})]},t.value)})})}function pc({testId:e,options:t,value:n,onChange:r}){return(0,R.jsx)(`div`,{className:`chipset`,"data-testid":e,role:`radiogroup`,children:t.map(t=>{let i=t.value===n;return(0,R.jsx)(`button`,{type:`button`,"data-testid":`${e}-chip-${t.value}`,"data-state":i?`active`:void 0,role:`radio`,"aria-checked":i,className:`chip`+(i?` is-active`:``),onClick:()=>r(t.value),style:{border:`none`,cursor:`pointer`},children:t.label},t.value)})})}function mc({id:e,label:t,hint:n,error:r,children:i}){return(0,R.jsxs)(`div`,{className:`field`,children:[(0,R.jsxs)(`label`,{htmlFor:e,className:`field-label`,children:[(0,R.jsx)(`span`,{children:t}),n&&(0,R.jsxs)(`span`,{className:`mono dim`,children:[`· `,n]})]}),i,r&&(0,R.jsx)(`span`,{"data-testid":`${e}-error`,style:{fontSize:11,color:`var(--err)`,fontFamily:`var(--ff-mono)`},children:r})]})}function hc({testId:e,label:t,value:n}){return(0,R.jsxs)(`div`,{"data-testid":e,style:{display:`grid`,gridTemplateColumns:`140px 1fr`,gap:12,fontSize:13,padding:`6px 0`,borderBottom:`1px dashed var(--rule)`},children:[(0,R.jsx)(`span`,{className:`dim`,style:{fontFamily:`var(--ff-mono)`},children:t}),(0,R.jsx)(`span`,{style:{fontFamily:`var(--ff-mono)`,wordBreak:`break-word`},children:n})]})}var gc=`optimistic-`,_c=()=>`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;function vc(e,t={}){let n=Ke(),r=t.client??Yo(),i=is(e);return ct({mutationFn:({to:t,message:n})=>r.cue(e,t,n),onMutate:async({to:t,message:r})=>{let a=`${gc}${_c()}`;W(`mutation.cue.started`,{ensemble:e,target:t,optimisticId:a}),await n.cancelQueries({queryKey:i});let o=n.getQueryData(i),s={id:a,from:`maestro`,to:t,text:r,timestamp:new Date().toISOString(),role:`maestro-out`};return n.setQueryData(i,e=>e&&{...e,chat:{...e.chat,messages:[...e.chat.messages,s],total:e.chat.total+1}}),{optimisticId:a,previousSnapshot:o}},onSuccess:(t,n,r)=>{W(`mutation.cue.succeeded`,{ensemble:e,target:n.to,optimisticId:r?.optimisticId})},onError:(t,r,a)=>{W(`mutation.cue.failed`,{ensemble:e,target:r.to,error:t instanceof Error?t.message:String(t)},`warn`),a?.previousSnapshot?n.setQueryData(i,a.previousSnapshot):a&&n.setQueryData(i,e=>e&&{...e,chat:{...e.chat,messages:e.chat.messages.filter(e=>e.id!==a.optimisticId),total:Math.max(0,e.chat.total-1)}})}})}function yc(e,t={}){let n=t.client??Yo();return ct({mutationFn:()=>n.pause(e),onMutate:()=>{W(`mutation.pause.started`,{ensemble:e})},onSuccess:()=>{W(`mutation.pause.succeeded`,{ensemble:e})},onError:t=>{W(`mutation.pause.failed`,{ensemble:e,error:wc(t)},`warn`)}})}function bc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.play(e,t??void 0),onMutate:t=>{W(`mutation.play.started`,{ensemble:e,release:t?.release===!0})},onSuccess:(t,n)=>{W(`mutation.play.succeeded`,{ensemble:e,release:n?.release===!0})},onError:t=>{W(`mutation.play.failed`,{ensemble:e,error:wc(t)},`warn`)}})}function xc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.release(e,t?.playerId),onMutate:t=>{W(`mutation.release.started`,{ensemble:e,playerId:t?.playerId})},onSuccess:(t,n)=>{W(`mutation.release.succeeded`,{ensemble:e,playerId:n?.playerId,released:t.released.length})},onError:(t,n)=>{W(`mutation.release.failed`,{ensemble:e,playerId:n?.playerId,error:wc(t)},`warn`)}})}function Sc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.recruit(e,t),onMutate:t=>{W(`mutation.recruit.started`,{ensemble:e,name:t.name,agent:t.agent})},onSuccess:(t,n)=>{W(`mutation.recruit.succeeded`,{ensemble:e,name:n.name,playerId:t.playerId,entryId:t.entryId})},onError:(t,n)=>{W(`mutation.recruit.failed`,{ensemble:e,name:n.name,error:wc(t)},`warn`)}})}function Cc(e={}){let t=Ke(),n=e.client??Yo();return ct({mutationFn:e=>n.createEnsemble(e),onMutate:e=>{W(`mutation.createEnsemble.started`,{name:e.name,lineup:e.lineup,startMode:e.startMode})},onSuccess:e=>{W(`mutation.createEnsemble.succeeded`,{ensemble:e.ensemble,conductorPlayerId:e.conductorPlayerId,recruitedPlayers:e.recruitedPlayers,playerErrors:e.playerErrors?.length??0}),t.invalidateQueries({queryKey:Zo})},onError:(e,t)=>{W(`mutation.createEnsemble.failed`,{name:t.name,error:wc(e)},`warn`)}})}function wc(e){return e instanceof Error?e.message:String(e)}function Tc(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.restart(e,t),onMutate:t=>{W(`mutation.restart.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.restart.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.restart.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Ec(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.destroy(e,t),onMutate:t=>{W(`mutation.destroy.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.destroy.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.destroy.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Dc(e,t={}){let n=Ke(),r=t.client??Yo();return ct({mutationFn:t=>r.detach(e,t),onMutate:t=>{W(`mutation.detach.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,r)=>{W(`mutation.detach.succeeded`,{ensemble:e,playerId:r.playerId}),n.invalidateQueries({queryKey:is(e)})},onError:(t,n)=>{W(`mutation.detach.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}function Oc(e,t={}){let n=t.client??Yo();return ct({mutationFn:t=>n.recall(e,t),onMutate:t=>{W(`mutation.recall.started`,{ensemble:e,playerId:t.playerId})},onSuccess:(t,n)=>{W(`mutation.recall.succeeded`,{ensemble:e,playerId:n.playerId,messages:t.messages})},onError:(t,n)=>{W(`mutation.recall.failed`,{ensemble:e,playerId:n.playerId,error:wc(t)},`warn`)}})}var kc=[{name:`tempo-conductor`,description:`Orchestrates the ensemble — breaks down tasks, delegates, synthesizes.`,source:`shipped`},{name:`tempo-composer`,description:`Software architect — designs system structure, defines interfaces.`,source:`shipped`},{name:`tempo-critic`,description:`Code reviewer — evaluates changes for correctness and quality.`,source:`shipped`},{name:`tempo-improv`,description:`Researcher and explorer — investigates unknowns, runs spikes.`,source:`shipped`},{name:`tempo-liner`,description:`Documentation specialist — README, CHANGELOG, PR descriptions.`,source:`shipped`},{name:`tempo-roadie`,description:`DevOps engineer — CI/CD, deployments, infrastructure.`,source:`shipped`},{name:`tempo-soloist`,description:`Senior engineer — implements features, fixes bugs, writes tests.`,source:`shipped`},{name:`tempo-tuner`,description:`QA engineer — designs test strategies, finds bugs, validates edges.`,source:`shipped`}],Ac=[{name:`tempo-dev-team`,description:`Conductor + composer + soloist + tuner + critic — full dev cycle.`,players:5,source:`shipped`},{name:`tempo-big-band`,description:`Every shipped player type — the maximum ensemble.`,players:8,source:`shipped`},{name:`tempo-review-squad`,description:`Conductor + critic + tuner — focused on code review and QA.`,players:3,source:`shipped`},{name:`tempo-jam-session`,description:`Conductor + 2 soloists + critic — quick exploratory work.`,players:4,source:`shipped`},{name:`tempo-mock-jam`,description:`Dev-mode all-mock ensemble for adapter testing.`,players:4,source:`shipped`}],jc=`__blank__`,Mc={1:`lineup`,2:`customize`,3:`review`},Nc=[{value:`hold`,label:`hold`},{value:`release-immediately`,label:`release immediately`}],Pc=/^[a-z0-9][a-z0-9-]*$/,Fc=64;function Ic(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`create-ensemble`})},[]);let e=Oi(),t=cs(),n=fs(),r=Cc(),i=n.data??Ac,[a,o]=(0,_.useState)(1),[s,c]=(0,_.useState)(()=>({name:``,lineup:Ac[0]?.name??`__blank__`,host:``,startMode:`hold`,conductorInstructions:``}));(0,_.useEffect)(()=>{!s.host&&t.data&&t.data.length>0&&c(e=>({...e,host:t.data[0].hostname}))},[s.host,t.data]);let l=zc(s.name),u=l===null&&s.lineup.length>0,d=()=>e(`/`),f=()=>{if(a===3||a===1&&!u)return;let e=a+1;o(e),W(`create-ensemble-wizard.advance`,{from:a,to:e})},p=()=>{a!==1&&o(a-1)},m=()=>{if(!u)return;let t=s.lineup===`__blank__`?void 0:s.lineup,n=s.startMode===`hold`?`hold`:`release`;r.mutate({name:s.name,...t?{lineup:t}:{},...s.host?{host:s.host}:{},startMode:n,...s.conductorInstructions?{conductorInstructions:s.conductorInstructions}:{}},{onSuccess:t=>e(`/ensemble/${encodeURIComponent(t.ensemble)}`)})},h=(0,_.useMemo)(()=>[...i.map(Rc),{value:jc,name:`Blank ensemble (recruit manually)`,desc:`Start with no players — use Recruit later from the Workspace.`,accent:!0}],[i]);return(0,R.jsx)(uc,{label:`modal · create ensemble · esc to close`,onClose:d,testId:`create-ensemble-modal`,children:(0,R.jsxs)(dc,{testId:`screen-create-ensemble`,title:`Create ensemble`,step:a,totalSteps:3,stepLabel:Mc[a],footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`hint`,children:`3 steps: lineup → customize → review`}),(0,R.jsxs)(`div`,{className:`row`,style:{display:`flex`,gap:8},children:[(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`create-ensemble-cancel`,onClick:d,children:`Cancel`}),a>1&&(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`create-ensemble-back`,onClick:p,children:`Back`}),a<3?(0,R.jsxs)(G,{variant:`primary`,size:`md`,"data-testid":`create-ensemble-next`,onClick:f,disabled:a===1&&!u,"aria-disabled":a===1&&!u,children:[`Next: `,Mc[a+1]]}):(0,R.jsx)(G,{variant:`primary`,size:`md`,"data-testid":`create-ensemble-submit`,onClick:m,disabled:r.isPending||!u,"aria-disabled":r.isPending||!u,children:r.isPending?`Creating…`:`Create ensemble`})]})]}),children:[a===1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(mc,{id:`create-ensemble-input-name`,label:`Name`,error:s.name.length>0?l:null,children:(0,R.jsx)(`input`,{id:`create-ensemble-input-name`,"data-testid":`create-ensemble-input-name`,className:`input`,placeholder:`my-feature`,value:s.name,onChange:e=>c(t=>({...t,name:e.target.value}))})}),(0,R.jsx)(mc,{id:`create-ensemble-lineup`,label:`Starting lineup`,hint:n.isError?`showing local catalog (daemon unreachable)`:void 0,children:(0,R.jsx)(fc,{testId:`create-ensemble-lineup`,options:h,value:s.lineup,onChange:e=>c(t=>({...t,lineup:e})),style:{maxHeight:220,overflow:`auto`}})})]}),a===2&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`field-grid-2`,children:[(0,R.jsx)(mc,{id:`create-ensemble-host`,label:`Default host`,children:(0,R.jsx)(`select`,{id:`create-ensemble-host`,"data-testid":`create-ensemble-input-host`,className:`select`,value:s.host,onChange:e=>c(t=>({...t,host:e.target.value})),disabled:t.isLoading,children:t.data&&t.data.length>0?t.data.map(e=>(0,R.jsx)(`option`,{value:e.hostname,children:e.hostname},e.hostname)):(0,R.jsx)(`option`,{value:``,children:t.isLoading?`Loading…`:`No hosts`})})}),(0,R.jsx)(mc,{id:`create-ensemble-start-mode`,label:`Start mode`,children:(0,R.jsx)(pc,{testId:`create-ensemble-start-mode`,options:Nc,value:s.startMode,onChange:e=>c(t=>({...t,startMode:e}))})})]}),(0,R.jsx)(mc,{id:`create-ensemble-input-instructions`,label:`Conductor instructions`,hint:`optional override`,children:(0,R.jsx)(`textarea`,{id:`create-ensemble-input-instructions`,"data-testid":`create-ensemble-input-instructions`,className:`textarea`,rows:3,placeholder:`Coordinate the rebuild. Gate phases; don't advance until the current phase is complete.`,value:s.conductorInstructions,onChange:e=>c(t=>({...t,conductorInstructions:e.target.value}))})})]}),a===3&&(0,R.jsxs)(`div`,{"data-testid":`create-ensemble-review`,children:[(0,R.jsx)(hc,{testId:`create-ensemble-summary-name`,label:`Name`,value:s.name}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-lineup`,label:`Lineup`,value:s.lineup===`__blank__`?`blank ensemble`:s.lineup}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-host`,label:`Default host`,value:s.host||`—`}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-start-mode`,label:`Start mode`,value:s.startMode===`hold`?`hold`:`release immediately`}),(0,R.jsx)(hc,{testId:`create-ensemble-summary-instructions`,label:`Instructions`,value:s.conductorInstructions||`—`}),r.isError&&r.error&&(0,R.jsx)(Lc,{name:s.name,err:r.error})]})]})})}function Lc({name:e,err:t}){let n=t instanceof Vo?t.status:null,r,i;return n===409?(r=`Ensemble "${e}" already exists`,i=`Pick a different name or open the existing one from Overview.`):n===400?(r=`Couldn't create ${e}`,i=`Validation failed: ${t.message}`):(r=`Failed to create ${e}`,i=t.message),(0,R.jsxs)(`div`,{"data-testid":`create-ensemble-error`,role:`alert`,style:{marginTop:12,padding:`8px 12px`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,fontSize:12.5,lineHeight:1.4},children:[(0,R.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500},children:r}),(0,R.jsx)(`div`,{style:{marginTop:3,color:`var(--dim)`},children:i})]})}function Rc(e){return{value:e.name,name:(0,R.jsxs)(R.Fragment,{children:[e.name,` `,(0,R.jsxs)(`span`,{className:`mono dim`,style:{fontWeight:400,fontSize:11},children:[`· `,e.players,` player`,e.players===1?``:`s`]})]}),...e.description!==void 0&&{desc:e.description},right:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:e.source.toUpperCase()})}}function zc(e){return e.length===0?`Required`:e.length>Fc?`Too long (≤${Fc} chars)`:Pc.test(e)?null:`Lowercase letters, digits, and dashes only; cannot start with a dash`}function Bc({testId:e,action:t,reason:n,children:r,className:i}){return(0,R.jsx)(`button`,{type:`button`,"data-testid":e,"data-disabled-reason":n,"aria-disabled":`true`,title:n,className:i,onClick:e=>{e.preventDefault(),W(`disabled-action.attempted`,{action:t,reason:n})},style:{background:`var(--bg-2)`,border:`1px solid var(--rule)`,borderRadius:6,padding:`6px 14px`,fontFamily:`var(--ff-display)`,fontSize:14,color:`var(--dim)`,cursor:`not-allowed`,opacity:.7},children:r})}var Vc={padding:`var(--density-pad)`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,color:`var(--accent)`},Hc={padding:`var(--density-pad)`,background:`var(--bg-1)`,border:`1px dashed var(--rule)`,borderRadius:8},Uc={fontFamily:`var(--ff-mono)`};function Wc(e){try{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}catch{return`??:??`}}function Gc(e,t=Date.now()){if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return`—`;let r=Math.max(0,t-n),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;let a=Math.floor(i/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Kc(e){if(e===void 0||!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/1e3);if(t<60)return`<1m`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;if(r<24)return i?`${r}h ${i}m`:`${r}h`;let a=Math.floor(r/24),o=r%24;return o?`${a}d ${o}h`:`${a}d`}function qc(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/1e3);if(r<60)return`expires in ${r}s`;let i=Math.floor(r/60);return i<60?`expires in ${i}m`:`expires in ${Math.floor(i/60)}h`}function Jc(e){if(!e)return`—`;let t=e.trim();return t.length===0?`—`:t.length<=8?t:`${t.slice(0,4)}·${t.slice(-4)}`}function Yc(e,t=Date.now()){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Kc(t-n);return r===`—`?null:r}function Xc(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`hosts`})},[]);let e=cs(),t=Ke(),[n,r]=(0,_.useState)(!1),i=(0,_.useCallback)(()=>{W(`hosts.rescan`,{}),t.invalidateQueries({queryKey:Qo})},[t]),a=(0,_.useCallback)(()=>{r(e=>{let t=!e;return W(`hosts.show-stale`,{value:t}),t})},[]);if(oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Hosts`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Daemons polling this Temporal namespace. Recruits with`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`host=`}),` route to these task queues.`]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`⟳`,"data-testid":`hosts-rescan`,onClick:i,children:`Re-scan`}),(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`hosts-show-stale`,"data-state":n?`on`:`off`,onClick:a,"aria-pressed":n,children:n?`Hide stale`:`Show stale`})]})}),[i,a,n])),e.isLoading)return(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`hosts`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading hosts…`})});if(e.isError)return(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-hosts`,style:Vc,children:e.error?.message??`Failed to load hosts`})});let o=e.data??[],s=n?o:o.filter(e=>e.freshness===`live`);return s.length===0?(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{"data-testid":`hosts-empty`,className:`dim`,style:Hc,children:o.length===0?(0,R.jsxs)(R.Fragment,{children:[`No daemons reporting. Run`,` `,(0,R.jsx)(`code`,{style:Uc,children:`agent-tempo daemon start`}),` on a host.`]}):(0,R.jsxs)(R.Fragment,{children:[`No live daemons. `,o.length,` stale host`,o.length===1?``:`s`,` `,`hidden — toggle `,(0,R.jsx)(`span`,{className:`mono`,children:`Show stale`}),` to view.`]})})}):(0,R.jsx)(Qc,{children:(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`hosts-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Host`}),(0,R.jsx)(`th`,{children:`Platform`}),(0,R.jsx)(`th`,{className:`num`,children:`Sessions`}),(0,R.jsx)(`th`,{className:`num`,children:`Player types`}),(0,R.jsx)(`th`,{children:`Daemon`}),(0,R.jsx)(`th`,{children:`Uptime`}),(0,R.jsx)(`th`,{children:`Heartbeat`}),(0,R.jsx)(`th`,{})]})}),(0,R.jsx)(`tbody`,{children:s.map(e=>(0,R.jsx)(Zc,{host:e},e.hostname))})]})})})}function Zc({host:e}){let t=e.hostname,n=e.instances.length>0?e.instances.reduce((e,t)=>e.lastAccessTime>t.lastAccessTime?e:t):null,r=n?.version??e.profile?.version??`—`,i=e.profile?.platform??`—`,a=e.profile?.availablePlayerTypes?.length??0,o=Gc(n?.lastAccessTime),s=e.freshness===`live`,c=s&&e.profile?.daemonStartedAt!==void 0?Kc(Date.now()-e.profile.daemonStartedAt):`—`;return(0,R.jsxs)(`tr`,{"data-testid":`host-row-${t}`,"data-freshness":e.freshness,children:[(0,R.jsxs)(`td`,{className:`mono`,title:t,children:[(0,R.jsx)(`span`,{style:{color:s?`var(--ok)`:`var(--warn)`},children:`●`}),` `,t]}),(0,R.jsx)(`td`,{"data-label":`Platform`,"data-testid":`host-row-${t}-platform`,className:`mono`,style:{color:`var(--text-2)`},children:i}),(0,R.jsx)(`td`,{"data-label":`Sessions`,"data-testid":`host-row-${t}-sessions`,className:`num`,children:`—`}),(0,R.jsx)(`td`,{"data-label":`Types`,"data-testid":`host-row-${t}-types`,className:`num`,children:a}),(0,R.jsx)(`td`,{"data-label":`Daemon`,"data-testid":`host-row-${t}-daemon`,className:`mono`,children:r}),(0,R.jsx)(`td`,{"data-label":`Uptime`,"data-testid":`host-row-${t}-uptime`,className:`mono dim`,children:c}),(0,R.jsx)(`td`,{"data-label":`Heartbeat`,"data-testid":`host-row-${t}-heartbeat`,className:`mono`,style:{color:s?`var(--text-2)`:`var(--warn)`},children:o}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Bc,{testId:`host-row-${t}-logs`,action:`hosts.logs`,reason:`Streaming daemon logs into the dashboard requires a daemon endpoint that hasn't shipped yet.`,children:`Logs`})}),(0,R.jsx)(`td`,{hidden:!0,"data-testid":`host-row-${t}-version`,children:r}),(0,R.jsx)(`td`,{hidden:!0,"data-testid":`host-row-${t}-freshness`,children:e.freshness})]})}function Qc({children:e}){return(0,R.jsx)(`section`,{"data-testid":`screen-hosts`,style:{display:`flex`,flexDirection:`column`},children:e})}var $c=[{name:`tempo-big-band`,description:`Full-lifecycle development ensemble — design, implement, test, review, and ship.`,players:9,source:`shipped`},{name:`tempo-dev-team`,description:`Development team — conductor, composer, two soloists, and a tuner for feature work.`,players:5,source:`shipped`},{name:`tempo-jam-session`,description:`Exploratory ensemble for spikes, research, and problems where the path forward is unclear.`,players:4,source:`shipped`},{name:`tempo-mock-jam`,description:`All-mock ensemble for autonomous validation harnesses (dev mode only).`,players:4,source:`shipped`},{name:`tempo-review-squad`,description:`Three critics with different focus areas for thorough parallel code review.`,players:3,source:`shipped`}],el=[`Name`,`Summary`,`Players`,`Source`,`Last used`],tl=`Editing lineup files requires a daemon endpoint that hasn’t shipped yet.`;function nl(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`loadouts`})},[]);let e=fs().data??$c;return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Loadouts`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Reusable ensemble lineups. Loaded via`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`agent-tempo up --lineup`}),` or from here.`]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Bc,{testId:`loadouts-action-import`,action:`loadouts.import-yaml`,reason:tl,children:`↑ Import YAML`}),(0,R.jsx)(Bc,{testId:`loadouts-action-new`,action:`loadouts.new`,reason:tl,children:`+ New loadout`})]})}),[])),(0,R.jsx)(`section`,{"data-testid":`screen-loadouts`,children:(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`loadouts-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[el.map(e=>(0,R.jsx)(`th`,{className:e===`Players`?`num`:void 0,children:e},e)),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.length===0?(0,R.jsx)(`tr`,{"data-testid":`loadouts-empty`,children:(0,R.jsx)(`td`,{colSpan:el.length+1,className:`dim`,style:{textAlign:`center`,padding:18},children:`No loadouts available yet.`})}):e.map(e=>(0,R.jsx)(rl,{l:e},e.name))})]})})})}function rl({l:e}){return(0,R.jsxs)(`tr`,{"data-testid":`loadouts-row-${e.name}`,children:[(0,R.jsxs)(`td`,{className:`mono`,children:[(0,R.jsx)(`span`,{className:`accent`,children:`≡`}),` `,e.name]}),(0,R.jsx)(`td`,{"data-label":`Summary`,style:{color:`var(--text-2)`,fontSize:12.5,maxWidth:320},children:e.description??`—`}),(0,R.jsx)(`td`,{"data-label":`Players`,className:`num`,children:e.players}),(0,R.jsx)(`td`,{"data-label":`Source`,children:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11},children:e.source})}),(0,R.jsx)(`td`,{"data-label":`Last used`,className:`mono dim`,style:{fontSize:11.5},children:`—`}),(0,R.jsxs)(`td`,{style:{textAlign:`right`},children:[(0,R.jsx)(Bc,{testId:`loadouts-row-${e.name}-edit`,action:`loadouts.edit`,reason:tl,children:`Edit`}),(0,R.jsx)(Bc,{testId:`loadouts-row-${e.name}-load`,action:`loadouts.load`,reason:tl,children:`▶ Load`})]})]})}var il={live:`●`,stale:`◐`,missing:`✗`},al={live:`var(--ok)`,stale:`var(--warn)`,missing:`var(--err, var(--warn))`},ol={border:`1px solid var(--warn-border, var(--warn))`,borderRadius:`var(--radius, 6px)`,background:`var(--warn-bg, transparent)`};function sl(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`orphans`})},[]);let e=ls(),t=Ke(),n=(0,_.useCallback)(()=>{W(`orphans.rescan`,{}),t.invalidateQueries({queryKey:$o})},[t]);if(oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Orphans`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Cross-host orphan sessions — adapters that left the cluster without an orderly destroy. Paste the `,(0,R.jsx)(`span`,{className:`mono`,children:`/migrate`}),` `,`command into a local session to recover.`]}),actions:(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`⟳`,"data-testid":`orphans-rescan`,onClick:n,children:`Re-scan`})}),[n])),e.isLoading)return(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`orphans`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading orphans…`})});if(e.isError)return(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`orphans-error`,style:Vc,children:e.error?.message??`Failed to load orphans`})});let r=e.data?.orphans??[];return r.length===0?(0,R.jsx)(ll,{children:(0,R.jsxs)(`div`,{"data-testid":`orphans-empty`,className:`dim`,style:Hc,children:[`No cross-host orphans. The cluster is tidy.`,` `,(0,R.jsx)(`a`,{href:`/docs/ops/cross-host-orphans.md`,className:`mono dim`,children:`(what's an orphan?)`})]})}):(0,R.jsx)(ll,{children:(0,R.jsx)(`div`,{className:`panel`,style:ol,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`orphans-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Player`}),(0,R.jsx)(`th`,{children:`Ensemble`}),(0,R.jsx)(`th`,{children:`Host`}),(0,R.jsx)(`th`,{children:`Status`}),(0,R.jsx)(`th`,{children:`Action`})]})}),(0,R.jsx)(`tbody`,{children:r.map(e=>(0,R.jsx)(cl,{orphan:e},e.workflowId))})]})})})}function cl({orphan:e}){let t=e.workflowId,n=(0,_.useCallback)(()=>{typeof navigator<`u`&&navigator.clipboard&&navigator.clipboard.writeText(e.migrateCommand),W(`orphans.copy-migrate`,{workflowId:e.workflowId,ensemble:e.ensemble})},[e.migrateCommand,e.workflowId,e.ensemble]),r=e.workflowId.length>28?`…`+e.workflowId.slice(-26):e.workflowId;return(0,R.jsxs)(`tr`,{"data-testid":`orphan-row-${t}`,"data-liveness":e.hostLiveness,children:[(0,R.jsxs)(`td`,{"data-label":`Player`,"data-testid":`orphan-row-${t}-player`,className:`mono`,children:[(0,R.jsx)(`div`,{children:e.playerId}),(0,R.jsx)(`div`,{className:`mono dim`,style:{fontSize:`0.85em`},title:e.workflowId,children:r})]}),(0,R.jsx)(`td`,{"data-label":`Ensemble`,"data-testid":`orphan-row-${t}-ensemble`,className:`mono`,children:e.ensemble}),(0,R.jsx)(`td`,{"data-label":`Host`,"data-testid":`orphan-row-${t}-host`,className:`mono`,children:e.preferredHost??(0,R.jsx)(`span`,{className:`dim`,children:`(unknown)`})}),(0,R.jsxs)(`td`,{"data-label":`Status`,"data-testid":`orphan-row-${t}-liveness`,className:`mono`,children:[(0,R.jsx)(`span`,{style:{color:al[e.hostLiveness]},"aria-label":`host ${e.hostLiveness}`,children:il[e.hostLiveness]}),` `,e.hostLiveness,` `,e.detachedSince&&(0,R.jsxs)(`span`,{className:`dim`,style:{fontSize:`0.85em`},children:[`(`,Gc(e.detachedSince),`)`]})]}),(0,R.jsx)(`td`,{"data-label":`Action`,children:(0,R.jsxs)(G,{variant:`ghost`,size:`sm`,"data-testid":`orphan-row-${t}-migrate-copy`,title:e.migrateCommand,onClick:n,children:[`📋 Copy `,(0,R.jsx)(`span`,{style:Uc,children:`/migrate`})]})})]})}function ll({children:e}){return(0,R.jsx)(`section`,{"data-testid":`screen-orphans`,style:{display:`flex`,flexDirection:`column`},children:e})}function ul(e,t){if(t.type===`snapshot`)return t.payload;if(!e)return e;switch(t.type){case`heartbeat`:case`throttled`:return e;case`gap`:return e;case`ensemble.created`:return e;case`ensemble.destroyed`:return{...e,state:`offline`,hasConductor:!1,players:[],chat:{messages:[],total:0,hasMore:!1}};case`player.added`:{let n=t.payload,r=e.players.filter(e=>e.playerId!==n.playerId);return{...e,players:[...r,n],hasConductor:e.hasConductor||n.isConductor}}case`player.removed`:{let{playerId:n}=t.payload,r=e.players.find(e=>e.playerId===n),i=e.players.filter(e=>e.playerId!==n),a=i.some(e=>e.isConductor);return{...e,players:i,hasConductor:a,...r?.isConductor?{state:e.state}:{}}}case`player.phase_changed`:{let{playerId:n,phase:r,lastHeartbeatAt:i,processingSince:a}=t.payload,o=e.players.map(e=>e.playerId===n?{...e,phase:r,...i===void 0?{}:{lastHeartbeatAt:i},...a===void 0?{}:{processingSince:a}}:e);return{...e,players:o}}case`chat.appended`:{let n=t.payload,r=e.chat.messages,i=r;if(n.role===`maestro-out`){let e=r.findIndex(e=>e.id.startsWith(`optimistic-`)&&e.from===n.from&&e.to===n.to&&e.text===n.text);e!==-1&&(i=[...r.slice(0,e),...r.slice(e+1)])}let a=[...i,n],o=a.length>200?a.slice(a.length-200):a,s=+(i===r);return{...e,chat:{messages:o,total:e.chat.total+s,hasMore:e.chat.hasMore||o.length<a.length}}}case`chat.compressed`:{let{dropped:n}=t.payload;return{...e,chat:{messages:[],total:Math.max(0,e.chat.total-n),hasMore:!0}}}case`flags.changed`:{let{paused:n,held:r}=t.payload;return{...e,flags:{paused:n,held:r},state:n?`paused`:e.state===`paused`?`online`:e.state}}case`schedules.changed`:return{...e,schedules:t.payload.schedules};case`host_profile.changed`:{let n=t.payload;return{...e,hostProfiles:{...e.hostProfiles,[n.hostname]:n}}}case`player.activity`:return e;case`answer`:return e}return t}function dl(e,t={}){let n=Ke();(0,_.useEffect)(()=>{if(!e||t.enabled===!1)return;let r=t.client??Yo(),i=new AbortController,a=is(e),o=!1;return W(`sse.connected`,{ensemble:e}),(async()=>{try{for await(let t of r.subscribe(e,{signal:i.signal})){if(o)break;if(t.type===`gap`){W(`sse.gap`,{ensemble:e,lastEventId:t.eventId}),n.invalidateQueries({queryKey:a});continue}if(n.setQueryData(a,e=>ul(e,t)),t.type===`snapshot`){let n=t.payload;W(`snapshot.applied`,{ensemble:e,playerCount:n.players.length,hasConductor:n.hasConductor})}}W(`sse.disconnected`,{ensemble:e,reason:`stream-end`})}catch(t){o||W(`sse.disconnected`,{ensemble:e,reason:t instanceof Error?t.message:String(t)},`warn`)}})(),()=>{o=!0,i.abort(`unmount`)}},[e,t.client,t.enabled,n])}function fl(e,t){return e.isConductor&&!t.isConductor?-1:!e.isConductor&&t.isConductor?1:e.playerId.localeCompare(t.playerId)}function pl(e){return[...e].sort(fl)}function ml({playerId:e,playerType:t,isConductor:n=!1,size:r=32}){let i=n||t===`tempo-conductor`||e===`conductor`,a=i?75:ec(t),o=i?`oklch(0.26 0.06 ${a})`:`oklch(0.24 0.045 ${a})`,s=i?`oklch(0.86 0.14 ${a})`:`oklch(0.82 0.13 ${a})`,c=i?`oklch(0.55 0.13 ${a})`:`oklch(0.35 0.05 ${a})`,l=i?`𝄞`:Qs(e);return(0,R.jsx)(`span`,{"data-testid":`player-avatar-${e}`,"data-conductor":i||void 0,"aria-label":e,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:r,height:r,background:o,color:s,fontSize:r*(i?.72:.55),border:`1px solid ${c}`,borderRadius:6,lineHeight:1,flexShrink:0},children:l})}function hl({ensemble:e}){let t=ps(e.name);dl(e.name);let n=t.data,r=(0,_.useMemo)(()=>pl(n?.players??[]),[n?.players]),i=r.length||e.playerCount,a=n?.state??e.state??`online`,o=n?.flags,s=i===0,c=r.filter(e=>e.phase===`attached`||e.phase===`processing`).length,l=Yc(n?.startedAt)??`—`,u=n?.currentBpm,d=n?.description?.trim()??``;return(0,R.jsx)(`article`,{"data-testid":`ensemble-card-${e.name}`,"data-state":a,className:`ensemble-card`+(s?` is-empty`:``),children:(0,R.jsxs)(ao,{to:`/ensemble/${encodeURIComponent(e.name)}`,"data-testid":`ensemble-card-${e.name}-link`,onClick:()=>W(`ensemble-card.click`,{ensemble:e.name}),style:{color:`inherit`,textDecoration:`none`,display:`flex`,flexDirection:`column`,gap:12},children:[(0,R.jsxs)(`div`,{className:`ec-head`,children:[(0,R.jsxs)(`div`,{className:`ec-name`,children:[(0,R.jsx)(`span`,{className:`at`,children:`@`}),e.name]}),(0,R.jsxs)(`div`,{className:`ec-tempo`,children:[(0,R.jsx)(`span`,{className:`bpm`,"data-testid":`ensemble-card-${e.name}-bpm`,children:u===void 0?`—`:u}),(0,R.jsx)(`span`,{children:`bpm`})]})]}),t.isLoading&&!t.data?(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`ensemble-snapshot-${e.name}`,className:`dim ec-desc`,children:`Loading…`}):t.isError?(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-ensemble-snapshot-${e.name}`,className:`ec-desc`,style:{color:`var(--accent)`},children:t.error?.message??`Snapshot unavailable`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`ec-desc`,"data-testid":`ensemble-card-${e.name}-desc`,children:d||null}),(0,R.jsxs)(`div`,{className:`ec-stats`,"data-testid":`ensemble-card-${e.name}-stats`,children:[(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,"data-testid":`ensemble-card-${e.name}-player-count`,children:i}),(0,R.jsx)(`div`,{className:`l`,children:i===1?`player`:`players`})]}),(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,style:{color:c>0?`var(--ok)`:`var(--dim)`},children:c}),(0,R.jsx)(`div`,{className:`l`,children:`active`})]}),(0,R.jsxs)(`div`,{className:`ec-stat`,children:[(0,R.jsx)(`div`,{className:`n`,"data-testid":`ensemble-card-${e.name}-uptime`,style:{fontFamily:`var(--ff-mono)`,fontSize:12},children:l}),(0,R.jsx)(`div`,{className:`l`,children:`uptime`})]})]}),(0,R.jsxs)(`div`,{className:`ec-meta mono dim`,children:[(0,R.jsx)(`span`,{"data-testid":`ensemble-card-${e.name}-lineup`,children:`—`}),(0,R.jsx)(`span`,{"data-testid":`ensemble-card-${e.name}-host`,children:`—`})]}),(a===`paused`||o?.held)&&(0,R.jsxs)(`div`,{className:`ec-flags`,children:[a===`paused`&&(0,R.jsx)(gl,{testId:`ensemble-card-${e.name}-flag-paused`,label:`paused`}),o?.held&&(0,R.jsx)(gl,{testId:`ensemble-card-${e.name}-flag-held`,label:`held`})]}),i>0&&(0,R.jsxs)(`div`,{className:`ec-roster`,children:[r.slice(0,5).map(e=>(0,R.jsx)(ml,{playerId:e.playerId,playerType:e.playerType,isConductor:e.isConductor,size:22},e.playerId)),i>5&&(0,R.jsxs)(`span`,{className:`mono dim`,style:{alignSelf:`center`,marginLeft:4,fontSize:11},children:[`+`,i-5]})]})]})]})})}function gl({testId:e,label:t}){return(0,R.jsx)(`span`,{"data-testid":e,className:`ec-flag`,children:t})}function _l({kicker:e,title:t,right:n,tight:r=!1}){return(0,R.jsxs)(`div`,{className:`section-head${r?` is-tight`:``}`,children:[(0,R.jsxs)(`div`,{children:[e&&(0,R.jsx)(`div`,{className:`section-kicker mono`,children:e}),(0,R.jsx)(`div`,{className:`section-title`,children:t})]}),n&&(0,R.jsx)(`div`,{className:`section-head-right`,children:n})]})}function vl(e,t,n=`${t}s`){return e===1?t:n}function yl({testId:e,count:t,label:n,pluralLabel:r,showDot:i}){return(0,R.jsxs)(`span`,{className:`page-pill`,"data-testid":e,children:[i&&(0,R.jsx)(`span`,{className:`pill-dot`}),(0,R.jsx)(`span`,{className:`pill-num`,children:t}),vl(t,n,r)]})}function bl(){let e=ss(),t=cs(),n=Oi(),r=Ke(),i=e.data,a=(0,_.useMemo)(()=>{let e=i??[];return{ensembles:e.length,players:e.reduce((e,t)=>e+(t.playerCount??0),0),hosts:t.data?.length??0,hasRunning:e.some(e=>e.playerCount>0)}},[i,t.data]),o=(0,_.useCallback)(()=>{W(`overview.refresh`,{}),r.invalidateQueries({queryKey:Zo}),r.invalidateQueries({queryKey:Qo})},[r]),s=(0,_.useCallback)(()=>{W(`overview.new-ensemble.click`,{}),n(`/create-ensemble`)},[n]);return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Overview`,pills:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yl,{testId:`overview-stat-ensembles`,count:a.ensembles,label:`ensemble`,showDot:a.hasRunning}),(0,R.jsx)(yl,{testId:`overview-stat-players`,count:a.players,label:`player`}),(0,R.jsx)(yl,{testId:`overview-stat-hosts`,count:a.hosts,label:`host`})]}),subtitle:`All ensembles, rolled up. Tap one to dive in.`,actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`↻`,"data-testid":`overview-refresh`,onClick:o,"aria-label":`Refresh`,children:`Refresh`}),(0,R.jsx)(G,{variant:`primary`,size:`sm`,icon:`+`,"data-testid":`overview-new-ensemble`,onClick:s,"aria-label":`New ensemble`,children:`New ensemble`})]})}),[a,o,s])),e.isLoading?(0,R.jsx)(`section`,{"data-testid":`screen-overview`,children:(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`ensemble-list`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading ensembles…`})}):e.isError?(0,R.jsx)(`section`,{"data-testid":`screen-overview`,children:(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-ensemble-list`,style:Vc,children:e.error?.message??`Failed to load ensembles`})}):(0,R.jsxs)(`section`,{"data-testid":`screen-overview`,children:[(0,R.jsx)(_l,{kicker:`I / RUNNING`,title:`Active ensembles`}),a.ensembles===0?(0,R.jsxs)(`div`,{"data-testid":`overview-empty`,className:`dim`,style:Hc,children:[`No ensembles are running. Open a terminal and run`,` `,(0,R.jsx)(`code`,{style:Uc,children:`agent-tempo up <name>`}),` to start one.`]}):(0,R.jsx)(`div`,{className:`ensemble-grid`,children:(i??[]).map(e=>(0,R.jsx)(hl,{ensemble:e},e.name))}),(0,R.jsx)(xl,{})]})}function xl(){return(0,R.jsxs)(`div`,{style:{marginTop:`calc(var(--density-gap) * 1.5)`},"data-testid":`overview-recent-activity`,children:[(0,R.jsx)(_l,{kicker:`II / RECENT`,title:`Recent activity`,right:(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11},children:`across all ensembles`})}),(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsx)(`div`,{className:`panel-body flush event-log`,children:(0,R.jsx)(`div`,{className:`event-row`,"data-testid":`overview-recent-activity-empty`,style:{display:`flex`,justifyContent:`center`,color:`var(--dim)`},children:(0,R.jsx)(`span`,{children:`No recent activity. Cross-ensemble event stream coming soon.`})})})})]})}function Sl(e){let t=[],n=``,r=!1,i=!1,a=!1,o=()=>{(n.length>0||a)&&(t.push(n),n=``,a=!1)};for(let t=0;t<e.length;t++){let s=e[t];if(s===`"`&&!r){i=!i,a=!0;continue}if(s===`'`&&!i){r=!r,a=!0;continue}if(/\s/.test(s)&&!r&&!i){o();continue}n+=s,a=!0}return o(),{tokens:t,unterminatedQuote:r||i}}function Cl(e){let t=e.trim();if(!t.startsWith(`/`))return null;let{tokens:n,unterminatedQuote:r}=Sl(t.slice(1));if(n.length===0)return null;let i=n[0].toLowerCase(),a=n.slice(1);return r?{name:i,args:a,raw:t,unterminatedQuote:!0}:{name:i,args:a,raw:t}}var wl=new Set([`worktree`,`restart`,`destroy`,`attachment-info`]);function Tl(e){let t=e.trimStart();if(!t)return null;if(t.startsWith(`/`)&&!t.includes(` `))return{mode:`command`,partial:t.slice(1).toLowerCase(),replacePrefix:`/`};if(t.startsWith(`@`)&&!t.includes(` `))return{mode:`player`,partial:t.slice(1).toLowerCase(),replacePrefix:`@`};if(t.startsWith(`/`)&&t.includes(` `)){let e=t.indexOf(` `),n=t.slice(1,e).toLowerCase(),r=t.slice(e+1);if(r.includes(` `))return null;if(wl.has(n))return{mode:`player-arg`,partial:r.toLowerCase(),replacePrefix:`/${n} `}}return null}function El(e){return e===`player`?`@`:`/`}function Dl(e,t){let n=t.startsWith(`/`)?t.slice(1):t;if(!n)return[...e];let r=n.toLowerCase();return e.filter(e=>e.name.toLowerCase().startsWith(r))}function Ol(e,t){let n=t.toLowerCase();return n?e.filter(e=>{let t=e.toLowerCase();return t===n?!1:t.startsWith(n)||t.split(`-`).some(e=>e.startsWith(n))}):[...e]}var kl=/^@([a-zA-Z0-9_-]+)(?:\s+([\s\S]*))?$/;function Al(e){let t=e.trim();if(t.startsWith(`/`)){let e=Cl(t);return e?{kind:`slash`,name:e.name,args:e.args,raw:e.raw}:{kind:`plain`,text:t}}if(t.startsWith(`@`)){let e=kl.exec(t);return e?{kind:`cue`,target:e[1],text:(e[2]??``).trim()}:{kind:`plain`,text:t}}return{kind:`plain`,text:t}}var jl=[{name:`help`,description:`Show available slash commands`,usage:`/help`},{name:`clear`,description:`Clear the local chat scrollback (does not affect server history)`,usage:`/clear`},{name:`pause`,description:`Pause every session + scheduler + maestro in this ensemble`,usage:`/pause`},{name:`play`,description:`Resume a paused ensemble`,usage:`/play`},{name:`release`,description:`Release all held players (or a single player when given)`,usage:`/release [player]`},{name:`recall`,description:`Read a player's message history`,usage:`/recall <player>`}];jl.map(e=>e.name);function Ml(e){let t=Ke(),n=yc(e),r=bc(e),i=xc(e),a=Oc(e);return(0,_.useCallback)(o=>{let s=o.name;switch(W(`slash.dispatched`,{ensemble:e,verb:s,args:o.args.length}),s){case`help`:return{handled:!0,verb:s,status:{level:`info`,message:`Slash commands`,description:jl.map(e=>` ${e.usage.padEnd(28)} ${e.description}`).join(`
|
|
17
17
|
`)}};case`clear`:return t.setQueryData(is(e),e=>e&&{...e,chat:{...e.chat,messages:[],total:0}}),{handled:!0,verb:s};case`pause`:return n.mutate(),{handled:!0,verb:s};case`play`:return r.mutate(),{handled:!0,verb:s};case`release`:{let e=o.args[0];return i.mutate(e?{playerId:e}:void 0),{handled:!0,verb:s}}case`recall`:{let e=o.args[0];return e?(a.mutate({playerId:e}),{handled:!0,verb:s}):{handled:!1,reason:`invalid-args`,verb:s,usage:`/recall <player>`,status:{level:`error`,message:`Usage: /recall <player>`,description:`Pass a player name — e.g. /recall tempo-eng`}}}default:return{handled:!1,reason:`unknown`,verb:s,status:{level:`error`,message:`Slash command "/${s}" not supported in the dashboard`,description:`Use the Maestro chat to ask the conductor instead, or run it from the TUI / CLI.`}}}},[e,t,n,r,i,a])}var Nl=`maestro`;function Pl(e){let t=[];for(let n of e){let e=t[t.length-1],r=Fl(n);n.broadcastId&&e&&e[0].broadcastId===n.broadcastId&&Fl(e[0])===r?e.push(n):t.push([n])}return t}function Fl(e){return e.role===`maestro-out`?`out`:`in`}function Il(e,t){return Pl(e).map(e=>{let n=e[0],r=Fl(n),i;n.broadcastId&&(i={count:e.length,recipients:e.map(e=>e.to)});let a;return!i&&n.role===`maestro-out`&&n.to&&n.to!==`maestro`&&n.to!==`conductor`&&n.to!==t&&(a=n.to),{source:n,direction:r,recipientLabel:a,broadcastBadge:i}})}function Ll(e){let t=`📡 broadcast → ${e.count} player${e.count===1?``:`s`}`,n=e.recipients.slice(0,3),r=Math.max(0,e.count-n.length);return n.length===0?t:`${t} (${r>0?`${n.join(`, `)} +${r} more`:n.join(`, `)})`}function Rl({phase:e,playerId:t,showLabel:n=!1}){let r=nc(e),i=Do(),a=!!r.pulse&&!i;return(0,R.jsxs)(`span`,{"data-testid":`phase-dot-${t}`,"data-phase":e??`unknown`,"data-bucket":r.bucket,style:{display:`inline-flex`,alignItems:`center`,gap:6,color:r.color,fontFamily:`var(--ff-ui)`,fontSize:`var(--density-fs-sm)`},children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:11,lineHeight:1,animation:a?`phase-dot-pulse 1.4s ease-in-out infinite`:`none`},children:r.icon}),n&&(0,R.jsx)(`span`,{className:`dim`,children:r.label})]})}var K={out:{className:`msg out`,arrow:`→`,defaultTarget:`conductor`},in:{className:`msg in`,arrow:`←`,defaultTarget:`maestro`},route:{className:`msg route`,arrow:`→`,defaultTarget:`maestro`}};function q({m:e}){let t=`feed-message-${e.id}`,n=K[e.kind],r=e.from??`unknown`,i=e.to??n.defaultTarget,a=J(e,r),o=e.fromPhase?(0,R.jsx)(Rl,{phase:e.fromPhase,playerId:r}):null,s=(0,R.jsxs)(`div`,{className:`msg-head`,children:[e.kind===`out`&&(0,R.jsx)(jo,{size:12}),a,e.kind===`in`&&e.fromIsConductor&&(0,R.jsx)(`span`,{style:{color:`var(--warn)`},"aria-label":`conductor`,children:`★`}),o,(0,R.jsx)(`span`,{className:`arrow`,children:n.arrow}),(0,R.jsx)(`span`,{className:`target`,children:i}),(0,R.jsx)(`span`,{className:`time`,children:e.time})]}),c=(0,R.jsx)(`div`,{className:`msg-body`,"data-testid":`${t}-body`,children:e.body});return(0,R.jsxs)(`div`,{className:n.className,"data-testid":t,"data-direction":e.kind,children:[e.kind!==`out`&&(0,R.jsx)(`div`,{className:`msg-avatar`,children:(0,R.jsx)(ml,{playerId:r,playerType:e.fromType,isConductor:e.fromIsConductor,size:28})}),(0,R.jsxs)(`div`,{children:[s,c]})]})}function J(e,t){return e.kind===`out`?(0,R.jsx)(`span`,{className:`sender mono`,children:`you`}):e.kind===`route`?(0,R.jsx)(`span`,{className:`sender`,style:{color:`var(--dim)`},children:t}):(0,R.jsx)(`span`,{className:`sender`,style:{color:e.fromType===void 0?`var(--accent)`:`oklch(0.8 0.12 ${ec(e.fromType)})`},children:t})}function Y({ensemble:e,messages:t,conductorPlayerId:n,players:r,hasCompressedGap:i=!1}){let a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>{let e=new Map;for(let t of r??[])e.set(t.playerId,t);return e},[r]),s=(0,_.useMemo)(()=>Il(t,n),[t,n]),c=(0,_.useMemo)(()=>s.map(e=>X(e,o)),[s,o]);return(0,_.useEffect)(()=>{let n=s.filter(e=>e.broadcastBadge).length;W(`chat.rendered`,{ensemble:e,count:s.length,messages:t.length,broadcasts:n}),a.current&&(a.current.scrollTop=a.current.scrollHeight)},[e,t.length,i]),t.length===0&&!i?(0,R.jsx)(`div`,{"data-testid":`chat-log-${e}`,"data-empty":`true`,className:`dim chat-log`,style:{background:`var(--bg-1)`,border:`1px dashed var(--rule)`,borderRadius:8,minHeight:0},children:`No messages yet. The conductor's first dispatch will land here.`}):(0,R.jsxs)(`div`,{ref:a,"data-testid":`chat-log-${e}`,className:`chat-log`,children:[i&&(0,R.jsx)(`div`,{"data-testid":`chat-log-${e}-compressed-gap`,role:`status`,style:{padding:`8px 12px`,background:`var(--bg-2)`,border:`1px solid var(--rule)`,borderRadius:6,color:`var(--dim)`,fontSize:`var(--density-fs-sm)`,marginBottom:6},children:`…earlier messages were dropped to keep up with chat volume. Reload the page to fetch them.`}),c.map(e=>(0,R.jsx)(q,{m:e},e.id))]})}function X(e,t){let n=e.source,r=n.from?t.get(n.from):void 0,i;return i=n.from===`maestro`?`out`:n.to===`maestro`?`in`:`route`,{id:n.id,kind:i,from:n.from,to:n.to,time:Wc(n.timestamp),body:zl(e),fromType:r?.playerType,fromIsConductor:r?.isConductor,fromPhase:r?.phase}}function zl(e){let t=e.source;return(0,R.jsxs)(R.Fragment,{children:[e.broadcastBadge&&(0,R.jsx)(`span`,{"data-testid":`broadcast-badge-${t.broadcastId}`,"data-broadcast-count":e.broadcastBadge.count,className:`dim`,style:{marginRight:6},children:Ll(e.broadcastBadge)}),e.recipientLabel&&!e.broadcastBadge&&(0,R.jsxs)(`span`,{"data-testid":`chat-message-${t.id}-recipient`,className:`dim`,style:{marginRight:6},children:[`→ @`,e.recipientLabel]}),(0,R.jsx)(`span`,{style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:t.text})]})}var Bl=8;function Vl({visible:e,items:t,selectedIndex:n,prefix:r,onSelect:i,testId:a=`composer-autofill`}){if(!e||t.length===0)return null;let o=0;t.length>Bl&&(o=Math.max(0,Math.min(n-Math.floor(Bl/2),t.length-Bl)));let s=t.slice(o,o+Bl);return(0,R.jsxs)(`div`,{"data-testid":a,role:`listbox`,"aria-label":r===`/`?`Slash command suggestions`:`Player suggestions`,style:{position:`absolute`,bottom:`calc(100% + 6px)`,left:0,right:0,background:`var(--bg-2)`,border:`1px solid var(--rule-strong)`,borderRadius:8,boxShadow:`0 6px 18px rgb(0 0 0 / 0.18)`,maxHeight:280,overflow:`auto`,zIndex:40,padding:4},children:[o>0&&(0,R.jsxs)(`div`,{className:`dim`,style:{padding:`4px 10px`,fontSize:11,fontFamily:`var(--ff-mono)`},children:[`↑ `,o,` more above`]}),s.map((e,t)=>{let s=o+t,c=s===n;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":c,"data-testid":`${a}-item-${e.name}`,"data-selected":c?`true`:void 0,onMouseDown:e=>{e.preventDefault(),i(s)},style:{display:`flex`,alignItems:`baseline`,gap:8,width:`100%`,padding:`6px 10px`,borderRadius:6,border:0,background:c?`color-mix(in oklch, var(--accent), transparent 80%)`:`transparent`,color:c?`var(--text)`:`var(--text-2)`,cursor:`pointer`,fontFamily:`var(--ff-ui)`,fontSize:13,textAlign:`left`,transition:`background 0.08s, color 0.08s`},children:[(0,R.jsxs)(`span`,{className:`mono`,style:{color:c?`var(--accent)`:`var(--muted)`,fontWeight:600,flexShrink:0},children:[r,e.name]}),e.description&&(0,R.jsx)(`span`,{className:`dim`,style:{fontSize:12,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:0},children:e.description})]},`${r}${e.name}`)}),o+Bl<t.length&&(0,R.jsxs)(`div`,{className:`dim`,style:{padding:`4px 10px`,fontSize:11,fontFamily:`var(--ff-mono)`},children:[`↓ `,t.length-o-Bl,` more below`]})]})}function Hl(e,t,n){return e.mode===`command`?t.length===0?[]:Dl(t,e.partial).map(e=>({name:e.name,description:e.description})):n.length===0?[]:Ol(n,e.partial).map(e=>({name:e}))}function Ul(e){let{value:t,commands:n=[],players:r=[],onApply:i}=e,[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(t);(0,_.useEffect)(()=>{s.current!==t&&(o(!1),s.current=t)},[t]);let c=(0,_.useMemo)(()=>Tl(t),[t]),l=(0,_.useMemo)(()=>c?Hl(c,n,r):[],[c,n,r]),u=!a&&c!==null&&l.length>0,[d,f]=(0,_.useState)(0);(0,_.useEffect)(()=>{d>=l.length&&f(0)},[l.length,d]);let p=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=c?.mode??null;p.current!==e&&(f(0),p.current=e)},[c?.mode]);let m=(0,_.useCallback)(()=>{f(e=>Math.max(0,e-1))},[]),h=(0,_.useCallback)(()=>{f(e=>Math.min(l.length-1,e+1))},[l.length]),g=(0,_.useCallback)(e=>{if(!u||!c)return!1;let t=l[e];return t?(i(`${c.replacePrefix}${t.name} `),!0):!1},[u,c,l,i]),v=(0,_.useCallback)(()=>g(d),[g,d]),y=(0,_.useCallback)(()=>{o(!0)},[]),b=(0,_.useCallback)(()=>{o(!1),f(0)},[]);return{visible:u,items:l,selectedIndex:d,mode:c?.mode??null,up:m,down:h,accept:v,acceptAt:g,close:y,reset:b}}var Wl=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform||navigator.userAgent||``),Gl=(0,_.forwardRef)(function({placeholder:e=`Message…`,value:t,defaultValue:n,onChange:r,onSubmit:i,onMention:a,onSlash:o,disabled:s=!1,sendLabel:c=`Send`,testIdPrefix:l=`composer`,commands:u,players:d},f){let p=(0,_.useRef)(null),m=t!==void 0,[h,g]=(0,_.useState)(n??``),v=m?t:h,y=(u?.length??0)>0||(d?.length??0)>0,b=(0,_.useCallback)(()=>{let e=p.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[]),x=(0,_.useCallback)(e=>{m||g(e),r?.(e),requestAnimationFrame(()=>{b();let t=p.current;if(t){t.focus();let n=e.length;t.setSelectionRange(n,n)}})},[m,r,b]),S=Ul({value:v,commands:u,players:d,onApply:x}),C=e=>{let t=e.target.value;m||g(t),r?.(t),b()},w=v.trim(),T=w.length>0&&!s,E=()=>{T&&(i?.(w),m||(g(``),requestAnimationFrame(b)),S.reset())},D=e=>{if(S.visible){if(e.key===`ArrowUp`){e.preventDefault(),S.up();return}if(e.key===`ArrowDown`){e.preventDefault(),S.down();return}if(e.key===`Tab`){e.preventDefault(),S.accept();return}if(e.key===`Escape`){e.preventDefault(),S.close();return}}e.key===`Enter`&&(Wl?e.metaKey:e.ctrlKey)&&(e.preventDefault(),E())},O=()=>{a?.(),y&&v===``&&x(`@`)},k=()=>{o?.(),y&&v===``&&x(`/`)};(0,_.useImperativeHandle)(f,()=>({focus:()=>p.current?.focus(),clear:()=>{m||g(``);let e=p.current;e&&(e.value=``,e.style.height=`auto`)}}),[m]);let A=Wl?`⌘↩`:`Ctrl ↩`,j=Wl?`Cmd + Return to send`:`Ctrl + Enter to send`,ee=S.mode?El(S.mode):`/`;return(0,R.jsx)(`div`,{className:`composer`,"data-testid":l,children:(0,R.jsxs)(`div`,{className:`composer-frame`,style:{position:`relative`},children:[(0,R.jsx)(Vl,{visible:S.visible,items:S.items,selectedIndex:S.selectedIndex,prefix:ee,onSelect:e=>S.acceptAt(e),testId:`${l}-autofill`}),(0,R.jsx)(`textarea`,{ref:p,className:`composer-input`,rows:1,placeholder:e,disabled:s,value:v,onChange:C,onKeyDown:D,"aria-label":`Message text`,"aria-autocomplete":y?`list`:void 0,"aria-expanded":S.visible||void 0,"data-testid":`${l}-input`}),(0,R.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,R.jsxs)(`div`,{className:`composer-tools`,children:[(0,R.jsx)(`button`,{type:`button`,className:`composer-icon`,title:`Mention a player`,"aria-label":`Mention a player`,disabled:s,onClick:O,"data-testid":`${l}-mention`,children:`@`}),(0,R.jsx)(`button`,{type:`button`,className:`composer-icon`,title:`Slash command`,"aria-label":`Slash command`,disabled:s,onClick:k,"data-testid":`${l}-slash`,children:`/`})]}),(0,R.jsxs)(`div`,{className:`composer-send`,children:[(0,R.jsx)(`span`,{className:`composer-hint mono dim`,title:j,children:A}),(0,R.jsx)(G,{variant:`primary`,size:`md`,onClick:E,disabled:!T,"aria-disabled":!T,"data-testid":`${l}-send`,children:c})]})]})]})})});function Kl({level:e,message:t,description:n,onDismiss:r}){return(0,R.jsxs)(`div`,{"data-testid":`composer-status`,"data-level":e,role:`alert`,style:{display:`flex`,alignItems:`flex-start`,gap:12,padding:`8px 12px`,marginBottom:6,background:`var(--bg-1)`,border:`1px solid ${e===`error`?`var(--accent)`:`var(--rule-strong)`}`,borderRadius:8,fontSize:12.5,lineHeight:1.4},children:[(0,R.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,R.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500},children:t}),n!==void 0&&(0,R.jsx)(`div`,{style:{marginTop:3,color:`var(--dim)`,whiteSpace:`pre-wrap`},children:n})]}),(0,R.jsx)(`button`,{type:`button`,"data-testid":`composer-status-dismiss`,"aria-label":`Dismiss`,onClick:r,style:{flexShrink:0,width:22,height:22,padding:0,border:0,background:`transparent`,color:`var(--dim)`,fontSize:16,lineHeight:1,cursor:`pointer`,borderRadius:4},children:`×`})]})}function ql({title:e=`Maestro chat is popped out`,subtitle:t=`Click anywhere here, or close the floating window, to dock it back.`,onClick:n,testId:r=`chat-stub`}){return(0,R.jsx)(`div`,{className:`panel chat chat-stub`,"data-testid":r,role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n?.())},"aria-label":`Dock chat back`,children:(0,R.jsxs)(`div`,{className:`chat-stub-inner`,children:[(0,R.jsx)(`div`,{className:`chat-stub-icon`,"aria-hidden":`true`,children:`↗`}),(0,R.jsx)(`div`,{className:`chat-stub-title`,children:e}),(0,R.jsx)(`div`,{className:`chat-stub-sub mono dim`,children:t})]})})}function Jl({titlePrefix:e=`agent-tempo · maestro chat`,titleAccent:t,alwaysOnTopLabel:n=`always on top`,onClose:r,children:i,testId:a=`popout-window`}){return(0,R.jsxs)(`div`,{className:`popout-window`,"data-testid":a,role:`region`,"aria-label":`Popped-out Maestro chat`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`popout-chrome`,children:[(0,R.jsxs)(`div`,{className:`popout-dots`,children:[(0,R.jsx)(`button`,{type:`button`,className:`popout-dot r`,title:`Dock back`,"aria-label":`Dock chat back`,"data-testid":`${a}-close`,onClick:r}),(0,R.jsx)(`span`,{className:`popout-dot y`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`popout-dot g`,"aria-hidden":`true`})]}),(0,R.jsxs)(`div`,{className:`popout-title mono`,children:[(0,R.jsx)(`span`,{className:`dim`,children:e}),t&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(`span`,{className:`accent`,children:t})]})]}),(0,R.jsxs)(`div`,{className:`popout-right mono dim`,children:[(0,R.jsx)(`span`,{className:`popout-pin`,"aria-hidden":`true`,children:`◈`}),` `,n]})]}),i]})}function Yl({type:e}){let t=ec(e);return(0,R.jsx)(`span`,{"data-testid":`type-badge-${e}`,style:{display:`inline-block`,padding:`1px 6px`,fontFamily:`var(--ff-mono)`,fontSize:11,letterSpacing:`0.02em`,borderRadius:4,color:`oklch(0.82 0.11 ${t})`,border:`1px solid oklch(0.38 0.07 ${t})`,background:`oklch(0.2 0.035 ${t} / 0.5)`},children:e})}function Xl({player:e,selected:t=!1,onSelect:n}){let r=`roster-item`+(t?` is-active`:``),i=e.part?.trim(),a=!e.playerType&&e.agentType!==`claude`;return(0,R.jsxs)(`button`,{type:`button`,"data-testid":`player-row-${e.playerId}`,"data-selected":t||void 0,"data-conductor":e.isConductor||void 0,onClick:()=>n?.(e.playerId),className:r,style:{background:t?`var(--accent-soft)`:`transparent`,color:`var(--text)`,border:0,borderLeft:t?`2px solid var(--accent)`:`2px solid transparent`,textAlign:`left`,cursor:`pointer`,fontFamily:`var(--ff-ui)`,width:`100%`},children:[(0,R.jsx)(ml,{playerId:e.playerId,playerType:e.playerType,isConductor:e.isConductor,size:32}),(0,R.jsxs)(`span`,{className:`col`,style:{minWidth:0,gap:2},children:[(0,R.jsxs)(`span`,{className:`rn`,children:[(0,R.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.playerId}),e.isConductor&&(0,R.jsx)(`span`,{"data-testid":`conductor-indicator`,className:`conductor-star`,title:`Conductor`,"aria-label":`conductor`,children:`★`}),(0,R.jsx)(Rl,{phase:e.phase,playerId:e.playerId})]}),(0,R.jsxs)(`span`,{className:`rp`,children:[e.playerType&&(0,R.jsx)(Yl,{type:e.playerType}),a&&(0,R.jsx)(`span`,{"data-testid":`adapter-badge-${e.agentType}`,style:{display:`inline-block`,padding:`1px 6px`,fontFamily:`var(--ff-mono)`,fontSize:11,letterSpacing:`0.02em`,borderRadius:4,color:`var(--muted)`,border:`1px solid var(--rule)`,background:`transparent`},children:e.agentType}),i&&(0,R.jsx)(`span`,{style:{marginLeft:6},children:i})]})]}),(0,R.jsxs)(`div`,{className:`rmeta`,children:[(0,R.jsx)(`div`,{className:`heartbeat`,children:e.hostname||`—`}),(0,R.jsx)(`div`,{children:e.agentType})]})]})}var Zl=60;function Ql(e,t=Zl){return e.length===t?e:e.length>t?e.slice(-t):[...Array(t-e.length).fill(0),...e]}function $l({series:e,height:t=44,bpm:n=92,targetBars:r=Zl}){let i=Do(),a=Ql(e,r),o=Math.max(...a,1),s=Math.max(a.length,1)*6,c=e.length>0&&e[e.length-1]>0;return(0,R.jsxs)(`div`,{className:`tempo-strip`,"data-testid":`tempo-strip`,style:{height:t},children:[(0,R.jsxs)(`div`,{className:`tempo-strip-label`,children:[(0,R.jsx)(`span`,{className:`mono dim`,children:`tempo`}),(0,R.jsxs)(`span`,{className:`tempo-bpm`,children:[(0,R.jsx)(`span`,{className:`mono num`,"data-testid":`tempo-strip-bpm`,children:n}),(0,R.jsx)(`span`,{className:`mono dim`,children:`bpm`})]})]}),(0,R.jsxs)(`svg`,{className:`tempo-strip-svg`,viewBox:`0 0 ${s} ${t}`,width:`100%`,height:t,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[a.map((e,n)=>n%10==0?(0,R.jsx)(`line`,{x1:n*6,x2:n*6,y1:0,y2:t,stroke:`var(--rule)`,strokeDasharray:`2 3`},`g${n}`):null),a.map((e,n)=>{let r=e/o*(t-8),s=n*6,l=t-r-2,u=n>a.length-10,d=n===a.length-1;return(0,R.jsx)(`rect`,{x:s,y:l,width:4,height:Math.max(1.5,r),rx:1,fill:u?`var(--accent)`:`var(--rule-strong)`,opacity:u?1:.75,style:d&&c&&!i?{animation:`tempo-strip-pulse 0.9s ease-in-out infinite`}:void 0},n)})]})]})}function eu(){return(0,R.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,"data-testid-exempt":`decorative-glyph`,children:[(0,R.jsx)(`circle`,{cx:`9`,cy:`8`,r:`3.2`}),(0,R.jsx)(`path`,{d:`M2.5 19c0-3.4 2.9-5.5 6.5-5.5s6.5 2.1 6.5 5.5`}),(0,R.jsx)(`circle`,{cx:`17`,cy:`7`,r:`2.4`}),(0,R.jsx)(`path`,{d:`M15.5 13.2c2.4 0.5 5 2 5 5.3`})]})}function tu(){let{id:e}=Mi(),t=e??null,n=Oi(),r=Ti(),i=ps(t),a=i.data?.currentBpm??0,o=i.data?.tempoSeries??[],s=Yc(i.data?.startedAt);dl(t),(0,_.useEffect)(()=>{t&&W(`workspace.opened`,{ensemble:t})},[t]);let c=(0,_.useMemo)(()=>pl(i.data?.players??[]),[i.data?.players]),l=(0,_.useMemo)(()=>c.find(e=>e.isConductor),[c]),u=l?.playerId,d=l?.hostname,f=i.data?.schedules??[],p=i.data?.chat?.messages??[],m=!!i.data&&p.length===0&&i.data.chat.hasMore,h=i.data?.flags,g=h?.paused??!1,v=h?.held??!1,y=gm(r.pathname),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(!1),w=vc(t??``),T=Ml(t??``),[E,D]=(0,_.useState)(null),O=(0,_.useMemo)(()=>c.map(e=>e.playerId),[c]),k=e=>{let n=Al(e);if(n.kind===`slash`){D(T(n).status??null);return}if(n.kind===`cue`){if(n.text===``){D({level:`error`,message:`No message after @${n.target}`,description:`Type something after the mention to send a directed cue.`});return}if(!O.includes(n.target)){D({level:`error`,message:`No player named "${n.target}" in this ensemble`,description:`Check spelling, or use @ autocomplete (Tab to accept).`});return}D(null),w.reset(),w.mutate({to:n.target,message:n.text});return}if(!u){W(`chat.message.skipped`,{ensemble:t,hasTarget:!1,length:n.text.length});return}D(null),w.reset(),w.mutate({to:u,message:n.text})},A=w.isError&&w.error?{level:`error`,message:`Failed to send`,description:w.error.message}:null,j=E??A,ee=(0,_.useCallback)(()=>{D(null),w.isError&&w.reset()},[w]),te=c.filter(e=>e.phase===`attached`||e.phase===`processing`).length,ne=c.filter(e=>e.phase===`awaiting`).length,M=c.filter(e=>e.phase===`draining`||e.phase===`detached`).length,N=(0,_.useCallback)(()=>x(e=>!e),[]);if(cc((0,_.useMemo)(()=>({lineup:t??``,status:{active:te,idle:ne,detached:M,uptime:`—`},onAction:N,actionIcon:(0,R.jsx)(eu,{}),actionLabel:b?`Hide roster`:`Show roster, events, schedules`,actionActive:b}),[t,te,ne,M,b,N])),!t)return(0,R.jsx)(`section`,{"data-testid":`workspace-missing-ensemble`,role:`alert`,className:`dim`,children:`No ensemble in the URL. Pick one from the Overview screen.`});if(i.isLoading&&!i.data)return(0,R.jsxs)(`section`,{"data-testid":`workspace-${t}`,"data-state":`loading`,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[(0,R.jsx)(Bs,{prefix:`ensemble /`,title:``,accent:t}),(0,R.jsx)(`div`,{"data-testid":`loading`,"data-resource":`workspace-${t}`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading workspace…`})]});if(i.isError)return(0,R.jsxs)(`section`,{"data-testid":`workspace-${t}`,"data-state":`error`,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[(0,R.jsx)(Bs,{prefix:`ensemble /`,title:``,accent:t}),(0,R.jsx)(`div`,{role:`alert`,"data-testid":`error-workspace-${t}`,style:{margin:`var(--density-pad) calc(var(--density-pad) * 1.6)`,padding:`var(--density-pad)`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,color:`var(--accent)`},children:i.error?.message??`Snapshot unavailable`})]});let P=i.data?.state??`online`;return(0,R.jsxs)(`section`,{"data-testid":`workspace-${t}`,"data-state":P,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[(0,R.jsx)(Bs,{prefix:`ensemble /`,title:``,accent:t,pills:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`page-pill`,children:[(0,R.jsx)(`span`,{className:`pill-dot`}),(0,R.jsx)(`span`,{className:`pill-num`,children:te}),` active`]}),(0,R.jsxs)(`span`,{className:`page-pill`,children:[(0,R.jsx)(`span`,{className:`pill-num`,children:ne}),` idle`]}),M>0&&(0,R.jsxs)(`span`,{className:`page-pill warn`,children:[`◐ `,M,` detached`]}),(0,R.jsx)(`span`,{className:`page-pill`,children:g?`paused`:v?`held`:`live`}),s&&(0,R.jsxs)(`span`,{className:`page-pill`,"data-testid":`workspace-uptime-pill`,children:[`up `,(0,R.jsx)(`span`,{className:`pill-num`,children:s})]})]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(ao,{to:`/recruit?ensemble=${encodeURIComponent(t)}`,"data-testid":`workspace-toolbar-recruit`,title:`Recruit a new player into this ensemble`,className:`btn btn-ghost btn-sm`,style:{textDecoration:`none`},children:[(0,R.jsx)(`span`,{className:`btn-icon`,children:`+`}),(0,R.jsx)(`span`,{children:`Recruit`})]}),(0,R.jsxs)(`button`,{type:`button`,"data-testid":`workspace-side-toggle`,className:`side-toggle`+(b?` is-active`:``),onClick:()=>x(e=>!e),"aria-pressed":b,"aria-label":b?`Hide roster`:`Show roster, events, schedules`,title:b?`Hide details`:`Show roster, events, schedules`,children:[(0,R.jsx)(`span`,{className:`st-icon`,children:(0,R.jsx)(eu,{})}),(0,R.jsx)(`span`,{className:`st-label`,children:b?`Hide details`:`Details`}),(0,R.jsx)(`span`,{className:`st-badge mono`,children:c.length})]})]}),subtitle:u?(0,R.jsxs)(R.Fragment,{children:[`Lineup `,(0,R.jsx)(`span`,{className:`mono`,children:`—`}),` · conducted by `,(0,R.jsx)(`span`,{className:`mono accent`,children:u}),d&&(0,R.jsxs)(R.Fragment,{children:[` on `,(0,R.jsx)(`span`,{className:`mono`,children:d})]})]}):(0,R.jsx)(`span`,{className:`dim`,children:`No conductor yet`})}),(0,R.jsx)(`div`,{className:`page-tempo`,children:(0,R.jsx)($l,{series:o,bpm:a})}),(0,R.jsxs)(`div`,{className:`workspace`+(b?``:` workspace-collapsed`),children:[b&&(0,R.jsx)(`div`,{className:`ws-side-scrim`,"data-testid":`workspace-side-scrim`,onClick:()=>x(!1),"aria-hidden":`true`}),(0,R.jsx)(`section`,{className:`workspace-main`,children:S?(0,R.jsx)(ql,{onClick:()=>C(!1),testId:`workspace-chat-stub`}):(0,R.jsxs)(`div`,{className:`panel chat`,style:{flex:1,minHeight:0},children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Maestro chat`}),(0,R.jsx)(`span`,{className:`subj display`,children:`Conductor + ensemble feed`})]}),(0,R.jsxs)(`div`,{className:`row`,children:[(0,R.jsx)(nu,{ensemble:t,paused:g,held:v}),(0,R.jsx)(ru,{ensemble:t,held:v}),(0,R.jsx)(`span`,{className:`popout-btn`,children:(0,R.jsxs)(`button`,{type:`button`,"data-testid":`workspace-popout`,className:`btn btn-ghost btn-sm`,onClick:()=>C(!0),"aria-pressed":S,title:`Pop out the chat into a floating window`,"aria-label":`Pop out chat`,children:[(0,R.jsx)(`span`,{className:`btn-icon`,children:`↗`}),(0,R.jsx)(`span`,{children:`Pop out`})]})})]})]}),(0,R.jsx)(Y,{ensemble:t,messages:p,conductorPlayerId:u,players:c,hasCompressedGap:m}),j&&(0,R.jsx)(Kl,{level:j.level,message:j.message,description:j.description,onDismiss:ee}),(0,R.jsx)(Gl,{placeholder:u?`Message ${u}`:`Recruit a player to start chatting`,disabled:!u||w.isPending,onSubmit:k,sendLabel:w.isPending?`Sending…`:`Send`,testIdPrefix:`composer`,commands:jl,players:O})]})}),b&&(0,R.jsxs)(`aside`,{className:`workspace-side`,"data-testid":`workspace-side`,"aria-label":`Roster, events, schedules`,children:[(0,R.jsx)(`div`,{className:`ws-side-sheet-grip`,"aria-hidden":`true`}),(0,R.jsx)(`button`,{type:`button`,"data-testid":`workspace-side-close`,className:`ws-side-sheet-close`,onClick:()=>x(!1),"aria-label":`Close details`,children:`×`}),(0,R.jsxs)(`div`,{className:`panel`,children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Roster`}),(0,R.jsxs)(`span`,{className:`subj display`,children:[c.length,` `,c.length===1?`player`:`players`]})]}),(0,R.jsxs)(ao,{to:`/recruit?ensemble=${encodeURIComponent(t)}`,"data-testid":`workspace-roster-recruit`,className:`btn btn-ghost btn-sm`,style:{textDecoration:`none`},title:`Recruit a new player`,children:[(0,R.jsx)(`span`,{className:`btn-icon`,children:`+`}),(0,R.jsx)(`span`,{children:`Recruit`})]})]}),(0,R.jsx)(`div`,{className:`panel-body flush roster`,"data-testid":`roster`,"aria-label":`Player roster`,children:c.length===0?(0,R.jsx)(`div`,{className:`dim`,style:{padding:`var(--density-pad)`},children:`Empty ensemble — recruit a player to begin.`}):c.map(e=>(0,R.jsx)(Xl,{player:e,selected:e.playerId===y,onSelect:e=>{W(`player.selected`,{ensemble:t,playerId:e}),n(`/ensemble/${encodeURIComponent(t)}/player/${encodeURIComponent(e)}`)}},e.playerId))})]}),(0,R.jsxs)(`div`,{className:`panel`,children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Event log`}),(0,R.jsx)(`span`,{className:`subj display`,children:`System audit trail`})]}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`ring · max 200 · messages elided`})]}),(0,R.jsx)(`div`,{className:`panel-body flush event-log`,"data-testid":`workspace-event-log`,children:c.length===0?(0,R.jsx)(`div`,{className:`dim`,style:{padding:`var(--density-pad)`,fontSize:11},children:`No events yet.`}):c.slice(0,6).map(e=>(0,R.jsxs)(`div`,{className:`event-row`,children:[(0,R.jsx)(`span`,{className:`t`,children:`·`}),(0,R.jsx)(`span`,{className:`k ${iu(e.phase)}`,children:au(e.phase)}),(0,R.jsx)(`span`,{children:e.playerId})]},e.playerId))})]}),(0,R.jsxs)(`div`,{className:`panel`,"data-testid":`workspace-schedules-panel`,children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Schedules`}),(0,R.jsx)(`span`,{className:`subj display`,children:f.length===0?`no scheduled actions`:`${f.length} active`})]}),(0,R.jsxs)(ao,{to:`/schedules`,"data-testid":`workspace-schedules-new`,className:`btn btn-ghost btn-sm`,style:{textDecoration:`none`},title:`Open the Schedules screen to add one`,children:[(0,R.jsx)(`span`,{className:`btn-icon`,children:`+`}),(0,R.jsx)(`span`,{children:`New`})]})]}),(0,R.jsx)(`div`,{className:`panel-body`,style:{paddingTop:6},children:f.length===0?(0,R.jsxs)(`div`,{"data-testid":`workspace-schedules-empty`,className:`dim`,style:{fontSize:11},children:[`No scheduled actions. Set one up via`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`/schedule`}),` in the conductor chat.`]}):(0,R.jsxs)(`ul`,{"data-testid":`workspace-schedules-list`,style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:4},children:[f.slice(0,3).map(e=>(0,R.jsx)(ou,{entry:e},e.name)),f.length>3&&(0,R.jsxs)(`li`,{className:`mono dim`,style:{fontSize:11,paddingTop:2},children:[`+ `,f.length-3,` more`]})]})})]})]})]}),S&&(0,R.jsxs)(Jl,{titlePrefix:`agent-tempo · maestro chat ·`,titleAccent:`@${t}`,onClose:()=>C(!1),testId:`workspace-popout-window`,children:[(0,R.jsx)(Y,{ensemble:t,messages:p,conductorPlayerId:u,players:c,hasCompressedGap:m}),j&&(0,R.jsx)(Kl,{level:j.level,message:j.message,description:j.description,onDismiss:ee}),(0,R.jsx)(Gl,{placeholder:u?`Message ${u}`:`Recruit a player to start chatting`,disabled:!u||w.isPending,onSubmit:k,sendLabel:w.isPending?`Sending…`:`Send`,testIdPrefix:`popout-composer`,commands:jl,players:O})]}),(0,R.jsx)(da,{})]})}function nu({ensemble:e,paused:t,held:n}){let r=yc(e),i=bc(e),a=t?i.isPending:r.isPending;return(0,R.jsxs)(`button`,{type:`button`,"data-testid":`workspace-toolbar-pause`,className:`btn btn-ghost btn-sm`,disabled:a,onClick:()=>{t?i.mutate({release:n}):r.mutate()},"aria-pressed":t,title:t?`Unpause this ensemble`:`Pause this ensemble`,children:[(0,R.jsx)(`span`,{className:`btn-icon`,children:t?`▶`:`⏸`}),(0,R.jsx)(`span`,{children:a?`…`:t?`Resume`:`Pause`})]})}function ru({ensemble:e,held:t}){let n=xc(e);return(0,R.jsx)(`button`,{type:`button`,"data-testid":`workspace-toolbar-release`,className:`btn btn-ghost btn-sm`,disabled:n.isPending||!t,onClick:()=>n.mutate(),title:t?`Release held sessions`:`No held sessions`,children:(0,R.jsx)(`span`,{children:n.isPending?`Releasing…`:`Release`})})}function iu(e){switch(e){case`attached`:case`processing`:return`ensemble`;case`draining`:case`detached`:return`phase`;case`booting`:return`heartbeat`;default:return``}}function au(e){return(e??`unknown`).toUpperCase()}function ou({entry:e}){return(0,R.jsxs)(`li`,{"data-testid":`workspace-schedule-${e.name}`,style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,gap:8,fontSize:12},children:[(0,R.jsxs)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[(0,R.jsx)(`span`,{className:`mono accent`,children:`⧗`}),` `,(0,R.jsx)(`span`,{className:`mono`,children:e.name}),(0,R.jsxs)(`span`,{className:`mono dim`,style:{marginLeft:6},children:[`→ `,e.target]})]}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11,flexShrink:0},children:su(e.nextFireAt)})]})}function su(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return`—`;let n=t-Date.now();if(n<=0)return`now`;let r=Math.floor(n/1e3);if(r<60)return`in ${r}s`;let i=Math.floor(r/60);if(i<60)return`in ${i}m`;let a=Math.floor(i/60);return a<24?`in ${a}h`:`in ${Math.floor(a/24)}d`}function cu(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`player-types`})},[]);let e=ds(),t=Ke(),n=e.data??kc,r=(0,_.useCallback)(()=>{W(`player-types.rescan`,{}),t.invalidateQueries({queryKey:ts})},[t]),i=(0,_.useCallback)(()=>{W(`player-types.new`,{})},[]);return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Player types`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Agent definitions. `,(0,R.jsx)(`span`,{className:`mono`,children:`.md`}),` with YAML frontmatter · three-tier lookup: project → user → shipped.`]}),actions:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,icon:`⟳`,"data-testid":`player-types-rescan`,onClick:r,children:`Re-scan`}),(0,R.jsx)(G,{variant:`primary`,size:`sm`,icon:`+`,"data-testid":`player-types-new`,onClick:i,children:`New type`})]})}),[r,i])),(0,R.jsx)(`section`,{"data-testid":`screen-player-types`,children:(0,R.jsx)(`div`,{className:`types-grid`,"data-testid":`player-types-grid`,children:n.map(e=>(0,R.jsx)(lu,{type:e},e.name))})})}function lu({type:e}){let t=ec(e.name),n=e.name.replace(/^tempo-/,``),r=`player-type-card-${e.name}`;return(0,R.jsxs)(`article`,{"data-testid":r,className:`panel`,style:{padding:16,gap:10,display:`flex`,flexDirection:`column`},children:[(0,R.jsxs)(`div`,{className:`row`,"data-testid":`${r}-meta-row`,style:{justifyContent:`space-between`},children:[(0,R.jsx)(Yl,{type:e.name}),(0,R.jsx)(`span`,{className:`mono dim`,"data-testid":`${r}-source`,style:{fontSize:10.5},children:e.source.toUpperCase()})]}),(0,R.jsxs)(`div`,{className:`display`,"data-testid":`${r}-name`,style:{fontSize:20},children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,style:{color:`oklch(0.82 0.12 ${t})`,fontFamily:`var(--ff-mono)`,fontSize:22,display:`inline-block`,minWidth:`1em`,textAlign:`center`,marginRight:8},children:Qs(e.name)}),n]}),(0,R.jsx)(`div`,{style:{color:`var(--text-2)`,fontSize:13,lineHeight:1.5},"data-testid":`${r}-summary`,children:e.description??`—`}),(0,R.jsxs)(`div`,{className:`row`,"data-testid":`${r}-actions-row`,style:{justifyContent:`space-between`,marginTop:`auto`},children:[(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:11},children:`— tools`}),(0,R.jsxs)(`div`,{className:`row`,children:[(0,R.jsx)(Bc,{testId:`${r}-edit`,action:`player-types.edit`,reason:`Editing player-type files requires a daemon endpoint that hasn't shipped yet.`,children:`Edit`}),(0,R.jsx)(Bc,{testId:`${r}-duplicate`,action:`player-types.duplicate`,reason:`Duplicating player-type files requires a daemon endpoint that hasn't shipped yet.`,children:`Duplicate`})]})]})]})}typeof window<`u`&&window.document&&window.document.createElement;function uu(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function du(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function fu(...e){return t=>{let n=!1,r=e.map(e=>{let r=du(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():du(e[t],null)}}}}function pu(...e){return _.useCallback(fu(...e),e)}function mu(e,t){let n=_.createContext(t),r=e=>{let{children:t,...r}=e,i=_.useMemo(()=>r,Object.values(r));return(0,R.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=_.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function hu(e,t=[]){let n=[];function r(t,r){let i=_.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=_.useMemo(()=>o,Object.values(o));return(0,R.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=_.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>_.createContext(e));return function(n){let r=n?.[e]||t;return _.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,gu(i,...t)]}function gu(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var _u=globalThis?.document?_.useLayoutEffect:()=>{},vu=_.useId||(()=>void 0),yu=0;function bu(e){let[t,n]=_.useState(vu());return _u(()=>{e||n(e=>e??String(yu++))},[e]),e||(t?`radix-${t}`:``)}var xu=_.useInsertionEffect||_u;function Su({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Cu({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=_.useRef(e!==void 0);_.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,_.useCallback(t=>{if(s){let n=wu(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Cu({defaultProp:e,onChange:t}){let[n,r]=_.useState(e),i=_.useRef(n),a=_.useRef(t);return xu(()=>{a.current=t},[t]),_.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function wu(e){return typeof e==`function`}function Tu(e){let t=Eu(e),n=_.forwardRef((e,n)=>{let{children:r,...i}=e,a=_.Children.toArray(r),o=a.find(Ou);if(o){let e=o.props.children,r=a.map(t=>t===o?_.Children.count(e)>1?_.Children.only(null):_.isValidElement(e)?e.props.children:null:t);return(0,R.jsx)(t,{...i,ref:n,children:_.isValidElement(e)?_.cloneElement(e,void 0,r):null})}return(0,R.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Eu(e){let t=_.forwardRef((e,t)=>{let{children:n,...r}=e;if(_.isValidElement(n)){let e=Au(n),i=ku(r,n.props);return n.type!==_.Fragment&&(i.ref=t?fu(t,e):e),_.cloneElement(n,i)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Du=Symbol(`radix.slottable`);function Ou(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Du}function ku(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Au(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ju=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Tu(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,R.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Mu(e,t){e&&Co.flushSync(()=>e.dispatchEvent(t))}function Nu(e){let t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...e)=>t.current?.(...e),[])}function Pu(e,t=globalThis?.document){let n=Nu(e);_.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Fu=`DismissableLayer`,Iu=`dismissableLayer.update`,Lu=`dismissableLayer.pointerDownOutside`,Ru=`dismissableLayer.focusOutside`,zu,Bu=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Vu=_.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=_.useContext(Bu),[u,d]=_.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=_.useState({}),m=pu(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=h.indexOf(g),y=u?h.indexOf(u):-1,b=l.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=Wu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!x||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),C=Z(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Pu(e=>{y===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),_.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(zu=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Gu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=zu)}},[u,f,n,l]),_.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Gu())},[u,l]),_.useEffect(()=>{let e=()=>p({});return document.addEventListener(Iu,e),()=>document.removeEventListener(Iu,e)},[]),(0,R.jsx)(ju.div,{...c,ref:m,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:uu(e.onFocusCapture,C.onFocusCapture),onBlurCapture:uu(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:uu(e.onPointerDownCapture,S.onPointerDownCapture)})});Vu.displayName=Fu;var Hu=`DismissableLayerBranch`,Uu=_.forwardRef((e,t)=>{let n=_.useContext(Bu),r=_.useRef(null),i=pu(t,r);return _.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,R.jsx)(ju.div,{...e,ref:i})});Uu.displayName=Hu;function Wu(e,t=globalThis?.document){let n=Nu(e),r=_.useRef(!1),i=_.useRef(()=>{});return _.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Ku(Lu,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Z(e,t=globalThis?.document){let n=Nu(e),r=_.useRef(!1);return _.useEffect(()=>{let e=e=>{e.target&&!r.current&&Ku(Ru,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Gu(){let e=new CustomEvent(Iu);document.dispatchEvent(e)}function Ku(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Mu(i,a):i.dispatchEvent(a)}var qu=`focusScope.autoFocusOnMount`,Ju=`focusScope.autoFocusOnUnmount`,Yu={bubbles:!1,cancelable:!0},Xu=`FocusScope`,Zu=_.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=_.useState(null),l=Nu(i),u=Nu(a),d=_.useRef(null),f=pu(t,e=>c(e)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:id(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||id(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&id(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),_.useEffect(()=>{if(s){ad.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(qu,Yu);s.addEventListener(qu,l),s.dispatchEvent(t),t.defaultPrevented||(Qu(cd(ed(s)),{select:!0}),document.activeElement===e&&id(s))}return()=>{s.removeEventListener(qu,l),setTimeout(()=>{let t=new CustomEvent(Ju,Yu);s.addEventListener(Ju,u),s.dispatchEvent(t),t.defaultPrevented||id(e??document.body,{select:!0}),s.removeEventListener(Ju,u),ad.remove(p)},0)}}},[s,l,u,p]);let m=_.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=$u(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&id(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&id(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,R.jsx)(ju.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Zu.displayName=Xu;function Qu(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(id(r,{select:t}),document.activeElement!==n)return}function $u(e){let t=ed(e);return[td(t,e),td(t.reverse(),e)]}function ed(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function td(e,t){for(let n of e)if(!nd(n,{upTo:t}))return n}function nd(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function rd(e){return e instanceof HTMLInputElement&&`select`in e}function id(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rd(e)&&t&&e.select()}}var ad=od();function od(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=sd(e,t),e.unshift(t)},remove(t){e=sd(e,t),e[0]?.resume()}}}function sd(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function cd(e){return e.filter(e=>e.tagName!==`A`)}var ld=`Portal`,ud=_.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=_.useState(!1);_u(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Co.createPortal((0,R.jsx)(ju.div,{...r,ref:t}),o):null});ud.displayName=ld;function dd(e,t){return _.useReducer((e,n)=>t[e][n]??e,e)}var fd=e=>{let{present:t,children:n}=e,r=pd(t),i=typeof n==`function`?n({present:r.isPresent}):_.Children.only(n),a=pu(r.ref,hd(i));return typeof n==`function`||r.isPresent?_.cloneElement(i,{ref:a}):null};fd.displayName=`Presence`;function pd(e){let[t,n]=_.useState(),r=_.useRef(null),i=_.useRef(e),a=_.useRef(`none`),[o,s]=dd(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return _.useEffect(()=>{let e=md(r.current);a.current=o===`mounted`?e:`none`},[o]),_u(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=md(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),_u(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=md(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=md(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:_.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function md(e){return e?.animationName||`none`}function hd(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gd=0;function _d(){_.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??vd()),document.body.insertAdjacentElement(`beforeend`,e[1]??vd()),gd++,()=>{gd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),gd--}},[])}function vd(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var yd=function(){return yd=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},yd.apply(this,arguments)};function Q(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function bd(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var xd=`right-scroll-bar-position`,Sd=`width-before-scroll-bar`,Cd=`with-scroll-bars-hidden`,wd=`--removed-body-scroll-bar-size`;function Td(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ed(e,t){var n=(0,_.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Dd=typeof window<`u`?_.useLayoutEffect:_.useEffect,Od=new WeakMap;function kd(e,t){var n=Ed(t||null,function(t){return e.forEach(function(e){return Td(e,t)})});return Dd(function(){var t=Od.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Td(e,null)}),i.forEach(function(e){r.has(e)||Td(e,a)})}Od.set(n,e)},[e]),n}function Ad(e){return e}function jd(e,t){t===void 0&&(t=Ad);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Md(e){e===void 0&&(e={});var t=jd(null);return t.options=yd({async:!0,ssr:!1},e),t}var $=function(e){var t=e.sideCar,n=Q(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return _.createElement(r,yd({},n))};$.isSideCarExport=!0;function Nd(e,t){return e.useMedium(t),$}var Pd=Md(),Fd=function(){},Id=_.forwardRef(function(e,t){var n=_.useRef(null),r=_.useState({onScrollCapture:Fd,onWheelCapture:Fd,onTouchMoveCapture:Fd}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=Q(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=kd([n,t]),w=yd(yd({},x),i);return _.createElement(_.Fragment,null,u&&_.createElement(S,{sideCar:Pd,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:b}),o?_.cloneElement(_.Children.only(s),yd(yd({},w),{ref:C})):_.createElement(y,yd({},w,{className:c,ref:C}),s))});Id.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Id.classNames={fullWidth:Sd,zeroRight:xd};var Ld,Rd=function(){if(Ld)return Ld;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function zd(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Rd();return t&&e.setAttribute(`nonce`,t),e}function Bd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vd(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Hd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zd())&&(Bd(t,n),Vd(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ud=function(){var e=Hd();return function(t,n){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Wd=function(){var e=Ud();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Gd={left:0,top:0,right:0,gap:0},Kd=function(e){return parseInt(e||``,10)||0},qd=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Kd(n),Kd(r),Kd(i)]},Jd=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Gd;var t=qd(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yd=Wd(),Xd=`data-scroll-locked`,Zd=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
18
18
|
.${Cd} {
|
|
19
19
|
overflow: hidden ${r};
|
|
@@ -59,4 +59,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
59
59
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
60
60
|
|
|
61
61
|
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},mp=`DialogDescriptionWarning`,hp=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${fp(mp).contentName}}.`;return _.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},gp=Vf,_p=Yf,vp=$f,yp=ip,bp=cp;function xp({title:e,children:t,label:n=`modal · confirm · esc to close`,confirmLabel:r,cancelLabel:i=`Cancel`,onCancel:a,onConfirm:o,pending:s=!1,testIdPrefix:c}){return(0,R.jsx)(uc,{label:n,onClose:a,testId:`${c}-modal`,children:(0,R.jsx)(dc,{title:e,testId:`${c}-dialog`,footer:(0,R.jsxs)(`div`,{className:`row`,style:{marginLeft:`auto`,gap:8},children:[(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`${c}-cancel`,onClick:a,disabled:s,children:i}),(0,R.jsx)(G,{variant:`danger`,size:`md`,"data-testid":`${c}-confirm`,onClick:o,disabled:s,children:s?`${r}…`:r})]}),children:(0,R.jsx)(`div`,{style:{fontSize:13.5,lineHeight:1.55,color:`var(--text)`},children:t})})})}var Sp=6;function Cp(){let{id:e,playerId:t}=Mi(),n=Oi(),r=ps(e??null),i=r.data?.players.find(e=>e.playerId===t),a=cs(),o=(0,_.useMemo)(()=>Ap(r.data?.chat?.messages,t),[r.data?.chat?.messages,t]),s=()=>{n(e?`/ensemble/${encodeURIComponent(e)}`:`/`)},c=`player-detail-${t}`;return(0,R.jsxs)(gp,{open:!0,onOpenChange:e=>{e||s()},children:[(0,R.jsx)(_p,{className:`sheet-overlay`,"data-testid":`${c}-backdrop`}),(0,R.jsx)(vp,{className:`sheet player-sheet`,"data-testid":c,"aria-modal":`true`,"aria-describedby":void 0,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wp,{ensemble:e??``,player:i,testIdPrefix:c,onClose:s}),(0,R.jsxs)(`div`,{className:`player-sheet-body`,children:[(0,R.jsx)(Tp,{player:i,transcript:o,testIdPrefix:c}),(0,R.jsx)(Ep,{player:i,testIdPrefix:c,adapterVersion:Pp(i,a.data)})]})]}):(0,R.jsx)(Dp,{testId:c,loading:r.isLoading,ensemble:e,playerId:t})})]})}function wp({ensemble:e,player:t,testIdPrefix:n,onClose:r}){let i=t.gitBranch??`—`,a=Oc(e),o=Tc(e),s=Dc(e),c=Ec(e),[l,u]=(0,_.useState)(!1);return(0,R.jsxs)(`div`,{className:`panel-head player-sheet-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,style:{alignItems:`center`,gap:12},children:[(0,R.jsx)(ml,{playerId:t.playerId,playerType:t.playerType,isConductor:t.isConductor,size:40}),(0,R.jsxs)(`div`,{className:`col`,style:{gap:2,minWidth:0},children:[(0,R.jsxs)(`div`,{className:`row`,children:[(0,R.jsx)(yp,{asChild:!0,children:(0,R.jsx)(`span`,{className:`subj display`,style:{fontSize:22},"data-testid":`${n}-name`,children:t.playerId})}),(0,R.jsx)(Rl,{phase:t.phase,playerId:t.playerId,showLabel:!0})]}),(0,R.jsxs)(`div`,{className:`row`,children:[t.playerType&&(0,R.jsx)(Yl,{type:t.playerType}),(0,R.jsxs)(`span`,{className:`mono dim`,style:{fontSize:11},children:[`on `,t.hostname,` · `,i]})]})]})]}),(0,R.jsxs)(`div`,{className:`row`,"data-testid":`${n}-actions`,children:[(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`${n}-action-dm`,onClick:r,children:`@DM`}),(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`${n}-action-recall`,disabled:a.isPending,onClick:()=>a.mutate({playerId:t.playerId}),children:`Recall`}),(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`${n}-action-restart`,disabled:o.isPending,onClick:()=>o.mutate({playerId:t.playerId}),children:`Restart`}),(0,R.jsx)(G,{variant:`ghost`,size:`sm`,"data-testid":`${n}-action-detach`,disabled:s.isPending,onClick:()=>s.mutate({playerId:t.playerId}),children:`Detach`}),(0,R.jsx)(G,{variant:`danger`,size:`sm`,"data-testid":`${n}-action-destroy`,disabled:c.isPending,onClick:()=>u(!0),children:`Destroy`}),(0,R.jsx)(bp,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":`Close player detail`,"data-testid":`${n}-close`,children:`✕`})})]}),l&&(0,R.jsx)(xp,{title:`Destroy ${t.playerId}?`,confirmLabel:`Destroy`,pending:c.isPending,onCancel:()=>u(!1),onConfirm:()=>{c.mutate({playerId:t.playerId},{onSettled:()=>u(!1)})},testIdPrefix:`${n}-destroy-confirm`,children:(0,R.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,R.jsxs)(`p`,{style:{margin:0},children:[`This terminates the player workflow. The session enters`,` `,(0,R.jsx)(`code`,{className:`mono`,children:`gone`}),` phase and cannot be revived.`]}),(0,R.jsxs)(`p`,{style:{margin:0,color:`var(--dim)`,fontSize:12.5},children:[`Use `,(0,R.jsx)(`code`,{className:`mono`,children:`Detach`}),` instead if you intend to restart the player later.`]})]})})]})}function Tp({player:e,transcript:t,testIdPrefix:n}){return(0,R.jsxs)(`div`,{className:`player-sheet-main`,children:[(0,R.jsx)(_l,{kicker:`transcript`,title:`Recent messages`,tight:!0}),(0,R.jsx)(`div`,{className:`col`,style:{gap:12},"data-testid":`${n}-transcript`,"data-count":t.length,children:t.length===0?(0,R.jsxs)(`p`,{className:`dim`,"data-testid":`${n}-transcript-empty`,style:{fontSize:`var(--density-fs-sm)`},children:[`No recent messages with `,e.playerId,`.`]}):t.map(e=>(0,R.jsx)(q,{m:e},e.id))})]})}function Ep({player:e,testIdPrefix:t,adapterVersion:n}){let r=(0,R.jsx)(Rl,{phase:e.phase,playerId:e.playerId,showLabel:!0}),i=e.messaging,a=e.lease;return(0,R.jsxs)(`div`,{className:`player-sheet-side`,style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,R.jsxs)(Op,{kicker:`attachment`,title:`Phase & lease`,sectionTestId:`${t}-section-phase-lease`,children:[(0,R.jsx)(kp,{testId:`${t}-kv-phase`,k:`phase`,v:r,mono:!1}),(0,R.jsx)(kp,{testId:`${t}-kv-adapter`,k:`adapter`,v:n}),(0,R.jsx)(kp,{testId:`${t}-kv-host`,k:`host`,v:e.hostname}),(0,R.jsx)(kp,{testId:`${t}-kv-heartbeat`,k:`heartbeat`,v:Gc(e.lastHeartbeatAt)}),(0,R.jsx)(kp,{testId:`${t}-kv-lease`,k:`lease`,v:qc(a?.expiresAt)}),(0,R.jsx)(kp,{testId:`${t}-kv-run-id`,k:`run id`,v:Jc(e.runId)})]}),(0,R.jsxs)(Op,{kicker:`workdir`,title:`Work`,sectionTestId:`${t}-section-work`,children:[(0,R.jsx)(kp,{testId:`${t}-kv-dir`,k:`dir`,v:e.workDir||`—`}),(0,R.jsx)(kp,{testId:`${t}-kv-branch`,k:`branch`,v:e.gitBranch??`—`}),(0,R.jsx)(kp,{testId:`${t}-kv-worktree`,k:`worktree`,v:`—`}),(0,R.jsx)(kp,{testId:`${t}-kv-part`,k:`part`,v:e.part||`—`,mono:!1})]}),(0,R.jsxs)(Op,{kicker:`traffic`,title:`Messages`,sectionTestId:`${t}-section-messages`,children:[(0,R.jsx)(kp,{testId:`${t}-kv-received`,k:`received`,v:Mp(i?.received)}),(0,R.jsx)(kp,{testId:`${t}-kv-sent`,k:`sent`,v:Mp(i?.sent)}),(0,R.jsx)(kp,{testId:`${t}-kv-outbox`,k:`outbox`,v:i?.outbox??`—`})]}),(0,R.jsx)(`span`,{hidden:!0,"data-testid":`${t}-id`,children:e.playerId}),e.playerType&&(0,R.jsx)(`span`,{hidden:!0,"data-testid":`${t}-type`,children:e.playerType}),(0,R.jsx)(`span`,{hidden:!0,"data-testid":`${t}-phase`,children:e.phase??`unknown`})]})}function Dp({testId:e,loading:t,ensemble:n,playerId:r}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`panel-head player-sheet-head`,children:[(0,R.jsx)(`div`,{className:`panel-head-title`,children:(0,R.jsx)(yp,{asChild:!0,children:(0,R.jsx)(`span`,{className:`subj display`,style:{fontSize:18},children:r??`Unknown player`})})}),(0,R.jsx)(bp,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":`Close player detail`,"data-testid":`${e}-close`,children:`✕`})})]}),(0,R.jsx)(`div`,{className:`player-sheet-body`,style:{gridTemplateColumns:`1fr`},children:(0,R.jsx)(`div`,{className:`player-sheet-main`,children:(0,R.jsx)(`p`,{"data-testid":`${e}-not-found`,role:`status`,className:`dim`,children:t?`Loading player…`:`${r} is not in the snapshot for ${n??`unknown ensemble`}.`})})})]})}function Op({kicker:e,title:t,sectionTestId:n,children:r}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(_l,{kicker:e,title:t,tight:!0}),(0,R.jsx)(`div`,{"data-testid":n,children:r})]})}function kp({testId:e,k:t,v:n,mono:r=!0}){return(0,R.jsxs)(`div`,{className:`kv`,"data-testid":e,children:[(0,R.jsx)(`span`,{className:`kv-k mono`,children:t}),(0,R.jsx)(`span`,{className:`kv-v${r?` mono`:``}`,children:n})]})}function Ap(e,t){return!e||!t?[]:e.filter(e=>e.from===t||e.to===t).slice(0,Sp).map(e=>jp(e,t)).reverse()}function jp(e,t){let n=e.from===Nl,r=e.to===Nl,i=n?`out`:r?`in`:`route`;return{id:e.id,kind:i,from:e.from===`conductor`?`conductor`:e.from,to:e.to===`conductor`?`conductor`:e.to,time:Wc(e.timestamp),body:e.text,fromIsConductor:!n&&!r&&e.role===`conductor-out`}}function Mp(e){return e===void 0?`—`:String(e)}function Np(e){return e===`claude`?`claude-code`:e}function Pp(e,t){let n=e.agentType;if(!n)return`—`;let r=Np(n),i=(t?.find(t=>t.hostname===e.hostname))?.profile?.adapterVersions?.[r];return i?`${r} · v${i}`:r}var Fp={1:`identity`,2:`type`,3:`spawn`,4:`review`},Ip=/^[a-zA-Z0-9_-]+$/,Lp=64,Rp=[`claude`,`copilot`],zp={display:`flex`,flexDirection:`column`,gap:14};function Bp(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`recruit`})},[]);let e=Oi(),[t]=fo(),n=t.get(`ensemble`)??``,r=cs(),i=ds(),a=Sc(n),o=i.data??kc,[s,c]=(0,_.useState)(1),[l,u]=(0,_.useState)(()=>({name:``,part:``,playerType:kc[0]?.name??``,agent:`claude`,workDir:``,host:``,initialMessage:``,worktree:!1,hold:!1}));(0,_.useEffect)(()=>{!l.host&&r.data&&r.data.length>0&&u(e=>({...e,host:r.data[0].hostname}))},[l.host,r.data]);let d=()=>{window.history.length>1?e(-1):e(n?`/ensemble/${encodeURIComponent(n)}`:`/`)},f=Vp(l.name),p=l.part.length>200?`Too long (≤200 chars)`:null,m=l.workDir.length===0?`Required`:null,h=s===1&&f===null&&p===null||s===2&&l.playerType.length>0||s===3&&m===null||s===4,g=a.isPending||f!==null||m!==null||l.playerType.length===0,v=()=>{if(s===4||!h)return;let e=s+1;c(e),W(`recruit-wizard.advance`,{from:s,to:e})},y=()=>{s!==1&&c(s-1)},b=()=>{g||a.mutate({name:l.name,workDir:l.workDir,agent:l.agent,playerType:l.playerType,...l.host?{host:l.host}:{},...l.initialMessage?{initialMessage:l.initialMessage}:{},...l.hold?{held:!0}:{}},{onSuccess:()=>d()})},x=(0,_.useMemo)(()=>o.map(e=>({value:e.name,name:e.name,...e.description!==void 0&&{desc:e.description},right:(0,R.jsx)(Yl,{type:e.name})})),[o]);return n?(0,R.jsx)(uc,{label:`modal · recruit a player · esc to close`,onClose:d,testId:`recruit-modal`,children:(0,R.jsxs)(dc,{testId:`screen-recruit`,title:`Recruit into @${n}`,step:s,totalSteps:4,stepLabel:Fp[s],footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`hint`,children:`↑↓ to select · Enter to confirm · Esc to cancel`}),(0,R.jsxs)(`div`,{className:`row`,style:{display:`flex`,gap:8},children:[(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`recruit-cancel`,onClick:d,children:`Cancel`}),s>1&&(0,R.jsx)(G,{variant:`ghost`,size:`md`,"data-testid":`recruit-back`,onClick:y,children:`Back`}),s<4?(0,R.jsxs)(G,{variant:`primary`,size:`md`,"data-testid":`recruit-next`,onClick:v,disabled:!h,"aria-disabled":!h,children:[`Next: `,Fp[s+1]]}):(0,R.jsx)(G,{variant:`primary`,size:`md`,"data-testid":`recruit-submit`,onClick:b,disabled:g,"aria-disabled":g,children:a.isPending?`Recruiting…`:`Recruit player`})]})]}),children:[s===1&&(0,R.jsxs)(`div`,{"data-testid":`recruit-wizard-step-1`,style:zp,children:[(0,R.jsx)(mc,{id:`recruit-input-name`,label:`Name`,error:l.name.length>0?f:null,children:(0,R.jsx)(`input`,{id:`recruit-input-name`,"data-testid":`recruit-input-name`,className:`input`,placeholder:`frontend-eng`,value:l.name,onChange:e=>u(t=>({...t,name:e.target.value}))})}),(0,R.jsx)(mc,{id:`recruit-input-part`,label:`Part`,hint:`optional`,error:p,children:(0,R.jsx)(`input`,{id:`recruit-input-part`,"data-testid":`recruit-input-part`,className:`input`,placeholder:`Implementing the schedules screen`,value:l.part,onChange:e=>u(t=>({...t,part:e.target.value}))})})]}),s===2&&(0,R.jsxs)(`div`,{"data-testid":`recruit-wizard-step-2`,style:zp,children:[(0,R.jsx)(mc,{id:`recruit-input-player-type`,label:`Player type`,hint:i.isError?`showing local catalog (daemon unreachable)`:`${o.length} available`,children:(0,R.jsx)(fc,{testId:`recruit-input-player-type`,options:x,value:l.playerType,onChange:e=>u(t=>({...t,playerType:e})),style:{maxHeight:240,overflow:`auto`}})}),(0,R.jsx)(mc,{id:`recruit-input-agent`,label:`Agent`,children:(0,R.jsx)(`select`,{id:`recruit-input-agent`,"data-testid":`recruit-input-agent`,className:`select`,value:l.agent,onChange:e=>u(t=>({...t,agent:e.target.value})),children:Rp.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))})})]}),s===3&&(0,R.jsxs)(`div`,{"data-testid":`recruit-wizard-step-3`,style:zp,children:[(0,R.jsxs)(`div`,{className:`field-grid-2`,children:[(0,R.jsx)(mc,{id:`recruit-input-workdir`,label:`Work dir`,error:l.workDir.length>0?null:m,children:(0,R.jsx)(`input`,{id:`recruit-input-workdir`,"data-testid":`recruit-input-workdir`,className:`input`,placeholder:`/repos/my-app`,value:l.workDir,onChange:e=>u(t=>({...t,workDir:e.target.value}))})}),(0,R.jsx)(mc,{id:`recruit-input-host`,label:`Host`,children:(0,R.jsx)(`select`,{id:`recruit-input-host`,"data-testid":`recruit-input-host`,className:`select`,value:l.host,onChange:e=>u(t=>({...t,host:e.target.value})),disabled:r.isLoading,children:r.data&&r.data.length>0?r.data.map(e=>(0,R.jsx)(`option`,{value:e.hostname,children:e.hostname},e.hostname)):(0,R.jsx)(`option`,{value:``,children:r.isLoading?`Loading…`:`No hosts`})})})]}),(0,R.jsx)(mc,{id:`recruit-input-message`,label:`Opening task`,hint:`optional`,children:(0,R.jsx)(`textarea`,{id:`recruit-input-message`,"data-testid":`recruit-input-message`,className:`textarea`,rows:3,placeholder:`Read CLAUDE.md and report status.`,value:l.initialMessage,onChange:e=>u(t=>({...t,initialMessage:e.target.value}))})}),(0,R.jsxs)(mc,{id:`recruit-input-options`,label:`Options`,children:[(0,R.jsx)(pc,{testId:`recruit-input-worktree`,options:[{value:`on`,label:`worktree`},{value:`off`,label:`no worktree`}],value:l.worktree?`on`:`off`,onChange:e=>u(t=>({...t,worktree:e===`on`}))}),(0,R.jsx)(pc,{testId:`recruit-input-hold`,options:[{value:`release`,label:`release immediately`},{value:`hold`,label:`hold`}],value:l.hold?`hold`:`release`,onChange:e=>u(t=>({...t,hold:e===`hold`}))})]})]}),s===4&&(0,R.jsxs)(`div`,{"data-testid":`recruit-wizard-step-4`,style:zp,children:[(0,R.jsx)(hc,{testId:`recruit-summary-name`,label:`Name`,value:l.name||`—`}),(0,R.jsx)(hc,{testId:`recruit-summary-part`,label:`Part`,value:l.part||`—`}),(0,R.jsx)(hc,{testId:`recruit-summary-player-type`,label:`Player type`,value:l.playerType}),(0,R.jsx)(hc,{testId:`recruit-summary-agent`,label:`Agent`,value:l.agent}),(0,R.jsx)(hc,{testId:`recruit-summary-workdir`,label:`Work dir`,value:l.workDir||`—`}),(0,R.jsx)(hc,{testId:`recruit-summary-host`,label:`Host`,value:l.host||`—`}),(0,R.jsx)(hc,{testId:`recruit-summary-message`,label:`Opening task`,value:l.initialMessage||`—`}),(0,R.jsx)(hc,{testId:`recruit-summary-options`,label:`Options`,value:[l.worktree?`worktree`:null,l.hold?`hold`:`release-immediately`].filter(Boolean).join(` · `)}),a.isError&&a.error&&(0,R.jsxs)(`div`,{"data-testid":`recruit-error`,role:`alert`,style:{marginTop:12,padding:`8px 12px`,background:`var(--bg-1)`,border:`1px solid var(--accent)`,borderRadius:8,fontSize:12.5,lineHeight:1.4},children:[(0,R.jsx)(`div`,{style:{color:`var(--text)`,fontWeight:500},children:`Failed to recruit ${l.name}`}),(0,R.jsx)(`div`,{style:{marginTop:3,color:`var(--dim)`},children:a.error.message})]})]})]})}):(0,R.jsx)(uc,{label:`modal · recruit · esc to close`,onClose:d,testId:`recruit-modal-empty`,children:(0,R.jsx)(dc,{testId:`screen-recruit`,title:`Recruit a player`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`hint`,children:`Pick an ensemble from the sidebar to start.`}),(0,R.jsx)(G,{variant:`primary`,size:`md`,"data-testid":`recruit-empty-back`,onClick:d,children:`Back`})]}),children:(0,R.jsxs)(`p`,{"data-testid":`recruit-missing-ensemble`,role:`alert`,className:`dim`,children:[`Pick an ensemble first. Open one from the sidebar and click`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`+ Recruit`}),` in the Workspace toolbar.`]})})})}function Vp(e){return e.length===0?`Required`:e.length>Lp?`Too long (≤${Lp} chars)`:Ip.test(e)?null:`Letters, digits, underscores, dashes only`}var Hp=[`Name`,`Target`,`Cadence`,`Kind`,`Next fire`],Up=`Schedule writes require daemon endpoints that haven’t shipped yet.`;function Wp(){(0,_.useEffect)(()=>{W(`screen.opened`,{screen:`schedules`})},[]);let e=ss(),t=e.data??[];return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Schedules`,subtitle:(0,R.jsxs)(R.Fragment,{children:[`Durable message deliveries via`,` `,(0,R.jsx)(`span`,{className:`mono`,children:`agentSchedulerWorkflow`}),`.`]}),actions:(0,R.jsx)(Bc,{testId:`schedules-action-new`,action:`schedules.new`,reason:Up,children:`+ New schedule`})}),[])),(0,R.jsx)(`section`,{"data-testid":`screen-schedules`,children:Gp(e,t)})}function Gp(e,t){return e.isError?(0,R.jsx)(`div`,{role:`alert`,"data-testid":`schedules-error`,style:Vc,children:e.error?.message??`Failed to load ensembles`}):e.isLoading?(0,R.jsx)(`div`,{"data-testid":`schedules-loading`,"data-resource":`schedules`,className:`dim`,style:{padding:`var(--density-pad)`},children:`Loading ensembles…`}):t.length===0?(0,R.jsx)(`div`,{"data-testid":`schedules-empty`,className:`dim`,style:Hc,children:`No ensembles running, so no schedules to show.`}):(0,R.jsx)(`div`,{className:`panel`,children:(0,R.jsxs)(`table`,{className:`table`,"data-testid":`schedules-table`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[Hp.map(e=>(0,R.jsx)(`th`,{children:e},e)),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:t.map(e=>(0,R.jsx)(Kp,{ensembleName:e.name},e.name))})]})})}function Kp({ensembleName:e}){let t=ps(e);if(dl(e),t.isError)return(0,R.jsx)(`tr`,{"data-testid":`schedules-error-${e}`,children:(0,R.jsxs)(`td`,{colSpan:Hp.length+1,role:`alert`,style:{color:`var(--accent)`},children:[e,`: `,t.error?.message]})});let n=t.data?.schedules??[];return n.length===0?null:(0,R.jsx)(R.Fragment,{children:n.map(t=>(0,R.jsx)(qp,{ensembleName:e,s:t},`${e}-${t.name}`))})}function qp({ensembleName:e,s:t}){let n=`schedule-row-${e}-${t.name}`,r=Yp(t);return(0,R.jsxs)(`tr`,{"data-testid":n,"data-schedule-type":t.type,children:[(0,R.jsxs)(`td`,{className:`mono`,children:[(0,R.jsx)(`span`,{className:`accent`,children:`⧗`}),` `,t.name]}),(0,R.jsx)(`td`,{"data-label":`Target`,children:(0,R.jsx)(`span`,{className:`mono`,children:t.target})}),(0,R.jsx)(`td`,{"data-label":`Cadence`,className:`mono`,style:{color:`var(--text-2)`},children:r}),(0,R.jsx)(`td`,{"data-label":`Kind`,children:(0,R.jsx)(Jp,{type:t.type})}),(0,R.jsx)(`td`,{"data-label":`Next fire`,className:`mono`,style:{color:`var(--accent)`},children:Xp(t.nextFireAt)}),(0,R.jsxs)(`td`,{style:{textAlign:`right`},children:[(0,R.jsx)(Bc,{testId:`${n}-edit`,action:`schedules.edit`,reason:Up,children:`Edit`}),(0,R.jsx)(Bc,{testId:`${n}-cancel`,action:`schedules.cancel`,reason:Up,children:`Cancel`})]})]})}function Jp({type:e}){return(0,R.jsx)(`span`,{className:`type-badge`,style:{color:e===`cron`||e===`interval`?`var(--info)`:`var(--warn)`,borderColor:`var(--rule-strong)`,background:`transparent`},children:e})}function Yp(e){return e.cronExpression?e.cronExpression:e.type===`interval`&&e.interval!==void 0?`every ${Zp(e.interval)}`:e.type===`once`?`once`:`—`}function Xp(e){if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return`—`;let n=t-Date.now();if(n<=0)return Gc(e);let r=Math.floor(n/1e3);if(r<60)return`in ${r}s`;let i=Math.floor(r/60);return i<60?`in ${i}m`:`in ${Math.floor(i/60)}h`}function Zp(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;return r<24?i?`${r}h${i}m`:`${r}h`:`${Math.floor(r/24)}d`}var Qp=`agentTempoDebug`,$p={terracotta:`Terracotta`,sage:`Sage`,plum:`Plum`},em=[4,5,6,7,8,9];function tm(){try{return window.localStorage?.getItem(Qp)===`true`}catch{return!1}}function nm(){return oc((0,_.useCallback)(()=>(0,R.jsx)(Bs,{title:`Settings`,subtitle:`Maestro client preferences and Temporal connection.`}),[])),(0,R.jsxs)(`section`,{"data-testid":`settings-page`,className:`settings-grid`,children:[(0,R.jsx)(rm,{}),(0,R.jsx)(im,{}),(0,R.jsx)(am,{}),(0,R.jsx)(om,{}),(0,R.jsx)(sm,{})]})}function rm(){let{data:e,isLoading:t,isError:n}=os(),r=t?`…`:n?`?`:e?.namespace??`?`,i=t?`…`:n?`?`:e?.taskQueue??`?`,a=t?`…`:n?`?`:e?.version??`?`;return(0,R.jsxs)(`div`,{className:`panel settings-panel`,"data-testid":`settings-panel-connection`,children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Connection`}),(0,R.jsx)(`span`,{className:`subj display`,children:`Temporal namespace`})]}),(0,R.jsxs)(`span`,{className:`page-pill`,"data-testid":`settings-connection-status`,children:[(0,R.jsx)(`span`,{className:`pill-dot`}),` connected`]})]}),(0,R.jsxs)(`div`,{className:`panel-body`,children:[(0,R.jsx)(um,{k:`namespace`,v:r,mono:!0}),(0,R.jsx)(um,{k:`address`,v:`localhost:7233`,mono:!0}),(0,R.jsx)(um,{k:`task queue`,v:i,mono:!0}),(0,R.jsx)(um,{k:`version`,v:a,mono:!0}),(0,R.jsx)(um,{k:`tls`,v:`off`,mono:!0}),(0,R.jsx)(um,{k:`auth`,v:`—`,mono:!0})]})]})}function im(){return(0,R.jsxs)(`div`,{className:`panel settings-panel`,"data-testid":`settings-panel-profile`,children:[(0,R.jsx)(`div`,{className:`panel-head`,children:(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Profile`}),(0,R.jsx)(`span`,{className:`subj display`,children:`Your maestro identity`})]})}),(0,R.jsxs)(`div`,{className:`panel-body`,children:[(0,R.jsx)(um,{k:`display name`,v:`—`,mono:!0}),(0,R.jsx)(um,{k:`email`,v:`—`,mono:!0}),(0,R.jsx)(um,{k:`default lineup`,v:`tempo-dev-team`,mono:!0}),(0,R.jsx)(um,{k:`default host`,v:`—`,mono:!0})]})]})}function am(){return(0,R.jsxs)(`div`,{className:`panel settings-panel`,"data-testid":`settings-panel-notifications`,children:[(0,R.jsx)(`div`,{className:`panel-head`,children:(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Notifications`}),(0,R.jsx)(`span`,{className:`subj display`,children:`When the maestro should ping you`})]})}),(0,R.jsxs)(`div`,{className:`panel-body`,children:[(0,R.jsx)(um,{k:`player detached`,v:`banner`}),(0,R.jsx)(um,{k:`conductor handoff`,v:`banner + sound`}),(0,R.jsx)(um,{k:`schedule fired`,v:`silent`}),(0,R.jsx)(um,{k:`recruit failed`,v:`banner`})]})]})}function om(){let e=Rs(e=>e.theme),t=Rs(e=>e.density),n=Rs(e=>e.accent),r=Rs(e=>e.setTheme),i=Rs(e=>e.setDensity),a=Rs(e=>e.setAccent);return(0,R.jsxs)(`div`,{className:`panel settings-panel`,"data-testid":`settings-panel-appearance`,children:[(0,R.jsxs)(`div`,{className:`panel-head`,children:[(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Appearance`}),(0,R.jsx)(`span`,{className:`subj display`,children:`Theme & density`})]}),(0,R.jsx)(`span`,{className:`mono dim`,style:{fontSize:10},children:`see Tweaks ⌥T`})]}),(0,R.jsxs)(`div`,{className:`panel-body`,children:[(0,R.jsx)(dm,{label:`Theme`,htmlFor:`settings-theme`,children:(0,R.jsxs)(`select`,{id:`settings-theme`,"data-testid":`settings-theme-select`,value:e,onChange:e=>r(e.target.value),style:lm,children:[(0,R.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,R.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,R.jsx)(dm,{label:`Density: ${t}`,htmlFor:`settings-density`,children:(0,R.jsx)(`input`,{id:`settings-density`,"data-testid":`settings-density-range`,type:`range`,min:em[0],max:em[em.length-1],step:1,value:t,onChange:e=>{let t=Number(e.target.value);t>=4&&t<=9&&i(t)}})}),(0,R.jsx)(dm,{label:`Accent`,htmlFor:`settings-accent`,children:(0,R.jsx)(`select`,{id:`settings-accent`,"data-testid":`settings-accent-select`,value:n,onChange:e=>a(e.target.value),style:lm,children:Object.keys($p).map(e=>(0,R.jsx)(`option`,{value:e,children:$p[e]},e))})}),(0,R.jsx)(fm,{})]})]})}function sm(){return(0,R.jsxs)(`div`,{className:`panel settings-panel`,"data-testid":`settings-panel-danger-zone`,style:{gridColumn:`1 / -1`},children:[(0,R.jsx)(`div`,{className:`panel-head`,children:(0,R.jsxs)(`div`,{className:`panel-head-title`,children:[(0,R.jsx)(`span`,{className:`h`,children:`Danger zone`}),(0,R.jsx)(`span`,{className:`subj display`,children:`Destructive actions`})]})}),(0,R.jsxs)(`div`,{className:`panel-body`,children:[(0,R.jsxs)(`div`,{className:`settings-danger-row`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{style:{fontWeight:500},children:`Disband all ensembles`}),(0,R.jsx)(`div`,{className:`mono dim`,style:{fontSize:11},children:`Stops all running players and clears outboxes. Sessions can be resumed later.`})]}),(0,R.jsx)(Bc,{testId:`settings-disband-all`,action:`settings.disband-all`,reason:"Disbanding every ensemble at once requires a daemon endpoint that hasn't shipped yet. Use `agent-tempo down --destroy` from the CLI for now.",children:`Disband all`})]}),(0,R.jsxs)(`div`,{className:`settings-danger-row`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{style:{fontWeight:500},children:`Reset client state`}),(0,R.jsx)(`div`,{className:`mono dim`,style:{fontSize:11},children:`Clears local preferences, recently-used loadouts, and chat drafts.`})]}),(0,R.jsx)(cm,{})]})]})]})}function cm(){let e=Rs(e=>e.setTheme),t=Rs(e=>e.setDensity),n=Rs(e=>e.setAccent);return(0,R.jsx)(`button`,{type:`button`,"data-testid":`settings-reset`,className:`btn btn-ghost btn-sm`,onClick:()=>{e(js),t(6),n(Ms);try{window.localStorage?.removeItem(Qp)}catch{}W(`settings.reset`,{})},children:`Reset`})}var lm={background:`var(--bg-2)`,color:`var(--text)`,border:`1px solid var(--rule)`,borderRadius:6,padding:`6px 10px`,fontFamily:`var(--ff-display)`,fontSize:13,minWidth:140};function um({k:e,v:t,mono:n=!1}){return(0,R.jsxs)(`div`,{className:`kv`,children:[(0,R.jsx)(`span`,{className:`kv-k`,children:e}),(0,R.jsx)(`span`,{className:`kv-v`+(n?` mono`:``),title:String(t),children:t})]})}function dm({label:e,htmlFor:t,children:n}){return(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:16,padding:`6px 0`},children:[(0,R.jsx)(`label`,{htmlFor:t,style:{fontFamily:`var(--ff-display)`,fontSize:13},children:e}),n]})}function fm(){let[e,t]=(0,_.useState)(()=>tm());return(0,R.jsx)(dm,{label:`Debug logs`,htmlFor:`settings-debug`,children:(0,R.jsx)(`input`,{id:`settings-debug`,"data-testid":`settings-debug-checkbox`,type:`checkbox`,checked:e,onChange:e=>{let n=e.target.checked;t(n);try{n?window.localStorage?.setItem(Qp,`true`):window.localStorage?.removeItem(Qp)}catch{}W(`settings.changed`,{key:`debug`,value:n})}})})}function pm(){return(0,R.jsxs)(ys,{children:[(0,R.jsx)(xs,{}),(0,R.jsx)(lc,{children:(0,R.jsx)(da,{})})]})}var mm=[{path:`/`,element:(0,R.jsx)(pm,{}),children:[{index:!0,element:(0,R.jsx)(bl,{})},{path:`ensemble/:id`,element:(0,R.jsx)(tu,{}),children:[{path:`player/:playerId`,element:(0,R.jsx)(Cp,{})}]},{path:`create-ensemble`,element:(0,R.jsx)(Ic,{})},{path:`recruit`,element:(0,R.jsx)(Bp,{})},{path:`hosts`,element:(0,R.jsx)(Xc,{})},{path:`orphans`,element:(0,R.jsx)(sl,{})},{path:`schedules`,element:(0,R.jsx)(Wp,{})},{path:`loadouts`,element:(0,R.jsx)(nl,{})},{path:`player-types`,element:(0,R.jsx)(cu,{})},{path:`settings`,element:(0,R.jsx)(nm,{})},...[],{path:`*`,element:(0,R.jsx)(ua,{to:`/`,replace:!0})}]}];function hm(){return eo(mm,{basename:`/dashboard`})}function gm(e){let t=/\/ensemble\/[^/]+\/player\/([^/]+)/.exec(e);if(t)try{return decodeURIComponent(t[1])}catch{return t[1]}}function _m(){if(!(typeof window>`u`))try{let e=new URL(window.location.href);if(!e.searchParams.has(`pair`))return;e.searchParams.delete(`pair`),window.history.replaceState({},``,`${e.pathname}${e.search}${e.hash}`)}catch{}}function vm(e){return e.slice(0,8)}function ym(){if(typeof window>`u`)return null;let e=null;try{e=new URL(window.location.href).searchParams.get(`pair`)}catch{}return _m(),e&&e.length>0?e:null}function bm(e={}){let[t,n]=(0,_.useState)({kind:`idle`}),r=(0,_.useRef)(!1);return(0,_.useEffect)(()=>{if(r.current)return;r.current=!0;let t=ym();if(!t)return;let i=vm(t);n({kind:`consuming`,tokenPrefix:i}),W(`pair.consume-start`,{tokenPrefix:i});let a=e.baseUrl??(typeof window<`u`?window.location.origin:``),o=e.fetchImpl??fetch.bind(globalThis),s=`${a}/dashboard/api/pair/${encodeURIComponent(t)}`,c=!1;return(async()=>{try{let e=await o(s,{method:`GET`,headers:{Accept:`application/json`},credentials:`same-origin`});if(!e.ok){let t=`http-${e.status}`;c||(n({kind:`failed`,tokenPrefix:i,reason:t}),W(`pair.consume-failed`,{tokenPrefix:i,reason:t},`warn`));return}let t=await e.json();if(!t.bearer||typeof t.bearer!=`string`){c||(n({kind:`failed`,tokenPrefix:i,reason:`malformed-response`}),W(`pair.consume-failed`,{tokenPrefix:i,reason:`malformed-response`},`warn`));return}c||(zo(t.bearer),n({kind:`paired`,tokenPrefix:i}),W(`pair.consume-success`,{tokenPrefix:i}))}catch(e){let t=e instanceof Error?e.message:String(e);c||(n({kind:`failed`,tokenPrefix:i,reason:t}),W(`pair.consume-failed`,{tokenPrefix:i,reason:t},`warn`))}})(),()=>{c=!0}},[]),t}var xm=new Ue({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function Sm({router:e}={}){let t=(0,_.useMemo)(()=>e??hm(),[e]);return bm(),(0,_.useEffect)(()=>{W(`app-mounted`,{pr:`pr-8`,issue:`#340`})},[]),(0,R.jsx)(qe,{client:xm,children:(0,R.jsx)(wo,{router:t})})}var Cm=document.getElementById(`root`);if(!Cm)throw Error(`#root element missing from index.html`);(0,v.createRoot)(Cm).render((0,R.jsx)(_.StrictMode,{children:(0,R.jsx)(Sm,{})}));
|
|
62
|
-
//# sourceMappingURL=index-
|
|
62
|
+
//# sourceMappingURL=index-BbR7zIdK.js.map
|