@tt-a1i/hive 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.en.md +23 -1
  3. package/README.md +10 -1
  4. package/dist/src/cli/team.js +19 -2
  5. package/dist/src/server/agent-run-bootstrap.d.ts +6 -1
  6. package/dist/src/server/agent-run-bootstrap.js +5 -2
  7. package/dist/src/server/agent-run-starter.d.ts +6 -7
  8. package/dist/src/server/agent-run-starter.js +18 -4
  9. package/dist/src/server/agent-runtime-contract.d.ts +10 -0
  10. package/dist/src/server/agent-runtime-stop-run.d.ts +1 -1
  11. package/dist/src/server/agent-runtime-stop-run.js +4 -1
  12. package/dist/src/server/agent-runtime.d.ts +2 -1
  13. package/dist/src/server/agent-runtime.js +10 -5
  14. package/dist/src/server/agent-startup-instructions.d.ts +7 -8
  15. package/dist/src/server/agent-startup-instructions.js +6 -4
  16. package/dist/src/server/agent-stdin-dispatcher.d.ts +20 -7
  17. package/dist/src/server/agent-stdin-dispatcher.js +22 -10
  18. package/dist/src/server/command-preset-defaults.js +12 -0
  19. package/dist/src/server/feature-flags.d.ts +42 -0
  20. package/dist/src/server/feature-flags.js +24 -0
  21. package/dist/src/server/hive-team-guidance.d.ts +4 -3
  22. package/dist/src/server/hive-team-guidance.js +17 -16
  23. package/dist/src/server/post-start-input-writer.js +2 -2
  24. package/dist/src/server/preset-launch-support.js +2 -1
  25. package/dist/src/server/recovery-summary.d.ts +5 -6
  26. package/dist/src/server/recovery-summary.js +3 -2
  27. package/dist/src/server/report-outbox-store.d.ts +36 -0
  28. package/dist/src/server/report-outbox-store.js +33 -0
  29. package/dist/src/server/restart-policy-support.d.ts +4 -5
  30. package/dist/src/server/restart-policy.d.ts +5 -1
  31. package/dist/src/server/restart-policy.js +51 -33
  32. package/dist/src/server/routes-settings.js +3 -3
  33. package/dist/src/server/routes-tasks.js +23 -0
  34. package/dist/src/server/routes-workspaces.js +5 -0
  35. package/dist/src/server/runtime-restart-policy.d.ts +3 -3
  36. package/dist/src/server/runtime-restart-policy.js +2 -3
  37. package/dist/src/server/runtime-store-contract.d.ts +3 -0
  38. package/dist/src/server/runtime-store-helpers.d.ts +2 -0
  39. package/dist/src/server/runtime-store-helpers.js +14 -9
  40. package/dist/src/server/runtime-store-workflows.js +8 -0
  41. package/dist/src/server/runtime-store.js +1 -0
  42. package/dist/src/server/session-capture.d.ts +6 -0
  43. package/dist/src/server/session-capture.js +32 -0
  44. package/dist/src/server/sqlite-schema-v22.d.ts +2 -0
  45. package/dist/src/server/sqlite-schema-v22.js +27 -0
  46. package/dist/src/server/sqlite-schema.d.ts +1 -1
  47. package/dist/src/server/sqlite-schema.js +19 -1
  48. package/dist/src/server/task-deps.d.ts +32 -0
  49. package/dist/src/server/task-deps.js +40 -0
  50. package/dist/src/server/tasks-file-watcher.d.ts +6 -7
  51. package/dist/src/server/tasks-file-watcher.js +3 -2
  52. package/dist/src/server/tasks-file.d.ts +2 -1
  53. package/dist/src/server/tasks-file.js +3 -2
  54. package/dist/src/server/team-authz.d.ts +1 -1
  55. package/dist/src/server/team-authz.js +1 -0
  56. package/dist/src/server/team-operations.d.ts +7 -1
  57. package/dist/src/server/team-operations.js +81 -19
  58. package/dist/src/server/webhook-notifier.d.ts +34 -0
  59. package/dist/src/server/webhook-notifier.js +47 -0
  60. package/dist/src/server/workflow-cli-policy.d.ts +1 -1
  61. package/dist/src/server/workflow-cli-policy.js +1 -1
  62. package/dist/src/server/workflow-output-schema.d.ts +18 -0
  63. package/dist/src/server/workflow-output-schema.js +41 -0
  64. package/dist/src/server/workflow-runner.js +12 -2
  65. package/dist/src/shared/types.d.ts +2 -2
  66. package/package.json +1 -1
  67. package/web/dist/assets/{AddWorkerDialog-CcC-7kgG.js → AddWorkerDialog-BRUxpa3f.js} +2 -2
  68. package/web/dist/assets/{AddWorkspaceDialog-BDpOTfmt.js → AddWorkspaceDialog-D56x5JCb.js} +1 -1
  69. package/web/dist/assets/{FirstRunWizard-BYX_ocQn.js → FirstRunWizard-BFVaMIsE.js} +1 -1
  70. package/web/dist/assets/{MarketplaceDrawer-DUxSk7db.js → MarketplaceDrawer-DeEZ35dN.js} +1 -1
  71. package/web/dist/assets/{WhatsNewDialog-B_RlCXcV.js → WhatsNewDialog-CHkZeINH.js} +1 -1
  72. package/web/dist/assets/{WorkerModal-D9-7YfZZ.js → WorkerModal-BBCuMLIa.js} +1 -1
  73. package/web/dist/assets/{WorkspaceTaskDrawer-BCKoF7qc.js → WorkspaceTaskDrawer-CpZHAcj1.js} +1 -1
  74. package/web/dist/assets/WorkspaceTerminalPanels-7If2mDyp.js +1 -0
  75. package/web/dist/assets/index-5zh61jMg.css +1 -0
  76. package/web/dist/assets/index-CxNL0O-C.js +73 -0
  77. package/web/dist/cli-icons/hermes.png +0 -0
  78. package/web/dist/index.html +2 -2
  79. package/web/dist/sw.js +1 -1
  80. package/web/dist/assets/WorkspaceTerminalPanels-Dq8y91t2.js +0 -1
  81. package/web/dist/assets/index-BiOvKIVw.css +0 -1
  82. package/web/dist/assets/index-DMRUklT3.js +0 -73
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Outbound completion/attention webhook. The user supplies a single URL (stored
3
+ * in app_state); the runtime POSTs a small JSON payload on server-side lifecycle
4
+ * events so they can wire their own Slack / Discord / Feishu / ntfy / Telegram
5
+ * without Hive taking on a relay, mobile app, or account system.
6
+ *
7
+ * Best-effort by design: fire-and-forget with a timeout, all errors swallowed —
8
+ * a flaky webhook must never block or fail a report/exit. This is a personal,
9
+ * local-trust setting: the URL is whatever the user typed, and a 127.0.0.1-bound
10
+ * runtime can reach localhost/intranet, so we only enforce an http(s) scheme and
11
+ * leave the rest to the operator (documented in the Settings UI).
12
+ */
13
+ export declare const WEBHOOK_URL_KEY = "notifications.webhook-url";
14
+ export type WebhookEventType = 'report_received' | 'agent_stopped' | 'workflow_finished';
15
+ export interface WebhookEvent {
16
+ type: WebhookEventType;
17
+ workspaceId: string;
18
+ agentId?: string;
19
+ agentName?: string;
20
+ summary?: string;
21
+ at: number;
22
+ }
23
+ export declare const readWebhookUrl: (raw: string | null | undefined) => string | null;
24
+ interface WebhookNotifierOptions {
25
+ getUrl: () => string | null;
26
+ /** Injectable for tests; defaults to global fetch. */
27
+ fetchImpl?: typeof fetch;
28
+ timeoutMs?: number;
29
+ }
30
+ export declare const createWebhookNotifier: ({ getUrl, fetchImpl, timeoutMs, }: WebhookNotifierOptions) => {
31
+ notify: (event: WebhookEvent) => void;
32
+ };
33
+ export type WebhookNotifier = ReturnType<typeof createWebhookNotifier>;
34
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Outbound completion/attention webhook. The user supplies a single URL (stored
3
+ * in app_state); the runtime POSTs a small JSON payload on server-side lifecycle
4
+ * events so they can wire their own Slack / Discord / Feishu / ntfy / Telegram
5
+ * without Hive taking on a relay, mobile app, or account system.
6
+ *
7
+ * Best-effort by design: fire-and-forget with a timeout, all errors swallowed —
8
+ * a flaky webhook must never block or fail a report/exit. This is a personal,
9
+ * local-trust setting: the URL is whatever the user typed, and a 127.0.0.1-bound
10
+ * runtime can reach localhost/intranet, so we only enforce an http(s) scheme and
11
+ * leave the rest to the operator (documented in the Settings UI).
12
+ */
13
+ export const WEBHOOK_URL_KEY = 'notifications.webhook-url';
14
+ export const readWebhookUrl = (raw) => {
15
+ const trimmed = raw?.trim();
16
+ return trimmed ? trimmed : null;
17
+ };
18
+ const isHttpUrl = (raw) => {
19
+ try {
20
+ const url = new URL(raw);
21
+ return url.protocol === 'http:' || url.protocol === 'https:';
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ };
27
+ export const createWebhookNotifier = ({ getUrl, fetchImpl = fetch, timeoutMs = 5000, }) => {
28
+ const notify = (event) => {
29
+ const url = readWebhookUrl(getUrl());
30
+ if (!url || !isHttpUrl(url))
31
+ return;
32
+ const controller = new AbortController();
33
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
34
+ void fetchImpl(url, {
35
+ method: 'POST',
36
+ headers: { 'content-type': 'application/json' },
37
+ body: JSON.stringify(event),
38
+ signal: controller.signal,
39
+ })
40
+ .catch(() => {
41
+ // Personal-trust, best-effort: a dead or slow webhook must not affect
42
+ // the report/exit path that triggered it.
43
+ })
44
+ .finally(() => clearTimeout(timer));
45
+ };
46
+ return { notify };
47
+ };
@@ -14,7 +14,7 @@
14
14
  */
15
15
  /** Canonical CLI set — mirrors the built-in command preset ids
16
16
  * (see command-preset-defaults.ts). The allowlist is a subset of these. */
17
- export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini"];
17
+ export declare const CANONICAL_WORKFLOW_CLIS: readonly ["claude", "codex", "opencode", "gemini", "hermes"];
18
18
  export type WorkflowCli = (typeof CANONICAL_WORKFLOW_CLIS)[number];
19
19
  export declare const WORKFLOW_CLI_POLICY_KEY = "workflow.cli-policy";
20
20
  export interface WorkflowCliPolicy {
@@ -14,7 +14,7 @@
14
14
  */
15
15
  /** Canonical CLI set — mirrors the built-in command preset ids
16
16
  * (see command-preset-defaults.ts). The allowlist is a subset of these. */
17
- export const CANONICAL_WORKFLOW_CLIS = ['claude', 'codex', 'opencode', 'gemini'];
17
+ export const CANONICAL_WORKFLOW_CLIS = ['claude', 'codex', 'opencode', 'gemini', 'hermes'];
18
18
  export const WORKFLOW_CLI_POLICY_KEY = 'workflow.cli-policy';
19
19
  export const DEFAULT_WORKFLOW_CLI_POLICY = {
20
20
  default: 'claude',
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Opt-in structured output for the workflow DSL `agent()` call. When a script
3
+ * passes `outputSchema`, the runner appends an instruction asking the worker to
4
+ * end its report with a fenced ```json block, then parses that block so the
5
+ * script gets an object instead of brittle free-text. Kept deliberately LIGHT:
6
+ * no schema validation library, no retry — the keys are advisory, and a parse
7
+ * miss falls back to `{ text }` in the runner so a script can always branch on
8
+ * a missing field (the documented safe-default discipline).
9
+ */
10
+ /**
11
+ * Extract and parse the LAST fenced json block in a report. Workers often emit
12
+ * a reasoning block then a final answer block, so the last one wins. Returns
13
+ * null on no block / invalid JSON / a non-object payload (so the caller's
14
+ * `?? { text }` fallback fires) rather than throwing.
15
+ */
16
+ export declare const extractJsonBlock: (text: string) => Record<string, unknown> | null;
17
+ /** The terse instruction appended to the worker prompt when a schema is set. */
18
+ export declare const buildSchemaInstruction: (schema: Record<string, unknown>) => string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Opt-in structured output for the workflow DSL `agent()` call. When a script
3
+ * passes `outputSchema`, the runner appends an instruction asking the worker to
4
+ * end its report with a fenced ```json block, then parses that block so the
5
+ * script gets an object instead of brittle free-text. Kept deliberately LIGHT:
6
+ * no schema validation library, no retry — the keys are advisory, and a parse
7
+ * miss falls back to `{ text }` in the runner so a script can always branch on
8
+ * a missing field (the documented safe-default discipline).
9
+ */
10
+ /**
11
+ * Extract and parse the LAST fenced json block in a report. Workers often emit
12
+ * a reasoning block then a final answer block, so the last one wins. Returns
13
+ * null on no block / invalid JSON / a non-object payload (so the caller's
14
+ * `?? { text }` fallback fires) rather than throwing.
15
+ */
16
+ export const extractJsonBlock = (text) => {
17
+ const matches = [...text.matchAll(/```(?:json)?[ \t]*\r?\n?([\s\S]*?)```/g)];
18
+ const last = matches.at(-1)?.[1];
19
+ if (last === undefined)
20
+ return null;
21
+ try {
22
+ const parsed = JSON.parse(last.trim());
23
+ return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
24
+ ? parsed
25
+ : null;
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ };
31
+ /** The terse instruction appended to the worker prompt when a schema is set. */
32
+ export const buildSchemaInstruction = (schema) => {
33
+ const keys = Object.keys(schema);
34
+ const keyList = keys.length > 0 ? keys.join(', ') : '(see the task)';
35
+ return [
36
+ '',
37
+ 'When you are done, end your report with a single fenced ```json block as the LAST thing in your message.',
38
+ `That JSON object should use these keys: ${keyList}.`,
39
+ 'If you cannot determine a field, omit it — the caller treats a missing field as the safe default.',
40
+ ].join('\n');
41
+ };
@@ -3,6 +3,7 @@ import { cpus } from 'node:os';
3
3
  import { dirname, join } from 'node:path';
4
4
  import { assertWindowsSafeFilename } from './windows-filename.js';
5
5
  import { resolveWorkflowCli } from './workflow-cli-policy.js';
6
+ import { buildSchemaInstruction, extractJsonBlock } from './workflow-output-schema.js';
6
7
  import { loadWorkflowScriptFile, loadWorkflowScriptSource } from './workflow-script-loader.js';
7
8
  import { getWorkflowAgentId } from './workspace-store-support.js';
8
9
  // TIER 2 #2 + #11 — runtime caps. Match Claude Code's documented caps
@@ -18,7 +19,7 @@ const isBuiltInWorkerRole = (value) => BUILT_IN_WORKER_ROLES.has(value);
18
19
  const buildModelArgs = (_cli, model) => {
19
20
  if (!model?.trim())
20
21
  return [];
21
- /* All four supported CLIs (claude / codex / opencode / gemini) accept
22
+ /* All supported CLIs (claude / codex / opencode / gemini / hermes) accept
22
23
  `--model <id>` as a positional flag. Keeping the mapping centralised
23
24
  here so future CLI quirks (e.g. opencode wanting `-m` instead) can
24
25
  be patched without touching the runner body. */
@@ -150,7 +151,10 @@ export const createWorkflowRunner = (deps) => {
150
151
  spawnedWorkers.push(worker.id);
151
152
  try {
152
153
  await store.startAgent(workspaceId, worker.id, { hivePort });
153
- const dispatch = await store.dispatchTaskByWorkerName(workspaceId, name, prompt, {
154
+ const dispatchPrompt = opts.outputSchema
155
+ ? prompt + buildSchemaInstruction(opts.outputSchema)
156
+ : prompt;
157
+ const dispatch = await store.dispatchTaskByWorkerName(workspaceId, name, dispatchPrompt, {
154
158
  fromAgentId: workflowAgentId,
155
159
  hivePort,
156
160
  workflowRunId: run.id,
@@ -159,6 +163,12 @@ export const createWorkflowRunner = (deps) => {
159
163
  label: opts.label ?? name,
160
164
  });
161
165
  const report = await awaiter.awaitReport(dispatch.id, opts.timeoutMs);
166
+ // Structured output: hand back the parsed object, or { text } on a
167
+ // parse miss so the script can still branch (treating an absent field
168
+ // as the safe default).
169
+ if (opts.outputSchema) {
170
+ return extractJsonBlock(report.text) ?? { text: report.text };
171
+ }
162
172
  return report.text;
163
173
  }
164
174
  finally {
@@ -27,13 +27,13 @@ export interface TeamListItem {
27
27
  status: AgentStatus;
28
28
  pendingTaskCount: number;
29
29
  /**
30
- * Last raw line printed to the worker's PTY. Surfaced on the worker card for UI hints only —
30
+ * Last raw line printed to the worker's PTY. Kept as non-authoritative UI context only —
31
31
  * not a worker reply. Real replies arrive as [Hive 系统消息] entries on orchestrator stdin.
32
32
  */
33
33
  lastPtyLine?: string;
34
34
  /**
35
35
  * Built-in command preset this worker was launched with (`claude` / `codex` /
36
- * `opencode` / `gemini`). Drives the worker card's CLI logo (§6.4). Undefined
36
+ * `opencode` / `gemini` / `hermes`). Drives the worker card's CLI logo (§6.4). Undefined
37
37
  * when the worker was created without picking a preset, or when the launch
38
38
  * config row references a custom command — in that case the UI falls back to
39
39
  * the role-letter avatar.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tt-a1i/hive",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Browser-native hive-mind for CLI coding agents — Claude Code, Codex, Gemini, and OpenCode collaborate as real PTY processes via a team protocol.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.30.3",
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-DUxSk7db.js","assets/index-DMRUklT3.js","assets/index-BiOvKIVw.css"])))=>i.map(i=>d[i]);
2
- import{c as W,j as e,u as j,r as c,e as z,k as M,n as X,A as Y,B as Z,F as R,G as ee,H as te,a as ae,P as re,O as se,C as ne,b as le,D as oe,d as ie,_ as de}from"./index-DMRUklT3.js";const ce=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ue=W("bookmark-plus",ce);const xe=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],me=W("dices",xe);const pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],he=W("search",pe);const fe=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],be=W("square-terminal",fe);const ge=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],ke=W("store",ge),ve=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],F=t=>`role.${t}`,C=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),je=({active:t,spec:a,onSelect:l})=>{const{t:n}=j();return e.jsxs("button",{type:"button",onClick:l,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(R,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(F(a.value))}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},ye=({onRoleChange:t,workerRole:a})=>{const{t:l}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:l("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(n=>e.jsx(je,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},Ne=({customTemplates:t,disabledReason:a,onDeleteTemplate:l,onSelect:n,selectedTemplateId:i})=>{const{t:o}=j(),[f,x]=c.useState(!1),[m,u]=c.useState(""),[b,k]=c.useState(null),y=c.useRef(null),g=c.useMemo(()=>t.find(r=>r.id===i)??null,[t,i]),v=c.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(s=>s.name.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)):t},[t,m]);return c.useEffect(()=>{if(!f)return;const r=h=>{h.key==="Escape"&&x(!1)},s=h=>{const w=y.current;w&&!w.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",s),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",s)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:g?g.name:o("addWorker.templatePickPlaceholder")}),e.jsx(z,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(he,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const s=r.id===i;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":s,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:s?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(X,{size:14,"aria-hidden":!0})})]},r.id)})}),i!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),l(r)}})]})},Ce=({canSaveAsTemplate:t,modified:a,onChange:l,onReset:n,onSaveAsTemplate:i,roleDescription:o,templateBusy:f,workerRole:x,writeDisabledReason:m})=>{const{t:u}=j(),[b,k]=c.useState(!1),[y,g]=c.useState(!1),[v,r]=c.useState("");return c.useEffect(()=>{(x==="custom"||a)&&k(!0)},[a,x]),c.useEffect(()=>{t||(g(!1),r(""))},[t]),e.jsxs("details",{open:b,onToggle:s=>k(s.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-sm text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(F(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t&&!y?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:s=>{s.preventDefault(),s.stopPropagation(),g(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ue,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:s=>{s.preventDefault(),s.stopPropagation(),n()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:s=>l(s.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:v,onChange:s=>r(s.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!v.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const s=v.trim();if(s)try{await i(s),g(!1),r("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{g(!1),r("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:l,logoPresetId:n,notFound:i=!1,testId:o,onSelect:f})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(ee,{commandPresetId:n,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:l}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,i?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},We=({active:t,preset:a,onSelect:l})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:l}),we=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>e.jsx(Se,{commandPresetId:t,commandPresets:a,onPresetChange:l}),Se=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.map(i=>e.jsx(We,{active:t===i.id,preset:i,onSelect:()=>l(i.id)},i.id)),e.jsx(D,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>l("")})]})]})},ze=({onChange:t,value:a})=>{const{t:l}=j(),n=a.trim();return e.jsxs("details",{className:"group flex flex-col gap-2",children:[e.jsx("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 shrink-0 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:l("addWorker.startupCommand")}),n?e.jsxs("span",{className:"truncate text-sm text-ter",children:["· ",l("addWorker.startupOverrides")]}):null]})}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:i=>t(i.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:l("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Me=c.lazy(()=>de(()=>import("./MarketplaceDrawer-DUxSk7db.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:l=!1,customTemplates:n,onApplyMarketplaceImport:i,onClose:o,onDeleteTemplate:f,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:g,onStartupCommandChange:v,onSubmit:r,onTemplateChange:s,roleDescription:h,roleDescriptionDefault:w,selectedTemplateId:_,startupCommand:P,templateBusy:I,workerName:A,workerRole:S,writeDisabledReason:N})=>{const{t:d}=j(),L=te(),[B,O]=c.useState(!1),[q,H]=c.useState(!1),K=c.useMemo(()=>new Set(n.map(p=>p.name)),[n]),V=p=>{i(p),L.show({kind:"success",message:d("marketplace.imported",{name:p.name})})},G=p=>{p||o()},Q=h!==w,E=t.find(p=>p.id===a),$=P.trim(),J=()=>N||(A.trim()?!a&&!$?d("addWorker.pickCliOrStartup"):E?.available===!1&&!$?d("addWorker.unavailable",{name:E.displayName}):h.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),U=p=>{const T=J();if(T){p.preventDefault(),L.show({kind:"warning",message:T});return}r(p)};return e.jsxs(ae,{open:!0,onOpenChange:G,children:[e.jsxs(re,{children:[e.jsx(se,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ne,{"data-testid":"add-worker-content",className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:e.jsxs("form",{onSubmit:U,"aria-label":d("addWorker.title"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx(le,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(oe,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-y-auto px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(C,{children:d("addWorker.name")}),e.jsx(ie,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(me,{size:12,"aria-hidden":!0}),d("addWorker.random")]})})]}),e.jsx("input",{autoFocus:!0,value:A,onChange:p=>x(p.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input"})]}),e.jsx(ye,{workerRole:S,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{H(!0),O(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-md border px-3 py-1.5 text-xs text-sec outline-none transition-colors focus-visible:ring-2",style:{background:"var(--bg-0)",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(ke,{size:14,"aria-hidden":!0}),d("marketplace.openFromAddWorker")]}),S==="custom"?e.jsx(Ne,{customTemplates:n,disabledReason:N,onDeleteTemplate:f,onSelect:s,selectedTemplateId:_}):null,e.jsx(Ce,{canSaveAsTemplate:S==="custom"&&!_&&h.trim().length>0,modified:Q,onChange:b,onReset:k,onSaveAsTemplate:g,roleDescription:h,templateBusy:I,workerRole:S,writeDisabledReason:N}),e.jsx(we,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(ze,{value:P,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:"icon-btn","data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:l||!!N,title:N??void 0,className:"icon-btn icon-btn--primary","data-testid":"add-worker-submit",children:d(l?"addWorker.creating":"addWorker.create")})]})]})})})]}),q?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Me,{open:B,onClose:()=>O(!1),onImport:V,importedNames:K})}):null]})},Ae=Object.freeze(Object.defineProperty({__proto__:null,AddWorkerDialog:_e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,he as S};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-DeEZ35dN.js","assets/index-CxNL0O-C.js","assets/index-5zh61jMg.css"])))=>i.map(i=>d[i]);
2
+ import{c as W,j as e,u as j,r as c,e as z,k as M,n as X,A as Y,B as Z,F as R,G as ee,H as te,a as ae,P as re,O as se,C as ne,b as le,D as oe,d as ie,_ as de}from"./index-CxNL0O-C.js";const ce=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ue=W("bookmark-plus",ce);const xe=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],me=W("dices",xe);const pe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],he=W("search",pe);const fe=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],be=W("square-terminal",fe);const ge=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],ke=W("store",ge),ve=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],F=t=>`role.${t}`,C=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),je=({active:t,spec:a,onSelect:l})=>{const{t:n}=j();return e.jsxs("button",{type:"button",onClick:l,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(R,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:n(F(a.value))}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},ye=({onRoleChange:t,workerRole:a})=>{const{t:l}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:l("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(n=>e.jsx(je,{active:a===n.value,spec:n,onSelect:()=>t(n.value)},n.value))})]})},Ne=({customTemplates:t,disabledReason:a,onDeleteTemplate:l,onSelect:n,selectedTemplateId:i})=>{const{t:o}=j(),[f,x]=c.useState(!1),[m,u]=c.useState(""),[b,k]=c.useState(null),y=c.useRef(null),g=c.useMemo(()=>t.find(r=>r.id===i)??null,[t,i]),v=c.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(s=>s.name.toLowerCase().includes(r)||s.description.toLowerCase().includes(r)):t},[t,m]);return c.useEffect(()=>{if(!f)return;const r=h=>{h.key==="Escape"&&x(!1)},s=h=>{const w=y.current;w&&!w.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",s),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",s)}},[f]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":f,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:g?g.name:o("addWorker.templatePickPlaceholder")}),e.jsx(z,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),f?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(he,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const s=r.id===i;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":s,"data-testid":`role-template-option-${r.id}`,onClick:()=>{n(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:s?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(X,{size:14,"aria-hidden":!0})})]},r.id)})}),i!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{n(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),l(r)}})]})},Ce=({canSaveAsTemplate:t,modified:a,onChange:l,onReset:n,onSaveAsTemplate:i,roleDescription:o,templateBusy:f,workerRole:x,writeDisabledReason:m})=>{const{t:u}=j(),[b,k]=c.useState(!1),[y,g]=c.useState(!1),[v,r]=c.useState("");return c.useEffect(()=>{(x==="custom"||a)&&k(!0)},[a,x]),c.useEffect(()=>{t||(g(!1),r(""))},[t]),e.jsxs("details",{open:b,onToggle:s=>k(s.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-sm text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(F(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-1",children:[t&&!y?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:s=>{s.preventDefault(),s.stopPropagation(),g(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ue,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:s=>{s.preventDefault(),s.stopPropagation(),n()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:s=>l(s.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:v,onChange:s=>r(s.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:f||!v.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const s=v.trim();if(s)try{await i(s),g(!1),r("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{g(!1),r("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:l,logoPresetId:n,notFound:i=!1,testId:o,onSelect:f})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(be,{size:13})});return e.jsxs("button",{type:"button",onClick:f,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(ee,{commandPresetId:n,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:l}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,i?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(M,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},We=({active:t,preset:a,onSelect:l})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:l}),we=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>e.jsx(Se,{commandPresetId:t,commandPresets:a,onPresetChange:l}),Se=({commandPresetId:t,commandPresets:a,onPresetChange:l})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{children:n("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:n("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.map(i=>e.jsx(We,{active:t===i.id,preset:i,onSelect:()=>l(i.id)},i.id)),e.jsx(D,{active:t==="",command:n("addWorker.genericCommand"),displayName:n("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>l("")})]})]})},ze=({onChange:t,value:a})=>{const{t:l}=j(),n=a.trim();return e.jsxs("details",{className:"group flex flex-col gap-2",children:[e.jsx("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none",children:e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(z,{size:12,"aria-hidden":!0,className:"-rotate-90 shrink-0 text-ter transition-transform duration-150 group-open:rotate-0"}),e.jsx(C,{children:l("addWorker.startupCommand")}),n?e.jsxs("span",{className:"truncate text-sm text-ter",children:["· ",l("addWorker.startupOverrides")]}):null]})}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:i=>t(i.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:l("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Me=c.lazy(()=>de(()=>import("./MarketplaceDrawer-DeEZ35dN.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:l=!1,customTemplates:n,onApplyMarketplaceImport:i,onClose:o,onDeleteTemplate:f,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:g,onStartupCommandChange:v,onSubmit:r,onTemplateChange:s,roleDescription:h,roleDescriptionDefault:w,selectedTemplateId:_,startupCommand:P,templateBusy:I,workerName:A,workerRole:S,writeDisabledReason:N})=>{const{t:d}=j(),L=te(),[B,O]=c.useState(!1),[q,H]=c.useState(!1),K=c.useMemo(()=>new Set(n.map(p=>p.name)),[n]),V=p=>{i(p),L.show({kind:"success",message:d("marketplace.imported",{name:p.name})})},G=p=>{p||o()},Q=h!==w,E=t.find(p=>p.id===a),$=P.trim(),J=()=>N||(A.trim()?!a&&!$?d("addWorker.pickCliOrStartup"):E?.available===!1&&!$?d("addWorker.unavailable",{name:E.displayName}):h.trim()?null:d("addWorker.emptyInstructions"):d("addWorker.enterName")),U=p=>{const T=J();if(T){p.preventDefault(),L.show({kind:"warning",message:T});return}r(p)};return e.jsxs(ae,{open:!0,onOpenChange:G,children:[e.jsxs(re,{children:[e.jsx(se,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ne,{"data-testid":"add-worker-content",className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:e.jsxs("form",{onSubmit:U,"aria-label":d("addWorker.title"),className:"flex flex-col",children:[e.jsxs("div",{className:"flex shrink-0 flex-col gap-0.5 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx(le,{className:"text-lg font-semibold text-pri",children:d("addWorker.title")}),e.jsx(oe,{className:"text-sm text-ter",children:d("addWorker.description",{command:"team send"})})]}),e.jsxs("div",{className:"flex flex-col gap-4 overflow-y-auto px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx(C,{children:d("addWorker.name")}),e.jsx(ie,{label:d("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":d("addWorker.randomAria"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(me,{size:12,"aria-hidden":!0}),d("addWorker.random")]})})]}),e.jsx("input",{autoFocus:!0,value:A,onChange:p=>x(p.target.value),placeholder:d("addWorker.namePlaceholder"),className:"input"})]}),e.jsx(ye,{workerRole:S,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{H(!0),O(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-md border px-3 py-1.5 text-xs text-sec outline-none transition-colors focus-visible:ring-2",style:{background:"var(--bg-0)",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(ke,{size:14,"aria-hidden":!0}),d("marketplace.openFromAddWorker")]}),S==="custom"?e.jsx(Ne,{customTemplates:n,disabledReason:N,onDeleteTemplate:f,onSelect:s,selectedTemplateId:_}):null,e.jsx(Ce,{canSaveAsTemplate:S==="custom"&&!_&&h.trim().length>0,modified:Q,onChange:b,onReset:k,onSaveAsTemplate:g,roleDescription:h,templateBusy:I,workerRole:S,writeDisabledReason:N}),e.jsx(we,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(ze,{value:P,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:"icon-btn","data-testid":"add-worker-cancel",children:d("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:l||!!N,title:N??void 0,className:"icon-btn icon-btn--primary","data-testid":"add-worker-submit",children:d(l?"addWorker.creating":"addWorker.create")})]})]})})})]}),q?e.jsx(c.Suspense,{fallback:null,children:e.jsx(Me,{open:B,onClose:()=>O(!1),onImport:V,importedNames:K})}):null]})},Ae=Object.freeze(Object.defineProperty({__proto__:null,AddWorkerDialog:_e},Symbol.toStringTag,{value:"Module"}));export{Ae as A,he as S};
@@ -1 +1 @@
1
- import{c as V,u as D,r as l,j as e,q as ce,e as B,k as Z,a as T,P as I,O as q,C as U,b as W,D as K,f as A,s as le,t as oe,v as ie,X as de,w as pe,x as xe,T as ue}from"./index-DMRUklT3.js";import{d as Q}from"./path-join-7MR1s7b1.js";const me=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],he=V("arrow-up",me);const fe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],be=V("folder-search",fe);const ge=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",ge);const ke=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],ee=V("git-branch",ke),te=t=>{const r=t.trim();if(r.length<2)return r;const i=r[0],s=r[r.length-1];return(i==='"'||i==="'")&&i===s?r.slice(1,-1):r},se=({error:t,onChange:r,presets:i,value:s})=>{const{t:p}=D(),[x,c]=l.useState(!1),a=l.useRef(null),d=i.find(o=>o.id===s),n=s==="",k=d?[d.command,...d.args].join(" ").trim():p(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=d?.displayName??(n?p("workspace.preset.generic"):"Claude Code (CC)"),j=i.length===0&&!n;return l.useEffect(()=>{if(!x)return;const o=f=>{a.current?.contains(f.target)||c(!1)},m=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",m)}},[x]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:p("workspace.preset.label")}),e.jsxs("div",{ref:a,className:"cli-select group relative",children:[e.jsx(ce,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":x,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":s,disabled:j,onClick:()=>c(o=>!o),children:g}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),x&&i.length>0?e.jsxs("div",{role:"listbox","aria-label":p("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[i.map(o=>{const m=o.id===s,f=o.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${o.id}`,className:"cli-select__option",onClick:()=>{r(o.id),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[o.displayName,f?p("workspace.preset.notFoundSuffix"):""]})]},o.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{r(""),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:p("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),ve=({probe:t,pasteFallbackDefault:r=!1,commandPresetError:i,commandPresetId:s,commandPresets:p,onCancel:x,onCommandPresetChange:c,onCreate:a,onOpenServerBrowse:d})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,o]=l.useState(g),[m,f]=l.useState(""),[N,S]=l.useState(r),[C,P]=l.useState(!1),[_,h]=l.useState("");l.useEffect(()=>{o(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const w=te(m),u=N&&w.length>0?w:t?.path??"",y=_.trim(),E=p.find(v=>v.id===s),F=p.length===0&&!i,L=!s&&y.length===0,z=E?.available===!1&&y.length===0,H=L?n("workspace.preset.genericRequiresStartup"):z?n("workspace.preset.notInstalled",{name:E.displayName}):null,$=j.trim().length>0&&u.length>0&&!F&&!L&&!z,O=()=>{$&&a({commandPresetId:s||null,name:j.trim(),path:u,...y?{startupCommand:y}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&x(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(ee,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>o(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(se,{error:i??H,onChange:c,presets:p,value:s}),e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[C?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:x,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:O,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},je=({entries:t,error:r,loading:i,onNavigate:s,onSelect:p,selected:x})=>{const{t:c}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:i?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("common.loading")}):r?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:r}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("workspace.browse.empty")}):e.jsx("ul",{children:t.map(a=>{const d=x===a.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${a.name}`,onClick:()=>p(a.path),onDoubleClick:()=>s(a.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:d?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:a.is_git_repository?e.jsx(ee,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:a.name}),a.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:c("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${a.name}`,onClick:()=>s(a.path),"aria-label":c("workspace.browse.openAria",{name:a.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},a.path)})})})},we=({probe:t,suggestedName:r,onSuggestedNameChange:i})=>{const{t:s}=D(),p=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:s("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:s("workspace.git.short",{branch:t.current_branch??s("workspace.git.detached")})}):p?e.jsx("span",{className:"text-ter text-xs",children:s("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:s("workspace.field.name")}),e.jsx("input",{type:"text",value:r,onChange:x=>i(x.target.value),disabled:!p,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ye=t=>{const i=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),s=i[i.length-1];return s?`~ (${s})`:t},Ne=(t,r)=>{if(!r||!t)return[];const i=[{label:ye(r),path:r}];if(t===r)return i;const s=r.replace(/[\\/]+$/,""),p=t.startsWith(s)?t.slice(s.length).replace(/^[\\/]+/,""):"";if(!p)return i;const x=Q(s),c=p.split(/[\\/]/).filter(Boolean);let a=s;for(const d of c)a=`${a}${x}${d}`,i.push({label:d,path:a});return i},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Ce=t=>{const[r,i]=l.useState(J),[s,p]=l.useState(!1),[x,c]=l.useState(null),[a,d]=l.useState(null),n=l.useRef(0),k=l.useRef(0),g=l.useCallback(async o=>{const m=++n.current;p(!0);try{const f=await le(o);if(n.current!==m)return;i(f),f.ok&&c(f.current_path)}catch{}finally{n.current===m&&p(!1)}},[]);l.useEffect(()=>{if(!t){n.current++,k.current++,i(J),c(null),d(null);return}g("")},[t,g]),l.useEffect(()=>{if(!x){d(null);return}const o=++k.current;oe(x).then(m=>{k.current===o&&d(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[x]);const j=l.useCallback(o=>{c(o)},[]);return{browse:r,loading:s,navigate:g,probe:a,selectEntry:j,selected:x}},_e=({commandPresetError:t,commandPresetId:r,commandPresets:i,onClose:s,onCommandPresetChange:p,onCreate:x,open:c})=>{const{t:a}=D(),{browse:d,loading:n,navigate:k,probe:g,selectEntry:j,selected:o}=Ce(c),[m,f]=l.useState(""),[N,S]=l.useState(!1),[C,P]=l.useState(""),[_,h]=l.useState(!1),[w,u]=l.useState("");if(l.useEffect(()=>{c||(f(""),S(!1),P(""),h(!1),u(""))},[c]),l.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!c)return null;const y=Ne(d.current_path,d.root_path),E=Q(d.current_path||d.root_path),F=te(C),L=i.find(b=>b.id===r),z=w.trim(),H=i.length===0&&!t,$=!r&&z.length===0,O=L?.available===!1&&z.length===0,v=$?a("workspace.preset.genericRequiresStartup"):O?a("workspace.preset.notInstalled",{name:L.displayName}):null,ae=m.trim().length>0&&(g?.is_dir===!0||N&&F.length>0)&&!H&&!$&&!O,re=()=>{const b=N&&F.length>0?F:g?.path??"";b&&x({commandPresetId:r||null,name:m.trim(),path:b,...z?{startupCommand:z}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&s(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:a("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:d.root_path?a("workspace.browse.root",{path:d.root_path}):a("workspace.browse.rootLoading")})]}),e.jsx(ie,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":a("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(de,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":a("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>d.parent_path?k(d.parent_path):null,disabled:!d.parent_path,"aria-label":a("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(he,{size:12,"aria-hidden":!0})," ",a("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),y.map((b,Y)=>{const ne=Y===y.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:E}):null,ne?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(je,{entries:d.entries,error:d.ok?null:d.error,loading:n,onNavigate:k,onSelect:j,selected:o})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(we,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(se,{error:t??v,onChange:p,presets:i,value:r}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.startup"),e.jsx("input",{type:"text",value:w,onChange:b=>u(b.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:a("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:C,onChange:b=>P(b.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:s,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:re,disabled:!ae,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},R="claude",Se=t=>t.some(r=>r.id===R&&r.available)?R:t.find(r=>r.available)?.id??t[0]?.id??R,ze=({trigger:t,onClose:r,onCreate:i})=>{const{t:s}=D(),p=l.useRef(s);l.useEffect(()=>{p.current=s},[s]);const[x,c]=l.useState({kind:"idle"}),[a,d]=l.useState([]),[n,k]=l.useState(R),[g,j]=l.useState(null),o=l.useRef({error:null,id:R,presets:[]}),m=l.useRef(r);l.useEffect(()=>{m.current=r},[r]),l.useEffect(()=>{if(t===0)return;let h=!1;j(null);const w=pe().then(u=>{if(h)return;const y=u.some(E=>E.id===o.current.id&&E.available)?o.current.id:Se(u);o.current={error:null,id:y,presets:u},d(u),k(y)}).catch(()=>{if(h)return;const u=p.current("workspace.preset.loadFailed");o.current={error:u,id:R,presets:[]},d([]),k(R),j(u)});return c({kind:"picking"}),xe().then(async u=>{if(await w,!h){if(u.canceled){if(u.error){c({kind:"error",message:u.error});return}c({kind:"idle"}),m.current();return}if(!u.supported){c({kind:"confirm",probe:null,pasteDefault:!0});return}if(!u.probe?.ok||!u.probe.is_dir){c({kind:"error",message:u.error??p.current("workspace.error.outsideSandbox")});return}c({kind:"confirm",probe:u.probe,pasteDefault:!1})}}).catch(u=>{if(h)return;const y=u instanceof Error?u.message:p.current("workspace.error.pickerFailed");c({kind:"error",message:y})}),()=>{h=!0}},[t]);const f=()=>{c({kind:"idle"}),r()},N=h=>{Promise.resolve(i(h)).then(()=>c({kind:"idle"})).catch(w=>{const u=w instanceof Error?w.message:s("workspace.error.createFailed");c({kind:"error",title:s("workspace.error.createTitle"),message:u})})},S=h=>{o.current={...o.current,id:h},k(h)},C=a.length>0||g?a:o.current.presets,P=n===""?"":C.length>0&&!C.some(h=>h.id===n&&h.available)?o.current.id:n,_=g??o.current.error;if(x.kind==="idle")return null;if(x.kind==="picking"){const h=()=>c({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:w=>!w&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:s("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(be,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:s("workspace.picking.message")})]})]})]})})}return x.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ue,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:x.title??s("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:x.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:s("common.close")}),e.jsx("button",{type:"button",onClick:()=>c({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:s("workspace.error.pastePathInstead")})]})]})})]})}):x.kind==="browse"?e.jsx(_e,{commandPresetError:_,commandPresetId:P,commandPresets:C,onClose:f,onCommandPresetChange:S,onCreate:N,open:!0}):e.jsx(ve,{commandPresetError:_,commandPresetId:P,commandPresets:C,pasteFallbackDefault:x.pasteDefault,probe:x.probe,onCancel:f,onCommandPresetChange:S,onCreate:N,onOpenServerBrowse:()=>c({kind:"browse"})})};export{ze as AddWorkspaceDialog};
1
+ import{c as V,u as D,r as l,j as e,q as ce,e as B,k as Z,a as T,P as I,O as q,C as U,b as W,D as K,f as A,s as le,t as oe,v as ie,X as de,w as pe,x as xe,T as ue}from"./index-CxNL0O-C.js";import{d as Q}from"./path-join-7MR1s7b1.js";const me=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],he=V("arrow-up",me);const fe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],be=V("folder-search",fe);const ge=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",ge);const ke=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],ee=V("git-branch",ke),te=t=>{const r=t.trim();if(r.length<2)return r;const i=r[0],s=r[r.length-1];return(i==='"'||i==="'")&&i===s?r.slice(1,-1):r},se=({error:t,onChange:r,presets:i,value:s})=>{const{t:p}=D(),[x,c]=l.useState(!1),a=l.useRef(null),d=i.find(o=>o.id===s),n=s==="",k=d?[d.command,...d.args].join(" ").trim():p(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=d?.displayName??(n?p("workspace.preset.generic"):"Claude Code (CC)"),j=i.length===0&&!n;return l.useEffect(()=>{if(!x)return;const o=f=>{a.current?.contains(f.target)||c(!1)},m=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",m)}},[x]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:p("workspace.preset.label")}),e.jsxs("div",{ref:a,className:"cli-select group relative",children:[e.jsx(ce,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":x,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":s,disabled:j,onClick:()=>c(o=>!o),children:g}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),x&&i.length>0?e.jsxs("div",{role:"listbox","aria-label":p("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[i.map(o=>{const m=o.id===s,f=o.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${o.id}`,className:"cli-select__option",onClick:()=>{r(o.id),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[o.displayName,f?p("workspace.preset.notFoundSuffix"):""]})]},o.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{r(""),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:p("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),ve=({probe:t,pasteFallbackDefault:r=!1,commandPresetError:i,commandPresetId:s,commandPresets:p,onCancel:x,onCommandPresetChange:c,onCreate:a,onOpenServerBrowse:d})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,o]=l.useState(g),[m,f]=l.useState(""),[N,S]=l.useState(r),[C,P]=l.useState(!1),[_,h]=l.useState("");l.useEffect(()=>{o(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const w=te(m),u=N&&w.length>0?w:t?.path??"",y=_.trim(),E=p.find(v=>v.id===s),F=p.length===0&&!i,L=!s&&y.length===0,z=E?.available===!1&&y.length===0,H=L?n("workspace.preset.genericRequiresStartup"):z?n("workspace.preset.notInstalled",{name:E.displayName}):null,$=j.trim().length>0&&u.length>0&&!F&&!L&&!z,O=()=>{$&&a({commandPresetId:s||null,name:j.trim(),path:u,...y?{startupCommand:y}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&x(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(ee,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>o(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(se,{error:i??H,onChange:c,presets:p,value:s}),e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[C?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:x,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:O,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},je=({entries:t,error:r,loading:i,onNavigate:s,onSelect:p,selected:x})=>{const{t:c}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:i?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("common.loading")}):r?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:r}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("workspace.browse.empty")}):e.jsx("ul",{children:t.map(a=>{const d=x===a.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${a.name}`,onClick:()=>p(a.path),onDoubleClick:()=>s(a.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:d?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:a.is_git_repository?e.jsx(ee,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:a.name}),a.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:c("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${a.name}`,onClick:()=>s(a.path),"aria-label":c("workspace.browse.openAria",{name:a.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},a.path)})})})},we=({probe:t,suggestedName:r,onSuggestedNameChange:i})=>{const{t:s}=D(),p=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:s("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:s("workspace.git.short",{branch:t.current_branch??s("workspace.git.detached")})}):p?e.jsx("span",{className:"text-ter text-xs",children:s("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:s("workspace.field.name")}),e.jsx("input",{type:"text",value:r,onChange:x=>i(x.target.value),disabled:!p,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ye=t=>{const i=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),s=i[i.length-1];return s?`~ (${s})`:t},Ne=(t,r)=>{if(!r||!t)return[];const i=[{label:ye(r),path:r}];if(t===r)return i;const s=r.replace(/[\\/]+$/,""),p=t.startsWith(s)?t.slice(s.length).replace(/^[\\/]+/,""):"";if(!p)return i;const x=Q(s),c=p.split(/[\\/]/).filter(Boolean);let a=s;for(const d of c)a=`${a}${x}${d}`,i.push({label:d,path:a});return i},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Ce=t=>{const[r,i]=l.useState(J),[s,p]=l.useState(!1),[x,c]=l.useState(null),[a,d]=l.useState(null),n=l.useRef(0),k=l.useRef(0),g=l.useCallback(async o=>{const m=++n.current;p(!0);try{const f=await le(o);if(n.current!==m)return;i(f),f.ok&&c(f.current_path)}catch{}finally{n.current===m&&p(!1)}},[]);l.useEffect(()=>{if(!t){n.current++,k.current++,i(J),c(null),d(null);return}g("")},[t,g]),l.useEffect(()=>{if(!x){d(null);return}const o=++k.current;oe(x).then(m=>{k.current===o&&d(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[x]);const j=l.useCallback(o=>{c(o)},[]);return{browse:r,loading:s,navigate:g,probe:a,selectEntry:j,selected:x}},_e=({commandPresetError:t,commandPresetId:r,commandPresets:i,onClose:s,onCommandPresetChange:p,onCreate:x,open:c})=>{const{t:a}=D(),{browse:d,loading:n,navigate:k,probe:g,selectEntry:j,selected:o}=Ce(c),[m,f]=l.useState(""),[N,S]=l.useState(!1),[C,P]=l.useState(""),[_,h]=l.useState(!1),[w,u]=l.useState("");if(l.useEffect(()=>{c||(f(""),S(!1),P(""),h(!1),u(""))},[c]),l.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!c)return null;const y=Ne(d.current_path,d.root_path),E=Q(d.current_path||d.root_path),F=te(C),L=i.find(b=>b.id===r),z=w.trim(),H=i.length===0&&!t,$=!r&&z.length===0,O=L?.available===!1&&z.length===0,v=$?a("workspace.preset.genericRequiresStartup"):O?a("workspace.preset.notInstalled",{name:L.displayName}):null,ae=m.trim().length>0&&(g?.is_dir===!0||N&&F.length>0)&&!H&&!$&&!O,re=()=>{const b=N&&F.length>0?F:g?.path??"";b&&x({commandPresetId:r||null,name:m.trim(),path:b,...z?{startupCommand:z}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&s(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:a("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:d.root_path?a("workspace.browse.root",{path:d.root_path}):a("workspace.browse.rootLoading")})]}),e.jsx(ie,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":a("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(de,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":a("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>d.parent_path?k(d.parent_path):null,disabled:!d.parent_path,"aria-label":a("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(he,{size:12,"aria-hidden":!0})," ",a("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),y.map((b,Y)=>{const ne=Y===y.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:E}):null,ne?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(je,{entries:d.entries,error:d.ok?null:d.error,loading:n,onNavigate:k,onSelect:j,selected:o})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(we,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(se,{error:t??v,onChange:p,presets:i,value:r}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.startup"),e.jsx("input",{type:"text",value:w,onChange:b=>u(b.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:a("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:C,onChange:b=>P(b.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:s,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:re,disabled:!ae,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},R="claude",Se=t=>t.some(r=>r.id===R&&r.available)?R:t.find(r=>r.available)?.id??t[0]?.id??R,ze=({trigger:t,onClose:r,onCreate:i})=>{const{t:s}=D(),p=l.useRef(s);l.useEffect(()=>{p.current=s},[s]);const[x,c]=l.useState({kind:"idle"}),[a,d]=l.useState([]),[n,k]=l.useState(R),[g,j]=l.useState(null),o=l.useRef({error:null,id:R,presets:[]}),m=l.useRef(r);l.useEffect(()=>{m.current=r},[r]),l.useEffect(()=>{if(t===0)return;let h=!1;j(null);const w=pe().then(u=>{if(h)return;const y=u.some(E=>E.id===o.current.id&&E.available)?o.current.id:Se(u);o.current={error:null,id:y,presets:u},d(u),k(y)}).catch(()=>{if(h)return;const u=p.current("workspace.preset.loadFailed");o.current={error:u,id:R,presets:[]},d([]),k(R),j(u)});return c({kind:"picking"}),xe().then(async u=>{if(await w,!h){if(u.canceled){if(u.error){c({kind:"error",message:u.error});return}c({kind:"idle"}),m.current();return}if(!u.supported){c({kind:"confirm",probe:null,pasteDefault:!0});return}if(!u.probe?.ok||!u.probe.is_dir){c({kind:"error",message:u.error??p.current("workspace.error.outsideSandbox")});return}c({kind:"confirm",probe:u.probe,pasteDefault:!1})}}).catch(u=>{if(h)return;const y=u instanceof Error?u.message:p.current("workspace.error.pickerFailed");c({kind:"error",message:y})}),()=>{h=!0}},[t]);const f=()=>{c({kind:"idle"}),r()},N=h=>{Promise.resolve(i(h)).then(()=>c({kind:"idle"})).catch(w=>{const u=w instanceof Error?w.message:s("workspace.error.createFailed");c({kind:"error",title:s("workspace.error.createTitle"),message:u})})},S=h=>{o.current={...o.current,id:h},k(h)},C=a.length>0||g?a:o.current.presets,P=n===""?"":C.length>0&&!C.some(h=>h.id===n&&h.available)?o.current.id:n,_=g??o.current.error;if(x.kind==="idle")return null;if(x.kind==="picking"){const h=()=>c({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:w=>!w&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:s("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(be,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:s("workspace.picking.message")})]})]})]})})}return x.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ue,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:x.title??s("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:x.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:s("common.close")}),e.jsx("button",{type:"button",onClick:()=>c({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:s("workspace.error.pastePathInstead")})]})]})})]})}):x.kind==="browse"?e.jsx(_e,{commandPresetError:_,commandPresetId:P,commandPresets:C,onClose:f,onCommandPresetChange:S,onCreate:N,open:!0}):e.jsx(ve,{commandPresetError:_,commandPresetId:P,commandPresets:C,pasteFallbackDefault:x.pasteDefault,probe:x.probe,onCancel:f,onCommandPresetChange:S,onCreate:N,onOpenServerBrowse:()=>c({kind:"browse"})})};export{ze as AddWorkspaceDialog};
@@ -1 +1 @@
1
- import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-DMRUklT3.js";const R=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],k=f("hexagon",R),w=({open:o,onClose:r,onAddWorkspace:x,onTryDemo:d})=>{const{t:s}=h(),[n,l]=j.useState(0),u=t=>{t||(l(0),r())},i=(t=!0)=>{l(0),r(t)},a=n===2;return e.jsx(b,{open:o,onOpenChange:u,children:e.jsxs(N,{children:[e.jsx(v,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(y,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[n===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(k,{size:32})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),n>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:m,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:m}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{x(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{d(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{w as FirstRunWizard};
1
+ import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-CxNL0O-C.js";const R=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],k=f("hexagon",R),w=({open:o,onClose:r,onAddWorkspace:x,onTryDemo:d})=>{const{t:s}=h(),[n,l]=j.useState(0),u=t=>{t||(l(0),r())},i=(t=!0)=>{l(0),r(t)},a=n===2;return e.jsx(b,{open:o,onOpenChange:u,children:e.jsxs(N,{children:[e.jsx(v,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(y,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[n===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(k,{size:32})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),n>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:m,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:m}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{x(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{d(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{w as FirstRunWizard};