commandmate 0.19.0 → 0.20.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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +252 -245
- package/.next/app-path-routes-manifest.json +31 -31
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +12 -12
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route.js +5 -3
- package/.next/server/app/api/app/update/route.js.nft.json +1 -1
- package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/app/update-check/route.js.nft.json +1 -1
- package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/conversation/route.js +1 -1
- package/.next/server/app/api/assistant/conversation/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/current-output/route.js +1 -1
- package/.next/server/app/api/assistant/current-output/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/messages/route.js +1 -1
- package/.next/server/app/api/assistant/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/session/route.js +1 -1
- package/.next/server/app/api/assistant/session/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/start/route.js +1 -1
- package/.next/server/app/api/assistant/start/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/terminal/route.js +1 -1
- package/.next/server/app/api/assistant/terminal/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/tools/route.js +1 -1
- package/.next/server/app/api/assistant/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/route.js +1 -1
- package/.next/server/app/api/auth/login/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/route.js +1 -1
- package/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/status/route.js +1 -1
- package/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/route.js +1 -1
- package/.next/server/app/api/daily-summary/route.js.nft.json +1 -1
- package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/status/route.js +1 -1
- package/.next/server/app/api/daily-summary/status/route.js.nft.json +1 -1
- package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route.js.nft.json +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/route.js +1 -1
- package/.next/server/app/api/external-apps/route.js.nft.json +1 -1
- package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/browse/route.js +2 -2
- package/.next/server/app/api/fs/browse/route.js.nft.json +1 -1
- package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/recent-paths/route.js +2 -2
- package/.next/server/app/api/fs/recent-paths/route.js.nft.json +1 -1
- package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/agent-event/route.js +1 -1
- package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/metrics/vibe/route.js +2 -2
- package/.next/server/app/api/metrics/vibe/route.js.nft.json +1 -1
- package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/ollama/models/route.js +1 -1
- package/.next/server/app/api/ollama/models/route.js.nft.json +1 -1
- package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route.js +1 -1
- package/.next/server/app/api/push/subscriptions/route.js.nft.json +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route.js +1 -1
- package/.next/server/app/api/push/vapid/route.js.nft.json +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route.js +1 -1
- package/.next/server/app/api/repositories/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/route.js +1 -1
- package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route.js +1 -1
- package/.next/server/app/api/repositories/excluded/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route.js +1 -1
- package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route.js +1 -1
- package/.next/server/app/api/repositories/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route.js +1 -1
- package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/sync/route.js +1 -1
- package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/validate-path/route.js +1 -1
- package/.next/server/app/api/repositories/validate-path/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sidebar/group-order/route.js +2 -2
- package/.next/server/app/api/sidebar/group-order/route.js.nft.json +1 -1
- package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/[id]/route.js +1 -1
- package/.next/server/app/api/skills/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/installations/route.js +1 -1
- package/.next/server/app/api/skills/installations/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/operations/route.js +2 -2
- package/.next/server/app/api/skills/operations/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/reindex/route.js +1 -1
- package/.next/server/app/api/skills/reindex/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route.js +1 -1
- package/.next/server/app/api/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/slash-commands/route.js +1 -1
- package/.next/server/app/api/slash-commands/route.js.nft.json +1 -1
- package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/cancel/route.js +2 -2
- package/.next/server/app/api/tasks/[taskId]/cancel/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route.js +2 -2
- package/.next/server/app/api/tasks/[taskId]/route.js.nft.json +1 -1
- package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route.js +2 -2
- package/.next/server/app/api/templates/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route.js +2 -2
- package/.next/server/app/api/templates/route.js.nft.json +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/todos/route.js +1 -1
- package/.next/server/app/api/todos/route.js.nft.json +1 -1
- package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route.js.nft.json +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/route.js +1 -1
- package/.next/server/app/api/verification/runs/route.js.nft.json +1 -1
- package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/execution-logs/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/logs/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route.js +6 -6
- package/.next/server/app/api/worktrees/[id]/marp-render/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route.js +3 -3
- package/.next/server/app/api/worktrees/[id]/schedules/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/skills/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tasks/route.js +4 -4
- package/.next/server/app/api/worktrees/[id]/tasks/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route.js +2 -2
- package/.next/server/app/api/worktrees/[id]/verify/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/apple-icon.png/route.js +1 -1
- package/.next/server/app/apple-icon.png/route.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/icon.png/route.js +1 -1
- package/.next/server/app/icon.png/route.js.nft.json +1 -1
- package/.next/server/app/icon1.png/route.js +1 -1
- package/.next/server/app/icon1.png/route.js.nft.json +1 -1
- package/.next/server/app/icon2.png/route.js +1 -1
- package/.next/server/app/icon2.png/route.js.nft.json +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route.js +2 -2
- package/.next/server/app/manifest.webmanifest/route.js.nft.json +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page_client-reference-manifest.js +1 -1
- package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route.js +1 -1
- package/.next/server/app/proxy/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page.js +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js +2 -2
- package/.next/server/app/worktrees/[id]/files/[...path]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +8 -8
- package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page.js +3 -3
- package/.next/server/app/worktrees/[id]/terminal/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +31 -31
- package/.next/server/chunks/1029.js +1 -0
- package/.next/server/chunks/1068.js +1 -1
- package/.next/server/chunks/1598.js +4 -0
- package/.next/server/chunks/3042.js +1 -1
- package/.next/server/chunks/3417.js +1 -0
- package/.next/server/chunks/3451.js +1 -1
- package/.next/server/chunks/3543.js +1 -1
- package/.next/server/chunks/3753.js +21 -17
- package/.next/server/chunks/3945.js +1 -1
- package/.next/server/chunks/406.js +5 -5
- package/.next/server/chunks/{1185.js → 5048.js} +1 -1
- package/.next/server/chunks/5959.js +3 -3
- package/.next/server/chunks/{5381.js → 5998.js} +2 -2
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/6274.js +5 -5
- package/.next/server/chunks/6283.js +1 -1
- package/.next/server/chunks/6401.js +1 -0
- package/.next/server/chunks/641.js +1 -0
- package/.next/server/chunks/8536.js +1 -0
- package/.next/server/chunks/8543.js +1 -0
- package/.next/server/chunks/8807.js +157 -143
- package/.next/server/chunks/8856.js +2 -2
- package/.next/server/chunks/9058.js +1 -0
- package/.next/server/chunks/9067.js +1 -0
- package/.next/server/chunks/9123.js +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/server/src/middleware.js +1 -1
- package/.next/server/src/middleware.js.map +1 -1
- package/.next/static/chunks/{6488-2c412c29258637b6.js → 6488-3e7539550c3ef358.js} +1 -1
- package/.next/static/chunks/744-fa8c0ae444c8338c.js +1 -0
- package/.next/static/chunks/app/api/app/update/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/app/update-check/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/conversation/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/current-output/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/messages/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/session/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/start/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/terminal/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/assistant/tools/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/auth/login/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/auth/status/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/daily-summary/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/daily-summary/status/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/external-apps/[id]/health/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/external-apps/[id]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/external-apps/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/fs/browse/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/fs/recent-paths/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/hooks/agent-event/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/hooks/claude-done/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/metrics/vibe/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/ollama/models/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/push/subscriptions/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/push/vapid/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/todos/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/clone/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/excluded/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/restore/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/scan/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/sync/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/repositories/validate-path/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/sidebar/group-order/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/skills/[id]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/skills/installations/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/skills/operations/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/skills/reindex/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/skills/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/slash-commands/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/tasks/[taskId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/templates/[id]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/templates/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/todos/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/verification/runs/[runId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/verification/runs/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/capture/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/logs/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/memos/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/messages/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/respond/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/search/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/send/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/timers/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/todos/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tree/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/manifest.webmanifest/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/proxy/[...path]/route-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/repositories/page-202680fe6ec169c8.js +1 -0
- package/.next/static/chunks/app/worktrees/[id]/layout-5bdd550ed6386f57.js +1 -0
- package/.next/static/chunks/app/worktrees/[id]/page-214ee8b97dca856b.js +1 -0
- package/.next/trace +12 -12
- package/.next/types/routes.d.ts +2 -1
- package/.next/types/validator.ts +9 -0
- package/README.md +10 -1
- package/dist/cli/commands/auto-yes.d.ts.map +1 -1
- package/dist/cli/commands/auto-yes.js +3 -2
- package/dist/cli/commands/capture.d.ts.map +1 -1
- package/dist/cli/commands/capture.js +3 -2
- package/dist/cli/commands/ls.d.ts.map +1 -1
- package/dist/cli/commands/ls.js +9 -3
- package/dist/cli/commands/respond.d.ts.map +1 -1
- package/dist/cli/commands/respond.js +3 -2
- package/dist/cli/commands/send.d.ts.map +1 -1
- package/dist/cli/commands/send.js +4 -3
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +66 -0
- package/dist/cli/commands/wait.d.ts.map +1 -1
- package/dist/cli/commands/wait.js +2 -1
- package/dist/cli/config/agent-target-options.d.ts +46 -0
- package/dist/cli/config/agent-target-options.d.ts.map +1 -0
- package/dist/cli/config/agent-target-options.js +54 -0
- package/dist/cli/docs/agent-operations.d.ts +2 -2
- package/dist/cli/docs/agent-operations.d.ts.map +1 -1
- package/dist/cli/docs/agent-operations.js +47 -14
- package/dist/cli/utils/api-client.d.ts +4 -1
- package/dist/cli/utils/api-client.d.ts.map +1 -1
- package/dist/cli/utils/api-client.js +43 -5
- package/dist/cli/utils/npm-runner.d.ts +24 -0
- package/dist/cli/utils/npm-runner.d.ts.map +1 -1
- package/dist/cli/utils/npm-runner.js +51 -1
- package/dist/cli/utils/pid-manager.d.ts +12 -2
- package/dist/cli/utils/pid-manager.d.ts.map +1 -1
- package/dist/cli/utils/pid-manager.js +76 -13
- package/dist/server/server.js +107 -14
- package/dist/server/src/lib/auto-yes-state.js +64 -0
- package/dist/server/src/lib/db/db-repository.js +66 -2
- package/dist/server/src/lib/db/db.js +12 -3
- package/dist/server/src/lib/db/migrations/index.js +6 -0
- package/dist/server/src/lib/db/migrations/runner.js +1 -1
- package/dist/server/src/lib/db/migrations/v53-worktree-aliases.js +53 -0
- package/dist/server/src/lib/db/migrations/v54-worktree-id-path-derived.js +204 -0
- package/dist/server/src/lib/db/migrations/v55-compact-churned-worktree-ids.js +207 -0
- package/dist/server/src/lib/db/migrations/worktree-id-rename.js +153 -0
- package/dist/server/src/lib/db/worktree-alias-db.js +155 -0
- package/dist/server/src/lib/db/worktree-db.js +53 -71
- package/dist/server/src/lib/detection/cli-patterns.js +86 -2
- package/dist/server/src/lib/detection/prompt-detect-multiple-choice.js +10 -1
- package/dist/server/src/lib/git/worktree-id.js +145 -0
- package/dist/server/src/lib/git/worktree-redirect.js +155 -0
- package/dist/server/src/lib/git/worktrees.js +173 -27
- package/dist/server/src/lib/logger.js +13 -1
- package/dist/server/src/lib/polling/auto-yes-manager.js +3 -1
- package/dist/server/src/lib/polling/prompt-dedup.js +22 -0
- package/dist/server/src/lib/polling/response-checker.js +53 -13
- package/dist/server/src/lib/polling/response-dedup.js +22 -0
- package/dist/server/src/lib/polling/response-poller-core.js +107 -0
- package/dist/server/src/lib/polling/response-poller.js +4 -1
- package/dist/server/src/lib/response-extractor.js +22 -2
- package/dist/server/src/lib/session/claude-session.js +117 -35
- package/dist/server/src/lib/session/current-output-builder.js +14 -1
- package/dist/server/src/lib/session/session-start-error.js +125 -0
- package/dist/server/src/lib/session/worktree-session-reconcile.js +603 -0
- package/dist/server/src/lib/tasks/contract-parser.js +17 -1
- package/dist/server/src/lib/tasks/task-state-machine.js +23 -1
- package/dist/server/src/lib/tmux/control-mode-tmux-transport.js +7 -0
- package/dist/server/src/lib/tmux/read-mode.js +22 -2
- package/dist/server/src/lib/tmux/tmux-capture-cache.js +33 -0
- package/dist/server/src/lib/tmux/tmux-control-client.js +12 -0
- package/dist/server/src/lib/tmux/tmux-control-registry.js +55 -11
- package/dist/server/src/lib/tmux/tmux.js +61 -0
- package/dist/server/src/lib/ws-server.js +104 -1
- package/package.json +1 -1
- package/.next/server/chunks/1117.js +0 -1
- package/.next/server/chunks/1356.js +0 -4
- package/.next/server/chunks/1692.js +0 -1
- package/.next/server/chunks/4018.js +0 -1
- package/.next/server/chunks/4390.js +0 -1
- package/.next/server/chunks/8681.js +0 -1
- package/.next/static/chunks/744-d5e47fe16e7b9e06.js +0 -1
- package/.next/static/chunks/app/api/app/update/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/app/update-check/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/conversation/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/current-output/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/messages/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/session/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/start/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/terminal/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/assistant/tools/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/auth/login/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/auth/status/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/daily-summary/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/daily-summary/status/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/external-apps/[id]/health/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/external-apps/[id]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/external-apps/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/fs/browse/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/fs/recent-paths/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/hooks/agent-event/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/hooks/claude-done/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/metrics/vibe/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/ollama/models/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/push/subscriptions/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/push/vapid/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/todos/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/clone/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/excluded/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/restore/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/scan/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/sync/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/repositories/validate-path/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/sidebar/group-order/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/skills/[id]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/skills/installations/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/skills/operations/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/skills/reindex/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/skills/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/slash-commands/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/tasks/[taskId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/templates/[id]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/templates/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/todos/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/verification/runs/[runId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/verification/runs/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/capture/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/logs/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/memos/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/messages/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/respond/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/search/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/send/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/timers/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/todos/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tree/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/api/worktrees/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/proxy/[...path]/route-8440b6c72bed83a1.js +0 -1
- package/.next/static/chunks/app/repositories/page-1ed1e5a542ecc168.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-f6e09d25cd3b56f9.js +0 -1
- /package/.next/static/{-E7I667pJDTBamyG8M_Z- → C01FQOE5FCmB3I_GhMa4_}/_buildManifest.js +0 -0
- /package/.next/static/{-E7I667pJDTBamyG8M_Z- → C01FQOE5FCmB3I_GhMa4_}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1479],{8269:(e,t,n)=>{"use strict";n.d(t,{hU:()=>r});var a=n(12115);function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onSwipeLeft:t,onSwipeRight:n,onSwipeUp:r,onSwipeDown:s,threshold:l=50,enabled:i=!0,axis:o="both",directionLock:c,directionLockThreshold:d=12,suppressWhenScrollable:u=!0,edgeStartZone:m=0,onSwipeMove:h,onSwipeEnd:x}=e,f=null!=c?c:"both"!==o,g="horizontal"===o?"horizontal":"vertical",p="both"===o||"horizontal"===o,b="both"===o||"vertical"===o,v=(0,a.useRef)(null),[y,w]=(0,a.useState)(!1),[j,k]=(0,a.useState)(null),N=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useCallback)(()=>{k(null)},[]),T=(0,a.useCallback)(e=>{if(!i)return;if(u&&e.target instanceof HTMLElement&&function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vertical",n=e;for(;n;){let e=getComputedStyle(n);if("horizontal"===t){let{overflowX:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollWidth>n.clientWidth)return!0}else{let{overflowY:t}=e;if(("auto"===t||"scroll"===t)&&n.scrollHeight>n.clientHeight)return!0}n=n.parentElement}return!1}(e.target,g)){N.current=null;return}let t=e.touches[0];if(m>0&&v.current){let e=v.current.getBoundingClientRect(),n=t.clientX-e.left,a=e.right-t.clientX;if(n>m&&a>m){N.current=null;return}}N.current={x:t.clientX,y:t.clientY},C.current={committed:null,cancelled:!1},w(!0)},[i,u,g,m]),E=(0,a.useCallback)(e=>{if(!i||!N.current)return;let t=e.touches[0],n=t.clientX-N.current.x,a=t.clientY-N.current.y,r=Math.abs(n),s=Math.abs(a);if(f){let e=C.current;if(e){if(e.cancelled)return;if(null===e.committed&&Math.max(r,s)>=d){let t=r>s?"horizontal":"vertical";if(e.committed=t,t!==o){e.cancelled=!0;return}}if(null!==e.committed&&e.committed!==o)return}}p&&r>s&&r>=l?k(n<0?"left":"right"):b&&s>=l&&k(a<0?"up":"down"),null==h||h({deltaX:n,deltaY:a})},[i,l,o,f,d,p,b,h]),I=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void w(!1);let o=f&&(null==(a=C.current)?void 0:a.cancelled)===!0,c=e.changedTouches[0];if(!o&&c){let e=c.clientX-N.current.x,a=c.clientY-N.current.y,i=Math.abs(e),o=Math.abs(a);i>o?p&&i>=l&&(e<0?(k("left"),null==t||t()):(k("right"),null==n||n())):b&&o>=l&&(a<0?(k("up"),null==r||r()):(k("down"),null==s||s()))}N.current=null,C.current=null,w(!1),null==x||x()},[i,l,f,p,b,t,n,r,s,x]),M=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,w(!1),null==x||x())},[x]);return(0,a.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("touchstart",T),e.addEventListener("touchmove",E),e.addEventListener("touchend",I),e.addEventListener("touchcancel",M),()=>{e.removeEventListener("touchstart",T),e.removeEventListener("touchmove",E),e.removeEventListener("touchend",I),e.removeEventListener("touchcancel",M)}},[T,E,I,M]),{ref:v,isSwiping:y,swipeDirection:j,resetSwipeDirection:S}}},11063:(e,t,n)=>{"use strict";n.d(t,{Ko:()=>r,j6:()=>a}),n(19985);let a=5242880,r={safe:"",interactive:"allow-scripts"}},17846:(e,t,n)=>{"use strict";n.d(t,{a:()=>l});var a=n(95155),r=n(12115),s=n(18955);function l(e){let{src:t,alt:n,onError:l}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!1);return o?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("imageViewer.loadError")}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:n})]}):(0,a.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,a.jsx)("img",{src:t,alt:n,onError:()=>{c(!0),null==l||l()},style:{maxWidth:"100%",maxHeight:"500px",objectFit:"contain"},className:"rounded-lg shadow-sm"})})}},19985:(e,t,n)=>{"use strict";n.d(t,{F5:()=>i,Fg:()=>a,HB:()=>s,Hv:()=>l});let a=0x1400000,r=[{extension:".png",mimeType:"image/png",magicBytes:[137,80,78,71]},{extension:".jpg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".jpeg",mimeType:"image/jpeg",magicBytes:[255,216,255]},{extension:".gif",mimeType:"image/gif",magicBytes:[71,73,70,56]},{extension:".webp",mimeType:"image/webp",magicBytes:[82,73,70,70]},{extension:".svg",mimeType:"image/svg+xml"}];function s(e){return e?e.startsWith(".")?e.toLowerCase():"."+e.toLowerCase():""}let l=[".png",".jpg",".jpeg",".gif",".webp",".svg"].filter(e=>".svg"!==e),i=l.map(e=>(function(e){let t=s(e),n=r.find(e=>e.extension===t);return(null==n?void 0:n.mimeType)||"application/octet-stream"})(e)).filter(e=>"application/octet-stream"!==e).join(",")},20252:(e,t,n)=>{Promise.resolve().then(n.bind(n,87228))},27307:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PdfPreview:()=>o,default:()=>c});var a=n(95155),r=n(12115),s=n(18955);n(19985);let l=void 0;var i=n(3005);function o(e){let{dataUri:t,filePath:n,variant:o="iframe"}=e,[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),h=(0,s.c)("worktree");if((0,r.useEffect)(()=>{let e=!1,n=null;return d(null),m(!1),(async()=>{try{let a=await fetch(t);if(!a.ok)throw Error("fetch failed: ".concat(a.status));let r=await a.blob();if(e)return;n=URL.createObjectURL(r),d(n)}catch(t){if(e)return;m(!0)}})(),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[t,n]),u)return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-3 p-6 text-center","data-testid":"pdf-preview-error",children:[(0,a.jsx)("p",{className:"text-sm text-danger-foreground",children:h("pdfPreview.loadError")}),(0,a.jsx)("a",{href:t,download:n.split("/").pop()||"document.pdf",className:"inline-flex items-center gap-2 px-4 py-2 rounded-md border border-input text-sm text-foreground hover:bg-muted",rel:"noopener",children:h("pdfPreview.downloadPdf")})]});if(!c)return(0,a.jsx)("div",{className:"h-full flex items-center justify-center","data-testid":"pdf-preview-loading",children:(0,a.jsx)(i.y,{size:"xl",variant:"accent"})});if("download"===o){let e=n.split("/").pop()||"document.pdf";return(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center gap-4 p-6 text-center","data-testid":"pdf-preview-download",children:[(0,a.jsx)("svg",{className:"w-16 h-16 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,a.jsx)("p",{className:"text-sm text-foreground break-all",children:e}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full max-w-xs",children:[(0,a.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-6 py-3 rounded-lg bg-accent-600 hover:bg-accent-700 active:bg-accent-800 text-white text-sm font-medium transition-colors",children:h("pdfPreview.openInNewTab")}),(0,a.jsx)("a",{href:c,download:e,className:"inline-flex items-center justify-center gap-2 px-6 py-2 rounded-lg border border-input text-sm text-foreground hover:bg-muted transition-colors",children:h("pdfPreview.download")})]})]})}return(0,a.jsx)("iframe",{src:c,sandbox:l,title:h("pdfPreview.title",{path:n}),className:"w-full h-full border-0 bg-white","data-testid":"pdf-preview-iframe"})}let c=o},46892:(e,t,n)=>{"use strict";n.d(t,{PL:()=>r,sb:()=>s});let a={idle:"bg-muted-foreground",ready:"bg-success",spinner:"border-info",waiting:"bg-warning"},r={idle:{className:a.idle,labelKey:"status.idle",type:"dot"},ready:{className:a.ready,labelKey:"status.ready",type:"dot"},running:{className:a.spinner,labelKey:"status.running",type:"spinner"},waiting:{className:a.waiting,labelKey:"status.waiting",type:"dot"},generating:{className:a.spinner,labelKey:"status.generating",type:"spinner"}},s={idle:"detailStatus.idle",ready:"detailStatus.ready",running:"detailStatus.running",waiting:"detailStatus.waiting"}},50857:(e,t,n)=>{"use strict";function a(e){return"running"===e||"generating"===e||"waiting"===e}function r(e){return e.isActive||a(e.status)}function s(e,t){let n=e.map((e,t)=>({it:e,index:t})).filter(e=>{let{it:t}=e;return r(t)}),a=new Set;return t>0&&n.length>0&&[...n].sort((e,t)=>Number(t.it.isActive)-Number(e.it.isActive)||e.index-t.index).slice(0,t).forEach(e=>{let{index:t}=e;return a.add(t)}),e.map((e,t)=>r(e)?{...e,slot:a.has(t)?"pill":"overflow"}:{...e,slot:"dot"})}n.d(t,{Qo:()=>a,Uw:()=>s})},51434:(e,t,n)=>{"use strict";n.d(t,{C:()=>r});var a=n(12115);function r(){let[e,t]=(0,a.useState)(!1),[n,r]=(0,a.useState)(0),[s,l]=(0,a.useState)(null),i=(0,a.useCallback)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport,n=window.innerHeight,a=e.height,s=n-a,i=s>100;t(i),r(i?s:0),l(a)},[]);return(0,a.useEffect)(()=>{if(null==window.visualViewport)return;let e=window.visualViewport;return i(),e.addEventListener("resize",i),()=>{e.removeEventListener("resize",i)}},[i]),{isKeyboardVisible:e,keyboardHeight:n,viewportHeight:s}}},53292:(e,t,n)=>{"use strict";n.d(t,{Ll:()=>a,bu:()=>r});let a=2e3,r=4e3},60850:(e,t,n)=>{"use strict";n.d(t,{U:()=>r});var a=n(12115);function r(e){let{value:t,saveFn:n,debounceMs:r=300,disabled:s=!1,maxRetries:l=3,onSaveComplete:i}=e,[o,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(null),m=(0,a.useRef)(t),h=(0,a.useRef)(n),x=(0,a.useRef)(i),f=(0,a.useRef)(null),g=(0,a.useRef)(!0),p=(0,a.useRef)(t);(0,a.useEffect)(()=>{m.current=t},[t]),(0,a.useEffect)(()=>{h.current=n},[n]),(0,a.useEffect)(()=>{x.current=i},[i]),(0,a.useEffect)(()=>(g.current=!0,()=>{g.current=!1,f.current&&clearTimeout(f.current)}),[]);let b=(0,a.useCallback)(async e=>{if(!g.current)return;c(!0),u(null);let t=null,n=0;for(;n<=l;)try{if(await h.current(e),g.current){var a;c(!1),u(null),null==(a=x.current)||a.call(x)}return}catch(e){if(t=e instanceof Error?e:Error(String(e)),++n<=l){let e=1e3*Math.pow(2,n-1);await new Promise(t=>setTimeout(t,e))}}g.current&&(c(!1),u(t))},[l]),v=(0,a.useCallback)(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),y=(0,a.useCallback)(async()=>{s||(v(),await b(m.current))},[s,v,b]);return(0,a.useEffect)(()=>{if(t!==p.current&&!s)return v(),f.current=setTimeout(()=>{b(m.current)},r),()=>{v()}},[t,s,r,v,b]),{isSaving:o,error:d,saveNow:y}}},64269:(e,t,n)=>{"use strict";function a(e,t){let n=null;return function(){for(var a=arguments.length,r=Array(a),s=0;s<a;s++)r[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(e){let t=new Set;for(let n of e){t.add(n);let e=n.split("/"),a="";for(let n=0;n<e.length-1;n++)a=a?"".concat(a,"/").concat(e[n]):e[n],t.add(a)}return t}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;return e.length<=t?e:"".concat(e.substring(0,t-3),"...")}function i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}n.d(t,{Nt:()=>r,W5:()=>l,ZD:()=>i,q3:()=>s,sg:()=>a})},69264:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});var a=n(95155),r=n(12115),s=n(18955),l=n(3005);function i(e){let{src:t,onError:n}=e,i=(0,s.c)("worktree"),[o,c]=(0,r.useState)(!0),[d,u]=(0,r.useState)(!1);return d?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,a.jsx)("svg",{className:"w-16 h-16 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),(0,a.jsx)("p",{className:"text-sm",children:i("videoViewer.loadError")})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center p-4",children:[o&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(l.y,{size:"xl",variant:"accent"}),(0,a.jsx)("p",{className:"ml-3 text-muted-foreground",children:i("videoViewer.loading")})]}),(0,a.jsx)("video",{controls:!0,src:t,onLoadedData:()=>{c(!1)},onError:()=>{c(!1),u(!0),null==n||n()},style:{maxWidth:"100%",maxHeight:"500px",display:o?"none":"block"},className:"rounded-lg shadow-sm",children:i("videoViewer.unsupported")})]})}},72115:(e,t,n)=>{"use strict";n.d(t,{f:()=>d});var a=n(95155),r=n(12115),s=n(18955);let l=["relative","flex-shrink-0","bg-border","transition-colors","duration-150","hover:bg-accent-500","dark:hover:bg-accent-500","focus:outline-none","focus:ring-2","focus:ring-ring","focus:ring-offset-2","focus:ring-offset-background"],i=["w-1","h-full","cursor-col-resize","before:content-['']","before:absolute","before:inset-y-0","before:-inset-x-1"],o=["h-1","w-full","cursor-row-resize","before:content-['']","before:absolute","before:inset-x-0","before:-inset-y-1"];function c(e,t){return"touches"in e&&e.touches.length>0?t?e.touches[0].clientX:e.touches[0].clientY:"clientX"in e?t?e.clientX:e.clientY:0}let d=(0,r.memo)(function(e){let{onResize:t,orientation:n="horizontal",ariaValueNow:d=50,onDoubleClick:u,minRatio:m=.1}=e,h=(0,s.c)("worktree"),[x,f]=(0,r.useState)(!1),g=(0,r.useRef)(0),p=(0,r.useRef)(null),b="horizontal"===n,v=(0,r.useCallback)(e=>{e.preventDefault(),f(!0),g.current=c(e,b)},[b]),y=(0,r.useCallback)(e=>{1===e.touches.length&&(f(!0),g.current=c(e,b))},[b]),w=(0,r.useCallback)(e=>{if(!x)return;let n=c(e,b);t(n-g.current),g.current=n},[x,b,t]),j=(0,r.useCallback)(e=>{if(!x||1!==e.touches.length)return;let n=c(e,b);t(n-g.current),g.current=n},[x,b,t]),k=(0,r.useCallback)(()=>{f(!1)},[]),N=(0,r.useCallback)(()=>{u&&u()},[u]),C=(0,r.useCallback)(e=>{let n=0;b?"ArrowRight"===e.key?n=10:"ArrowLeft"===e.key&&(n=-10):"ArrowDown"===e.key?n=10:"ArrowUp"===e.key&&(n=-10),0!==n&&(e.preventDefault(),t(n))},[b,t]);(0,r.useEffect)(()=>(x&&(document.addEventListener("mousemove",w),document.addEventListener("mouseup",k),document.addEventListener("touchmove",j),document.addEventListener("touchend",k),document.body.style.userSelect="none",document.body.style.cursor=b?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",j),document.removeEventListener("touchend",k),document.body.style.userSelect="",document.body.style.cursor=""}),[x,w,k,j,b]);let S=(0,r.useMemo)(()=>[...l,...b?i:o,...x?["bg-accent-500","dark:bg-accent-500","dragging",b?"w-2":"h-2"]:[]].join(" "),[b,x]);return(0,a.jsx)("div",{ref:p,role:"separator","aria-orientation":n,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,"aria-label":h("paneResizer.label",{arrows:h(b?"paneResizer.arrowsHorizontal":"paneResizer.arrowsVertical")}),tabIndex:0,className:S,onMouseDown:v,onTouchStart:y,onKeyDown:C,onDoubleClick:N})})},83012:(e,t,n)=>{"use strict";n.d(t,{Fx:()=>l,bg:()=>i,fw:()=>s});var a=n(53298),r=n(73683);function s(e,t){let n=new Date(e);return isNaN(n.getTime())?"":(0,a.m)(n,{addSuffix:!0,...t?{locale:t}:{}})}function l(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=Math.round((Date.now()-t.getTime())/1e3);if(n<45)return"now";let a=Math.round(n/60);if(a<60)return"".concat(a,"m ago");let r=Math.round(a/60);if(r<24)return"".concat(r,"h ago");let s=Math.round(r/24);return s<7?"".concat(s,"d ago"):s<30?"".concat(Math.round(s/7),"w ago"):s<365?"".concat(Math.round(s/30),"mo ago"):"".concat(Math.round(s/365),"y ago")}function i(e,t){return!(e instanceof Date)||isNaN(e.getTime())?"":(0,r.GP)(e,"PPp",t?{locale:t}:void 0)}},85872:(e,t,n)=>{"use strict";async function a(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}n.d(t,{$C:()=>r,Ar:()=>l,KG:()=>s});let r={async list(e){var t;let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:a(n,"Failed to load todos")},async listAll(){var e;let t=await fetch("/api/todos");return t.ok?null!=(e=(await t.json()).todos)?e:[]:a(t,"Failed to load todos")},async create(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});return n.ok?(await n.json()).todo:a(n,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/repositories/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await a(n,"Failed to delete todo")}},s=["todo","doing","done"],l={async list(e){var t;let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"));return n.ok?null!=(t=(await n.json()).todos)?t:[]:a(n,"Failed to load todos")},async create(e,t,n){let r=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(void 0!==n?{content:t,detail:n}:{content:t})});return r.ok?(await r.json()).todo:a(r,"Failed to create todo")},async update(e,t,n){let r=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?(await r.json()).todo:a(r,"Failed to update todo")},async remove(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"DELETE"});n.ok||await a(n,"Failed to delete todo")},async reorder(e,t){let n=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({todoIds:t})});n.ok||await a(n,"Failed to reorder todos")}}},87228:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>lr});var a,r=n(95155),s=n(20063),l=n(4560),i=n(12115),o=n(67909),c=n(18955),d=n(37772),u=n(3005),m=n(744),h=n(48481),x=n(64269);let f=(0,i.memo)(function(e){let{path:t,className:n="w-6 h-6"}=e;return(0,r.jsx)("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),g={back:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z",menu:"M4 6h16M4 12h16M4 18h16"};function p(e){let{worktreeName:t,repositoryName:n,status:a,gitStatus:s,onBackClick:l,onMenuClick:i}=e,o=(0,c.c)("common"),d=(0,c.c)("worktree");return(0,r.jsx)("header",{"data-testid":"mobile-header",role:"banner",className:"sticky top-0 inset-x-0 bg-surface border-b border-border shadow-sm pt-safe z-40",children:(0,r.jsxs)("div",{className:"flex items-center justify-between h-14 px-4",children:[(0,r.jsx)("div",{className:"w-10 flex-shrink-0",children:l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"aria-label":o("back"),className:"p-2 -ml-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(f,{path:g.back})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(h.m,{"data-testid":"status-indicator",status:a,size:"sm",className:"mr-2"}),(0,r.jsxs)("div",{className:"flex flex-col items-center min-w-0",children:[(0,r.jsx)("h1",{role:"heading","data-testid":"worktree-name",title:t,className:"text-sm font-medium text-foreground truncate text-center leading-tight",children:t}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[n&&(0,r.jsx)("span",{className:"truncate max-w-[100px] text-center",children:n}),s&&"(unknown)"!==s.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[n&&(0,r.jsx)("span",{className:"text-muted-foreground/50",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[80px] font-mono",title:s.currentBranch,"data-testid":"mobile-branch-name",children:(0,x.W5)(s.currentBranch,20)}),s.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:d("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsx)("div",{className:"w-10 flex-shrink-0 flex justify-end",children:i&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,"aria-label":o("menu"),className:"p-2 -mr-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(f,{path:g.menu})})})]})})}var b=n(22479),v=n(26983),y=n(59847),w=n(53842),j=n(23327);function k(e){let{"data-testid":t,"aria-label":n,className:a=""}=e;return(0,r.jsx)("span",{"data-testid":t,className:"w-2 h-2 rounded-full bg-accent-500 ".concat(a).trim(),"aria-label":n})}let N=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(b.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})}];function C(e){let{activeTab:t,onTabChange:n,hasNewOutput:a=!1,hasPrompt:s=!1,hasUpdate:l=!1,onSearchParamsChange:o,inFlow:d=!1}=e,u=(0,c.c)("worktree"),m=(0,i.useRef)([]),h=(0,i.useCallback)(e=>{let n=e===t;return"".concat("flex flex-col items-center justify-center flex-1 min-h-[44px] py-2 px-1 transition-colors relative touch-manipulation"," ").concat(n?"text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground")},[t]),x=(0,i.useCallback)(e=>{n(e),null==o||o("memo"===e?"notes":e)},[n,o]),f=(0,i.useCallback)((e,t)=>{var n;let a=null;switch(e.key){case"ArrowRight":case"ArrowDown":a=(t+1)%N.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+N.length)%N.length;break;case"Home":a=0;break;case"End":a=N.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),x(N[a].id)},[x]),g=(0,i.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[a&&(0,r.jsx)("span",{"data-testid":"new-output-badge",className:"absolute top-1 right-1 w-2 h-2 bg-success rounded-full","aria-label":u("tabs.newOutput")}),s&&(0,r.jsx)("span",{"data-testid":"prompt-badge",className:"absolute top-1 right-3 w-2 h-2 bg-warning rounded-full","aria-label":u("tabs.promptWaiting")})]}),[a,s,u]);return(0,r.jsx)("nav",{"data-testid":"mobile-tab-bar",role:"tablist","aria-label":u("tabs.ariaLabel"),className:"".concat(d?"flex-shrink-0":"fixed bottom-0"," inset-x-0 border-t border-border bg-background supports-[backdrop-filter]:bg-background/80 backdrop-blur-md flex pb-safe z-40"),children:N.map((e,n)=>(0,r.jsxs)("button",{ref:e=>{m.current[n]=e},type:"button","data-testid":"mobile-tab-".concat(e.id),role:"tab","aria-selected":t===e.id,"aria-label":u(e.labelKey),tabIndex:t===e.id?0:-1,onClick:()=>x(e.id),onKeyDown:e=>f(e,n),className:h(e.id),children:[t===e.id&&(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute top-0 inset-x-2 h-0.5 rounded-full bg-accent-500"}),e.icon,(0,r.jsx)("span",{className:"text-xs mt-1 whitespace-nowrap",children:u(e.labelKey)}),"terminal"===e.id&&g,"info"===e.id&&l&&(0,r.jsx)(k,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}class S extends i.Component{static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){var n,a;console.error("[ErrorBoundary:".concat(this.props.componentName||"unknown","]"),e,t),null==(n=(a=this.props).onError)||n.call(a,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,r.jsx)(T,{componentName:this.props.componentName,error:this.state.error,onRetry:this.handleRetry}):this.props.children}constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:null})},this.state={hasError:!1,error:null}}}function T(e){let{componentName:t,error:n,onRetry:a}=e,s=(0,c.c)("error"),l=(0,c.c)("common");return(0,r.jsxs)("div",{className:"p-4 bg-danger-subtle border border-danger-border rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-danger-foreground mb-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),(0,r.jsx)("span",{className:"font-medium",children:t?s("boundary.errorOccurredIn",{componentName:t}):s("boundary.errorOccurred")})]}),n&&(0,r.jsx)("p",{className:"text-sm text-danger-foreground/80 mb-3",children:n.message}),a&&(0,r.jsx)("button",{onClick:a,className:"px-4 py-2 bg-danger-foreground text-danger-subtle rounded hover:opacity-90 transition-opacity text-sm",children:l("retry")})]})}let E={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function I(e){let{visible:t,duration:n=200}=e,[a,r]=(0,i.useState)(t?"visible":"hidden"),s=(0,i.useRef)(null),l=(0,i.useRef)(t);(0,i.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]),(0,i.useEffect)(()=>{let e=l.current;l.current=t,s.current&&(clearTimeout(s.current),s.current=null);let a=e=>{s.current=setTimeout(()=>{r(e),s.current=null},n)};t&&!e?(r("fade-in"),a("visible")):!t&&e?(r("fade-out"),a("hidden")):t?r(e=>"fade-out"===e?(a("visible"),"fade-in"):e):r(e=>"fade-in"===e?(a("hidden"),"fade-out"):e)},[t,n]);let o="hidden"!==a,c="fade-in"===a||"fade-out"===a;return{shouldRender:o,animationClass:(0,i.useMemo)(()=>{switch(a){case"fade-in":return E.fadeIn;case"fade-out":return E.fadeOut;default:return E.none}},[a]),isAnimating:c}}var M=n(92539),L=n(8269);let A={base:"px-6 py-3 rounded-lg font-medium transition-all touch-manipulation disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2",primary:"bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",secondary:"bg-muted border-2 border-input hover:bg-muted/80 text-foreground focus:ring-ring",defaultSelected:"bg-muted-foreground text-background hover:bg-muted-foreground/90"},R=(0,i.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:s,onDismiss:l,cliToolName:o}=e,{shouldRender:c,animationClass:d}=I({visible:n&&null!==t,duration:300}),u=(0,i.useId)(),m=n&&null!==t,h=(0,M.r)({active:m}),[x,f]=(0,i.useState)(0);(0,i.useEffect)(()=>{n||f(0)},[n]);let g=(0,i.useCallback)(e=>{let{deltaY:t}=e;f(t>0?t:0)},[]),p=(0,i.useCallback)(()=>{null==l||l()},[l]),b=(0,i.useCallback)(()=>{f(0)},[]),{ref:v}=(0,L.hU)({axis:"vertical",threshold:100,enabled:m,onSwipeMove:g,onSwipeDown:p,onSwipeEnd:b}),y=(0,i.useCallback)(e=>{h.current=e,v.current=e},[h,v]),w=(0,i.useCallback)(()=>{l&&l()},[l]),j=(0,i.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let k="animate-fade-out"===d;return(0,r.jsxs)(S,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:w,className:"fixed inset-0 bg-black/50 z-50 transition-opacity duration-300 ".concat(k?"opacity-0":"opacity-100"," ").concat(k?"pointer-events-none":""),"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:y,"data-testid":"mobile-prompt-sheet",role:"dialog","aria-modal":"true","aria-labelledby":u,onClick:j,style:{transform:x>0?"translateY(".concat(x,"px)"):void 0},className:"fixed bottom-0 inset-x-0 bg-surface rounded-t-2xl z-50 pb-safe transform transition-transform duration-300 ".concat(k?"translate-y-full":"translate-y-0"),children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{"data-testid":"drag-handle",className:"w-10 h-1 bg-input rounded-full","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"px-4 pb-6",children:(0,r.jsx)(P,{promptData:t,answering:a,onRespond:s,labelId:u,cliToolName:o})})]})]})});function P(e){let{promptData:t,answering:n,onRespond:a,labelId:s,cliToolName:l}=e,o=(0,c.c)("prompt"),[d,u]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[h,x]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),p=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===d))?e:null},[t,d]),b=(null==p?void 0:p.requiresTextInput)===!0,v=n||f,y=(0,i.useCallback)(async e=>{if(!v){g(!0);try{await a(e)}catch(e){}finally{g(!1)}}},[v,a]),w=(0,i.useCallback)(async()=>{if(!v&&null!==d){g(!0);try{let e=b&&h.trim()?h.trim():d.toString();await a(e)}catch(e){}finally{g(!1)}}},[v,a,d,b,h]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:s,className:"text-lg font-semibold text-foreground",children:l?o("confirmationFrom",{toolName:l}):o("confirmationFromClaude")}),t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:t.instructionText}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:t.question}),v&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:o("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(F,{promptData:t,disabled:v,onYes:()=>y("yes"),onNo:()=>y("no")}),"multiple_choice"===t.type&&(0,r.jsx)(D,{promptData:t,disabled:v,selectedOption:d,onSelectOption:u,textInputValue:h,onTextInputChange:x,showTextInput:b,onSubmit:w})]})}let F=(0,i.memo)(function(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption;return(0,r.jsxs)("div",{className:"flex gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)("button",{type:"button",onClick:a,disabled:n,className:"flex-1 ".concat(A.base," ").concat(A.primary," ").concat(i?"ring-2 ring-accent-300":""),children:l("yes")}),(0,r.jsx)("button",{type:"button",onClick:s,disabled:n,className:"flex-1 ".concat(A.base," ").concat(o?A.defaultSelected:A.secondary),children:l("no")})]})}),D=(0,i.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,h=(0,i.useId)(),x=(0,c.c)("prompt");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:x("selectAnOption")}),(0,r.jsx)(m.z6,{name:h,value:null!=a?String(a):"",onValueChange:e=>s(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a===e.number;return(0,r.jsxs)("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ".concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(n?"opacity-50 cursor-not-allowed":""),children:[(0,r.jsx)(m.CU,{value:String(e.number),className:"mt-1"}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium text-foreground",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{className:"ml-2 text-xs text-accent-600 bg-accent-100 px-2 py-0.5 rounded",children:x("default")})]})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(h),className:"sr-only",children:x("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(h),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:x("enterValuePlaceholder"),inputMode:"text",enterKeyHint:"done",className:"w-full px-4 py-3 border-2 border-input rounded-lg bg-surface text-foreground focus:outline-none focus:border-ring disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:n||null===a,className:"w-full ".concat(A.base," ").concat(A.primary),children:x("submit")})]})});var z=n(86651),O=n(84926);function B(e){let{open:t,onClose:n,onSearch:a,onEnd:s,endDisabled:l=!1}=e,o=(0,c.c)("worktree"),d=(0,i.useId)(),u=(0,M.r)({active:t}),m=(0,i.useCallback)(()=>{a(),n()},[a,n]),h=(0,i.useCallback)(()=>{s(),n()},[s,n]);return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&n()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"terminal-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:u,"data-testid":"mobile-terminal-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":d,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:d,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:o("terminal.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-search",onClick:m,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation",children:[(0,r.jsx)(z.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),o("terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:h,disabled:l,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-sm text-danger hover:bg-danger/10 transition-colors touch-manipulation disabled:opacity-40 disabled:hover:bg-transparent",children:[(0,r.jsx)(O.A,{size:18,"aria-hidden":"true"}),o("terminal.endSession")]})]})]})]}):null}var _=n(80344),W=n(79651);function H(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e=>{var t;return null!=(t=e.description)?t:""};if(!t.trim())return e;let a=t.toLowerCase();return e.map(e=>({...e,commands:e.commands.filter(e=>{let t=e.name.toLowerCase().includes(a),r=n(e).toLowerCase().includes(a);return t||r})})).filter(e=>e.commands.length>0)}function V(e,t){return"codex-skill"===e.source?"antigravity"===t?"/".concat(e.name):"$".concat(e.name):"/".concat(e.name)}function U(e,t){var n;return e.descriptionKey?t(e.descriptionKey):null!=(n=e.description)?n:""}function K(e){let{groups:t,onSelect:n,highlightedIndex:a=-1,className:s="",cliToolId:l}=e,i=(0,c.c)("worktree"),o=0;return 0===t.length?(0,r.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center ".concat(s),children:i("slashCommands.empty")}):(0,r.jsx)("div",{className:"overflow-y-auto ".concat(s),children:t.map(e=>(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-muted",children:e.label}),(0,r.jsx)("div",{children:e.commands.map(e=>{var t;let s=o;o++;let c=s===a;return(0,r.jsxs)("button",{type:"button","data-command-item":!0,"data-highlighted":c,onClick:()=>n(e),className:"w-full px-3 py-2 text-left flex items-start gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors ".concat(c?"bg-accent-100 dark:bg-accent-900/40":""),children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-mono text-sm flex-shrink-0",children:V(e,l)}),(null==(t=e.cliTools)?void 0:t.length)===1&&"codex"===e.cliTools[0]&&(0,r.jsx)("span",{className:"mt-0.5 rounded border border-accent-200 bg-accent-50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent-700 dark:border-accent-800 dark:bg-accent-950/40 dark:text-accent-300",children:"Codex"}),"user-catalog"===e.source&&(0,r.jsx)("span",{"data-testid":"user-catalog-badge",className:"mt-0.5 rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:i("slashCommands.sourceBadge.userCatalog")}),(0,r.jsx)("span",{className:"text-muted-foreground text-sm truncate",children:U(e,i)})]},e.name)})})]},e.category))})}function $(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let q=(0,i.memo)(function(e){let{isOpen:t,groups:n,onSelect:a,onClose:s,isMobile:l=!1,position:o,onFreeInput:d,isCatalogStale:u=!1,cliToolId:m}=e,[h,x]=(0,i.useState)(""),[f,g]=(0,i.useState)(0),p=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,w]=(0,i.useState)({x:0,y:0}),j=(0,c.c)("worktree"),k=(0,c.c)("common"),N=(0,i.useMemo)(()=>H(n,h,e=>U(e,j)),[n,h,j]),C=(0,i.useMemo)(()=>N.flatMap(e=>e.commands),[N]);(0,i.useEffect)(()=>{t&&(x(""),g(0),setTimeout(()=>{var e;null==(e=p.current)||e.focus()},50))},[t]);let S=(0,i.useCallback)(e=>{a(e),s()},[a,s]),T=(0,i.useCallback)(e=>{if(t)switch(e.key){case"Escape":e.preventDefault(),s();break;case"ArrowDown":e.preventDefault(),g(e=>Math.min(e+1,C.length-1));break;case"ArrowUp":e.preventDefault(),g(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),C[f]&&S(C[f])}},[t,C,f,s,S]);if((0,i.useEffect)(()=>{if(t)return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[t,T]),(0,i.useLayoutEffect)(()=>{let e=e=>{v.current=e,w(t=>t.x===e.x&&t.y===e.y?t:e)};if(!t||l)return void e({x:0,y:0});let n=b.current;if(!n)return;let a=n.getBoundingClientRect();e({x:$(a.left-v.current.x,a.width,window.innerWidth),y:$(a.top-v.current.y,a.height,window.innerHeight)})},[t,l,N,null==o?void 0:o.top,null==o?void 0:o.left]),!t)return null;let E=u?(0,r.jsx)("div",{"data-testid":"slash-command-stale-note",className:"px-3 py-2 border-t border-border text-xs text-muted-foreground",children:j("slashCommands.catalogStale.hint")}):null;if(l)return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:s,"aria-hidden":"true"}),(0,r.jsxs)("div",{"data-testid":"slash-command-bottom-sheet",className:"fixed bottom-0 left-0 right-0 bg-surface rounded-t-xl z-50 max-h-[70vh] flex flex-col shadow-xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:j("slashCommands.title")}),(0,r.jsx)("button",{type:"button",onClick:s,"aria-label":k("close"),className:"p-2 rounded-full hover:bg-muted",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:p,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:j("slashCommands.searchPlaceholder"),className:"w-full px-3 py-2 border border-input bg-surface dark:bg-surface-2 text-foreground rounded-lg focus:outline-none focus:ring-2 focus:ring-ring"})}),d&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(h),className:"w-full px-4 py-3 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j("slashCommands.enterCustomCommand")})]}),(0,r.jsx)(K,{groups:N,onSelect:S,highlightedIndex:f,className:"flex-1 overflow-y-auto pb-20",cliToolId:m}),E]})]});let I=o?{top:o.top,left:o.left}:{bottom:"100%",left:0,marginBottom:"4px"};return(0,r.jsxs)("div",{ref:b,role:"listbox","data-testid":"slash-command-dropdown",className:"absolute bg-surface border border-border rounded-lg shadow-lg z-50 w-80 max-h-96 flex flex-col",style:0!==y.x||0!==y.y?{...I,transform:"translate(".concat(y.x,"px, ").concat(y.y,"px)")}:I,children:[(0,r.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,r.jsx)("input",{ref:p,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:j("slashCommands.searchPlaceholder"),className:"w-full px-3 py-1.5 text-sm border border-input bg-surface dark:bg-surface-2 text-foreground rounded focus:outline-none focus:ring-1 focus:ring-ring"})}),d&&(0,r.jsxs)("button",{type:"button","data-testid":"free-input-button",onClick:()=>d(h),className:"w-full px-3 py-2 text-left border-b border-border flex items-center gap-2 hover:bg-accent-50 dark:hover:bg-accent-900/30 transition-colors text-sm",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j("slashCommands.enterCustomCommand")})]}),(0,r.jsx)(K,{groups:N,onSelect:S,highlightedIndex:f,className:"flex-1 overflow-y-auto",cliToolId:m}),E,(0,r.jsxs)("div",{className:"px-3 py-1.5 border-t border-border text-xs text-muted-foreground flex gap-3",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Enter"})," ",j("slashCommands.selectHint")]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Esc"})," ",j("slashCommands.closeHint")]})]})]})}),J=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disabled:s=!1,onInterrupt:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)(!1),h=(0,i.useRef)(0),x=(0,i.useCallback)(async()=>{let e=Date.now();if(!(e-h.current<1e3)){h.current=e,m(!0);try{let e=a&&a!==n?{cliToolId:n,instanceId:a}:{cliToolId:n},r=await fetch("/api/worktrees/".concat(t,"/interrupt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok)null==l||l();else{let e=await r.json().catch(()=>({}));console.error("[InterruptButton] Failed to send interrupt:",e.error||r.statusText)}}catch(e){console.error("[InterruptButton] Error sending interrupt:",e)}finally{m(!1)}}},[t,n,a,l]);return(0,r.jsx)("button",{type:"button",onClick:x,disabled:s||d,className:"flex-shrink-0 p-2 text-danger hover:bg-danger/10 rounded-full transition-colors disabled:text-muted-foreground/40 disabled:hover:bg-transparent","aria-label":o("interrupt.stopProcessing"),"data-testid":"interrupt-button",children:d?(0,r.jsx)(u.y,{size:"md"}):(0,r.jsx)(G,{})})});function G(){return(0,r.jsx)("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}var Y=n(74385),X=n(38218),Q=n(19985);let Z="commandmate:draft-message:",ee="Queued (session busy) — your message will run after the current task finishes.";function et(e,t){return"".concat(Z).concat(e,":").concat(t)}let en=(0,i.memo)(function(e){let{worktreeId:t,onMessageSent:n,cliToolId:a,instanceId:s,isSessionRunning:l=!1,pendingInsertText:o,onInsertConsumed:d,splitIndex:u=0,onFocus:h,isProcessing:x=!1,showToast:f,autoYesSlot:g,onOptimisticSend:p}=e,b=(0,c.c)("worktree"),[v,y]=(0,i.useState)(""),[w,j]=(0,i.useState)(!1),[k,N]=(0,i.useState)(null),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(!1),[I,M]=(0,i.useState)(!1),L=(0,i.useRef)(null),A=(0,i.useRef)(null),R=(0,i.useRef)(!1),P=(0,i.useRef)(null),F=(0,i.useRef)(null),D=(0,X.a)(),{groups:z,isCatalogStale:O}=function(e,t){let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(!0),[l,o]=(0,i.useState)(null),[c,d]=(0,i.useState)(""),[u,m]=(0,i.useState)(t||"claude"),[h,x]=(0,i.useState)({}),f=(0,i.useCallback)(async()=>{try{var n;s(!0),o(null);let r=e?"/api/worktrees/".concat(e,"/slash-commands"):"/api/slash-commands";t&&(r+="?cliTool=".concat(t));let l=await fetch(r,{cache:"no-store"});if(!l.ok)throw Error("HTTP error ".concat(l.status));let i=await l.json();a(i.groups),m(i.cliTool||t||"claude"),x(null!=(n=i.catalogStaleness)?n:{})}catch(e){o((0,_.hS)(e)),a([]),x({})}finally{s(!1)}},[e,t]);(0,i.useEffect)(()=>{f()},[f]),(0,i.useEffect)(()=>{if(!e)return;let t=t=>{let n=t.detail;(null==n?void 0:n.worktreeId)===e&&f()};return window.addEventListener(Y.I,t),()=>window.removeEventListener(Y.I,t)},[e,f]);let g=(0,i.useMemo)(()=>n.flatMap(e=>e.commands),[n]),p=(0,i.useMemo)(()=>H(n,c),[n,c]),b=(0,i.useMemo)(()=>Object.values(h).some(e=>e.stale),[h]);return{groups:n,filteredGroups:p,allCommands:g,loading:r,error:l,filter:c,setFilter:d,refresh:(0,i.useCallback)(()=>{f()},[f]),cliTool:u,isCatalogStale:b}}(t,a),{attachedImage:B,fileInputRef:U,isUploading:K,error:$,acceptAttribute:G,openFileDialog:en,handleFileSelect:ea,removeAttachment:er,resetAfterSend:es}=function(e,t){let[n,a]=(0,i.useState)(null),[r,s]=(0,i.useState)(!1),[l,o]=(0,i.useState)(null),c=(0,i.useRef)(null),d=(0,i.useCallback)(()=>{var e;null==(e=c.current)||e.click()},[]),u=(0,i.useCallback)(async n=>{var r;let l=null==(r=n.target.files)?void 0:r[0];if(!l)return;o(null);let i=function(e){let t=e.name.lastIndexOf(".");if(-1===t)return"Unsupported file format";let n=(0,Q.HB)(e.name.substring(t));if(!Q.Hv.includes(n))return"Unsupported file format: ".concat(n);if(e.size>Q.Fg){let e=Q.Fg/1024/1024;return"File size exceeds ".concat(e,"MB limit")}return null}(l);if(i){o(i),c.current&&(c.current.value="");return}s(!0);try{let n=await t(e,l);a({file:l,path:n.path})}catch(e){o(e instanceof Error?e.message:"Upload failed")}finally{s(!1),c.current&&(c.current.value="")}},[e,t]),m=(0,i.useCallback)(()=>{a(null),o(null)},[]),h=(0,i.useCallback)(()=>{a(null)},[]);return{attachedImage:n,fileInputRef:c,isUploading:r,error:l,acceptAttribute:Q.F5,openFileDialog:d,handleFileSelect:u,removeAttachment:m,resetAfterSend:h}}(t,(0,i.useCallback)((e,t)=>_.y.uploadImageFile(e,t),[]));(0,i.useEffect)(()=>{try{0===u&&function(e){try{let t="".concat(Z).concat(e),n=window.localStorage.getItem(t);if(null===n)return;let a=et(e,0);null===window.localStorage.getItem(a)&&window.localStorage.setItem(a,n),window.localStorage.removeItem(t)}catch(e){}}(t);let e=window.localStorage.getItem(et(t,u));e?y(e):y("")}catch(e){}return()=>{F.current&&clearTimeout(F.current)}},[t,u]),(0,i.useEffect)(()=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{try{let e=et(t,u);v?window.localStorage.setItem(e,v):window.localStorage.removeItem(e)}catch(e){}},500)},[v,t,u]),(0,i.useEffect)(()=>{let e=L.current;e&&(v?(e.style.height="auto",e.style.height="".concat(Math.min(e.scrollHeight,160),"px")):e.style.height="24px")},[v]),(0,i.useEffect)(()=>{o&&(y(e=>""===e.trim()?o:e+"\n\n"+o),null==d||d())},[o,d]);let el=(0,i.useCallback)(async()=>{if(C||!v.trim()&&!B||w)return;let e=v.trim(),r=a||"claude",l={cliToolId:r};if(s&&s!==r&&(l.instanceId=s),B&&(l.imagePath=B.path),p){N(null),p(e,l),y(""),M(!1),es();try{window.localStorage.removeItem(et(t,u))}catch(e){}x&&(null==f||f(ee,"warning")),null==n||n(r);return}try{j(!0),N(null),await _.y.sendMessage(t,e,l),y(""),M(!1),es();try{window.localStorage.removeItem(et(t,u))}catch(e){}x&&(null==f||f(ee,"warning")),null==n||n(r)}catch(e){N((0,_.hS)(e))}finally{j(!1)}},[C,v,B,w,t,a,s,n,es,u,x,f,p]),ei=(0,i.useCallback)(async e=>{e.preventDefault(),await el()},[el]),eo=(0,i.useCallback)(()=>{S(!0),R.current=!1,A.current&&clearTimeout(A.current)},[]),ec=(0,i.useCallback)(()=>{S(!1),R.current=!0,A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{R.current=!1},300)},[]),ed=(0,i.useCallback)(e=>{var t;y("".concat(V(e,a)," ")),E(!1),null==(t=L.current)||t.focus()},[a]),eu=(0,i.useCallback)(()=>{var e;E(!1),M(!1),null==(e=L.current)||e.focus()},[]),em=(0,i.useCallback)(e=>{E(!1),M(!0),y(e?"/".concat(e):"/"),setTimeout(()=>{var e;null==(e=L.current)||e.focus()},50)},[]),eh=(0,i.useCallback)(e=>{let t=e.target.value;if(y(t),""===t){M(!1),E(!1);return}if(I)return;let n="/"===t||t.startsWith("/")&&!t.includes(" "),r="codex"===a&&("$"===t||t.startsWith("$")&&!t.includes(" "));n||r?E(!0):E(!1)},[I,a]),ex=(0,i.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&T){e.preventDefault(),eu();return}if(R.current&&"Enter"===e.key){R.current=!1;return}if("Enter"===e.key&&!C&&(!T||I)){if(D)return;e.shiftKey||(e.preventDefault(),el())}}},[T,I,C,D,el,eu]);return(0,r.jsxs)("div",{ref:P,className:"space-y-2 relative","data-testid":"message-input-container",children:[(k||$)&&(0,r.jsx)("div",{className:"p-2 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:k||$}),B&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-accent-50 dark:bg-accent-900/20 border border-accent-200 dark:border-accent-800 rounded-lg text-sm","data-testid":"image-attachment-preview",children:[(0,r.jsx)("svg",{className:"h-4 w-4 flex-shrink-0 text-accent-600 dark:text-accent-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),(0,r.jsx)("span",{className:"truncate text-accent-800 dark:text-accent-300",children:B.file.name}),(0,r.jsx)("button",{type:"button",onClick:er,className:"flex-shrink-0 p-0.5 text-accent-600 hover:text-danger-foreground dark:text-accent-400 rounded transition-colors","aria-label":b("composer.removeAttachment"),"data-testid":"remove-attachment-button",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("input",{ref:U,type:"file",accept:G,onChange:ea,className:"hidden","data-testid":"image-file-input"}),(0,r.jsxs)("form",{onSubmit:ei,className:"rounded-xl bg-surface border border-border shadow-sm px-3 py-2 focus-within:ring-2 focus-within:ring-accent-500/40 transition-shadow flex flex-col gap-1.5",children:[(0,r.jsxs)("div",{className:D?"flex flex-col gap-1":"flex items-center gap-2",children:[D&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>{I&&M(!1),E(!0)},className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors","aria-label":b("composer.showSlashCommands"),"data-testid":"mobile-command-button",children:(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:en,disabled:K||w,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":b("composer.attachImage"),"data-testid":"attach-image-button",children:K?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsx)(J,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l})]}),!D&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:en,disabled:K||w,className:"flex-shrink-0 p-2 text-muted-foreground hover:text-accent-600 hover:bg-accent-50 dark:hover:text-accent-400 dark:hover:bg-accent-900/30 rounded-full transition-colors disabled:text-muted-foreground/50 disabled:hover:bg-transparent","aria-label":b("composer.attachImage"),"data-testid":"attach-image-button",children:K?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,r.jsx)("textarea",{ref:L,"data-testid":"message-input-textarea",value:v,onChange:eh,onKeyDown:ex,onCompositionStart:eo,onCompositionEnd:ec,onFocus:h,placeholder:b("composer.placeholder"),disabled:w,rows:1,inputMode:"text",enterKeyHint:"send",className:"flex-1 outline-none bg-transparent resize-none overflow-y-auto scrollbar-thin",style:{minHeight:"36px",maxHeight:"160px",paddingTop:"8px",paddingBottom:"8px",lineHeight:"20px"}}),!D&&(0,r.jsx)(J,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l}),(0,r.jsx)(m.$n,{variant:"ghost",type:"submit","data-testid":"send-message-button","data-can-send":String((!!v.trim()||!!B)&&!w),disabled:!v.trim()&&!B||w,className:"flex-shrink-0 p-2 rounded-full transition-colors disabled:hover:bg-transparent ".concat((v.trim()||B)&&!w?"bg-accent-600 text-white hover:bg-accent-700 shadow-sm":"text-muted-foreground/50"),"aria-label":b("composer.sendMessage"),children:w?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]})]}),(g||!D)&&(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0","data-testid":"composer-meta-row",children:[(0,r.jsx)("div",{className:"flex items-center gap-2 min-w-0 overflow-x-auto scrollbar-hide",children:g}),!D&&(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground select-none",children:[(0,r.jsx)(W.u,{children:"/"}),(0,r.jsx)("span",{children:b("composer.commandsHint")}),(0,r.jsx)("span",{"aria-hidden":"true",className:"opacity-50",children:"\xb7"}),(0,r.jsx)(W.u,{children:"⇧"}),(0,r.jsx)(W.u,{children:"↵"}),(0,r.jsx)("span",{children:b("composer.newlineHint")})]})]})]}),(0,r.jsx)(q,{isOpen:T,groups:z,onSelect:ed,onClose:eu,isMobile:D,onFreeInput:em,isCatalogStale:O,cliToolId:a})]})});var ea=n(9900);function er(e,t,n,a){return(0,i.useCallback)(r=>{let s=n&&n!==t?{cliToolId:t,keys:r,instanceId:n}:{cliToolId:t,keys:r};fetch("/api/worktrees/".concat(encodeURIComponent(e),"/special-keys"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}).then(()=>{a&&setTimeout(a,ea.LK)}).catch(e=>{console.error("Failed to send special keys:",e)})},[e,t,n,a])}let es=[{key:"Left",label:"◀",ariaLabel:"Left"},{key:"Up",label:"▲",ariaLabel:"Up"},{key:"Down",label:"▼",ariaLabel:"Down"},{key:"Right",label:"▶",ariaLabel:"Right"},{key:"Enter",label:"↵",ariaLabel:"Enter"},{key:"Escape",label:"Esc",ariaLabel:"Escape"}],el=[{key:"PageUp",label:"PgUp",ariaLabel:"Page Up"},{key:"PageDown",label:"PgDn",ariaLabel:"Page Down"},{key:"Home",label:"Home",ariaLabel:"Home"},{key:"End",label:"End",ariaLabel:"End"},{key:"q",label:"q",ariaLabelKey:"navigation.quitPager"}];function ei(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:s,showPagerKeys:l=!1}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(null),m=er(t,n,a,s),h=(0,i.useCallback)(e=>{u(e[0]),setTimeout(()=>u(null),ea.tX),m(e)},[m]),x=(0,i.useMemo)(()=>l?[...es,...el]:es,[l]),f=(0,i.useCallback)(e=>{let t={ArrowLeft:"Left",ArrowUp:"Up",ArrowDown:"Down",ArrowRight:"Right",Enter:"Enter",Escape:"Escape"}[e.key];t&&(e.preventDefault(),h([t]))},[h]);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-muted rounded-lg",onKeyDown:f,role:"toolbar","aria-label":o("navigation.toolbarLabel"),children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mx-2",children:o("navigation.caption")}),x.map(e=>{let{key:t,label:n,ariaLabel:a,ariaLabelKey:s}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-border\n focus:outline-none focus:ring-2 focus:ring-ring\n transition-colors duration-75\n ".concat(d===t?"bg-accent-500 text-white border-accent-500 scale-95":"bg-surface dark:bg-surface-2 hover:bg-muted active:bg-muted"),"aria-label":s?o(s):a,onClick:()=>h([t]),children:n},t)})]})}var eo=n(36402),ec=n(17846),ed=n(69264),eu=n(27307),em=n(24027),eh=n(5917),ex=n(75426),ef=n(51963),eg=n(39867);let ep="flex w-full items-center gap-3 rounded-lg px-3 min-h-[44px] py-3 text-sm text-foreground hover:bg-muted transition-colors touch-manipulation";function eb(e){let{open:t,onClose:n,onSearch:a,onCopyContent:s,onCopyPath:l,downloadUrl:o,downloadName:d,contentCopied:u,pathCopied:m}=e,h=(0,c.c)("worktree"),x=(0,i.useId)(),f=(0,M.r)({active:t}),g=(0,i.useCallback)(()=>{a(),n()},[a,n]),p=(0,i.useCallback)(()=>{s(),n()},[s,n]),b=(0,i.useCallback)(()=>{l(),n()},[l,n]);return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(e.stopPropagation(),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),t)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"file-actions-overlay",onClick:n,className:"fixed inset-0 bg-black/50 z-50","aria-hidden":"true"}),(0,r.jsxs)("div",{ref:f,"data-testid":"mobile-file-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":x,tabIndex:-1,className:"fixed bottom-0 inset-x-0 z-50 rounded-t-2xl border-t border-border bg-surface pb-safe",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-2",children:(0,r.jsx)("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30","aria-hidden":"true"})}),(0,r.jsx)("h2",{id:x,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:h("fileViewer.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-search",onClick:g,className:ep,children:[(0,r.jsx)(z.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.searchInFile")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-content",onClick:p,className:ep,children:[u?(0,r.jsx)(eh.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ex.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.copyFileContent")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-path",onClick:b,className:ep,children:[m?(0,r.jsx)(eh.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ef.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:o,download:d,onClick:n,className:ep,"aria-label":h("actions.downloadFile"),children:[(0,r.jsx)(eg.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.downloadFile")]})]})]})]}):null}var ev=n(11063),ey=n(60322),ew=n(65229),ej=n(97624),ek=n(37354),eN=n(57828),eC=n(18514),eS=n(59854),eT=n(76246);let eE={highlightName:"terminal-search",currentHighlightName:"terminal-search-current",fallbackOverlayId:"terminal-search-fallback-overlay",fallbackOverlayBgColor:"rgba(255, 165, 0, 0.6)"},eI={highlightName:"history-search",currentHighlightName:"history-search-current",fallbackOverlayId:"history-search-fallback-overlay",fallbackOverlayBgColor:"rgba(59, 130, 246, 0.6)"};function eM(){return"undefined"!=typeof CSS&&null!==CSS&&"highlights"in CSS}function eL(e,t,n){let a=document.createRange(),r=!1;for(let{node:s,start:l,end:i}of e)if(!r&&t<i&&t>=l&&(a.setStart(s,t-l),r=!0),r&&n<=i)return a.setEnd(s,n-l),a;return r?a:null}function eA(e){var t;eM()&&(CSS.highlights.delete(e.highlightName),CSS.highlights.delete(e.currentHighlightName)),null==(t=document.getElementById(e.fallbackOverlayId))||t.remove()}function eR(e,t,n,a){if(0===t.length)return void eA(a);let r=function(e){let t,n=[],a=0,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;t=r.nextNode();){var s,l;let e=null!=(l=null==(s=t.nodeValue)?void 0:s.length)?l:0;n.push({node:t,start:a,end:a+e}),a+=e}return n}(e),s=t[n],l=s?eL(r,s.start,s.end):null;if(eM()){let e=[];t.forEach((t,a)=>{if(a===n)return;let s=eL(r,t.start,t.end);s&&e.push(s)}),CSS.highlights.set(a.highlightName,new Highlight(...e)),CSS.highlights.delete(a.currentHighlightName)}if(function(e,t,n){let a=document.getElementById(n.fallbackOverlayId);if(!t||"function"!=typeof t.getBoundingClientRect){null==a||a.remove();return}let r=t.getBoundingClientRect(),s=e.getBoundingClientRect();a?a.style.backgroundColor=n.fallbackOverlayBgColor:((a=document.createElement("div")).id=n.fallbackOverlayId,a.style.position="absolute",a.style.backgroundColor=n.fallbackOverlayBgColor,a.style.borderRadius="2px",a.style.pointerEvents="none",a.style.zIndex="5",e instanceof HTMLElement&&(e.style.position="relative"),e.appendChild(a)),a.style.top="".concat(r.top-s.top+e.scrollTop,"px"),a.style.left="".concat(r.left-s.left+e.scrollLeft,"px"),a.style.width="".concat(r.width,"px"),a.style.height="".concat(r.height,"px")}(e,l,a),l){let e=l.startContainer,t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})}}function eP(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eI;eA(e)}function eF(e){let[t,n]=(0,i.useState)(!1),[a,r]=(0,i.useState)(""),[s,l]=(0,i.useState)(""),[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(0),m=(0,i.useRef)(null),h=(0,i.useRef)(null),x=(0,i.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),f=(0,i.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),g=(0,i.useCallback)(()=>{n(!1),r(""),l(""),c([]),u(0),f()},[f]);(0,i.useEffect)(()=>{if(!a||a.length<2){l(""),f();return}return f(),h.current=setTimeout(()=>{l(a)},300),f},[a,f]),(0,i.useEffect)(()=>{if(!s||s.length<2||!e){c([]),u(0);return}let t=e.split("\n"),n=s.toLowerCase(),a=[];t.forEach((e,t)=>{e.toLowerCase().includes(n)&&a.push(t+1)}),c(a),u(0)},[s,e]);let p=(0,i.useCallback)(()=>{0!==o.length&&u(e=>(e+1)%o.length)},[o.length]),b=(0,i.useCallback)(()=>{0!==o.length&&u(e=>(e-1+o.length)%o.length)},[o.length]);return{searchOpen:t,searchQuery:a,searchMatches:o,searchCurrentIdx:d,searchInputRef:m,openSearch:x,closeSearch:g,nextMatch:p,prevMatch:b,setSearchQuery:r}}var eD=n(90487);function ez(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex h-full items-center justify-center bg-surface text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}n(1226);let eO=(0,o.default)(()=>n.e(9263).then(n.bind(n,79263)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[79263]},ssr:!1,loading:()=>(0,r.jsx)(ez,{})}),eB="flex min-h-[44px] min-w-[44px] flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface hover:text-foreground transition-colors touch-manipulation",e_=/^---\s*\nmarp:\s*true/;function eW(e){let{searchInputRef:t,searchQuery:n,searchMatches:a,searchCurrentIdx:s,onQueryChange:l,onPrev:i,onNext:o,onClose:d}=e,u=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-border",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>l(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d(),"Enter"===e.key&&(e.shiftKey?i():o())},placeholder:u("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:bg-surface-2 text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:a.length>0?"".concat(s+1,"/").concat(a.length):"0/0"}),(0,r.jsx)("button",{onClick:i,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)("button",{onClick:o,disabled:0===a.length,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground disabled:text-muted-foreground","aria-label":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)("button",{onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground","aria-label":u("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})}let eH="\n<script>\ndocument.addEventListener('click', function(e) {\n var target = e.target;\n while (target && target.tagName !== 'A') {\n target = target.parentElement;\n }\n if (target && target.href) {\n e.preventDefault();\n parent.postMessage({\n type: 'commandmate:link-click',\n href: target.getAttribute('href')\n }, '*');\n }\n});\n<\/script>";function eV(e){let{htmlContent:t,filePath:n}=e,[a,s]=(0,i.useState)("preview"),[l,o]=(0,i.useState)("safe"),d=(0,i.useRef)(new Set),u=(0,c.c)("worktree"),m=(0,eo.SC)(),h=(0,i.useCallback)(async e=>{if("interactive"===e&&!d.current.has(n)){if(!await m({description:u("htmlPreview.interactiveModeConfirm")}))return;d.current.add(n)}o(e)},[n,m,u]),x=(0,i.useMemo)(()=>"interactive"!==l?t:t.includes("</body>")?t.replace("</body>","".concat(eH,"</body>")):t+eH,[t,l]);(0,i.useEffect)(()=>{if("interactive"!==l)return;let e=e=>{if("null"!==e.origin)return;let t=e.data;if(!t||"object"!=typeof t||"commandmate:link-click"!==t.type||"string"!=typeof t.href)return;let n=t.href;(n.startsWith("http://")||n.startsWith("https://"))&&window.open(n,"_blank","noopener,noreferrer")};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[l]);let f=(0,i.useMemo)(()=>{try{return eD.A.highlight(t,{language:"html",ignoreIllegals:!0}).value}catch(e){return eD.A.highlightAuto(t).value}},[t]),g=(0,i.useMemo)(()=>Array.from({length:t.split("\n").length},(e,t)=>t+1),[t]),p=(0,i.useMemo)(()=>f.split("\n"),[f]);return(0,r.jsxs)("div",{className:"flex flex-col h-full","data-testid":"html-preview-mobile",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsx)("div",{className:"flex gap-1",children:["source","preview"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>s(e),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat(a===e?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:"source"===e?u("fileViewer.tabSource"):u("fileViewer.tabPreview")},e))}),(0,r.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>h(e),className:"px-2 py-1 text-xs font-medium rounded-md transition-colors ".concat(l===e?"safe"===e?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"),children:"safe"===e?u("fileViewer.sandboxSafe"):u("fileViewer.sandboxInteractive")},e))})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===a?(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:g.map(e=>{var t;let n=e-1;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap text-muted-foreground",children:e}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(t=p[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:x,sandbox:ev.Ko[l],title:u("htmlPreview.title",{path:n}),className:"w-full h-full border-0 bg-white"},"".concat(n,"-").concat(l))})]})}let eU=(0,i.memo)(function(e){let{isOpen:t,onClose:n,worktreeId:a,filePath:s,onFileSaved:l,onOpenFile:o}=e,[u,h]=(0,i.useState)(null),[x,f]=(0,i.useState)(!1),[g,p]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),[y,w]=(0,i.useState)(!1),[j,k]=(0,i.useState)(null),[N,C]=(0,i.useState)(0),[S,T]=(0,i.useState)(!1),[E,I]=(0,i.useState)("viewer"),[M,L]=(0,i.useState)(!1),[A,R]=(0,i.useState)(null),[P,F]=(0,i.useState)(!1),D=(0,i.useRef)(null),O=(0,c.c)("worktree"),B=(0,eo.SC)(),_=u?null!=A?A:u.content:void 0,{searchOpen:W,searchQuery:H,searchMatches:V,searchCurrentIdx:U,searchInputRef:K,openSearch:$,closeSearch:q,nextMatch:J,prevMatch:G,setSearchQuery:Y}=eF(_),X=(0,i.useMemo)(()=>!!((null==u?void 0:u.content)&&!u.isImage&&!u.isVideo&&!u.isPdf),[u]),Q=(null==u?void 0:u.extension)==="md",Z=(0,i.useCallback)(async()=>{if(X&&_)try{await (0,ey.l)(_),v(!0),setTimeout(()=>v(!1),ea.pX)}catch(e){}},[X,_]),ee=(0,i.useCallback)(async()=>{try{await (0,ey.l)(s),w(!0),setTimeout(()=>w(!1),ea.pX)}catch(e){}},[s]),et=(0,i.useCallback)(()=>{T(e=>!e)},[]);(0,i.useEffect)(()=>{if(0===V.length||!D.current)return;let e=V[U],t=D.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[U,V]),(0,i.useEffect)(()=>{if(!S||Q)return;let e=e=>{"Escape"===e.key&&T(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[S,Q]),(0,i.useEffect)(()=>{if(!t||!s){h(null),p(null),v(!1),I("viewer"),L(!1),R(null),F(!1),q();return}I("viewer"),L(!1),R(null),F(!1),(async()=>{f(!0),p(null);try{let t=await fetch("/api/worktrees/".concat(a,"/files/").concat((0,eT.o)(s)));if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||O("fileViewer.loadError");throw Error(a)}let n=await t.json();h(n)}catch(e){p(e instanceof Error?e.message:O("fileViewer.loadError"))}finally{f(!1)}})()},[t,a,s]),(0,i.useEffect)(()=>{k(null),C(0),u&&"md"===u.extension&&e_.test(u.content)&&!(u.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(a,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:u.content})});if(e.ok){let t=await e.json();k(t.slides)}}catch(e){}})()},[u,a]);let en=!!(j&&j.length>0),er=(0,i.useCallback)(e=>{R(e)},[]),es=(0,i.useCallback)((e,t)=>{h(e=>e?{...e,content:t}:e),R(t),null==l||l(e)},[l]),el=(0,i.useCallback)(async()=>{(!P||await B({description:O("editor.unsavedCloseConfirm"),variant:"danger"}))&&n()},[P,B,O,n]);(0,i.useEffect)(()=>{if(!Q||M)return;let e=e=>{"Escape"===e.key&&(W?q():S?T(!1):el())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[Q,M,W,S,el]);let[ei,ep]=(0,i.useState)("");(0,i.useEffect)(()=>{"viewer"===E&&void 0!==_&&ep(_)},[E,_]),(0,i.useEffect)(()=>{if(!Q||!t)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[Q,t]);let ev=(0,i.useMemo)(()=>{if(!u||void 0===_||u.isImage||u.isVideo||u.isHtml||u.isPdf)return null;let e=Array.from({length:_.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:eD.A.highlight(_,{language:u.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:eD.A.highlightAuto(_).value}}},[u,_]),eE=()=>u?u.isImage?(0,r.jsx)(ec.a,{src:u.content,alt:u.path,mimeType:u.mimeType}):u.isVideo?(0,r.jsx)(ed.u,{src:u.content,mimeType:u.mimeType}):u.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(eu.PdfPreview,{dataUri:u.content,filePath:s,variant:"download"})}):u.isHtml?(0,r.jsx)(eV,{htmlContent:u.content,filePath:s}):eI():null,eI=()=>{if(!ev)return null;let e=new Set(V),t=V.length>0?V[U]:-1,n=ev.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:D,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:ev.lineNumbers.map(a=>{var s;let l=a-1,i=a===t,o=e.has(a);return(0,r.jsxs)("tr",{"data-line":a,className:i?"bg-warning/30":o?"bg-warning/15":"",children:[(0,r.jsx)("td",{className:"pl-3 pr-2 text-right select-none font-mono border-r border-border bg-muted dark:bg-muted/50 sticky left-0 align-top whitespace-nowrap ".concat(i||o?"text-warning-foreground":"text-muted-foreground"),children:a}),(0,r.jsx)("td",{className:"px-4 text-foreground align-top",children:(0,r.jsx)("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono",children:(0,r.jsx)("code",{className:"hljs",dangerouslySetInnerHTML:{__html:null!=(s=n[l])?s:""}})})})]},a)})})})})},eM="/api/worktrees/".concat(a,"/files/").concat((0,eT.o)(s),"?download=1"),eL=s?s.split("/").pop()||s:"",eA=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:eM,download:eL,className:e,"aria-label":O("actions.downloadFile"),title:O("actions.download"),children:[(0,r.jsx)(eg.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:O("actions.download")})]})},eR=()=>(0,r.jsxs)("div",{className:"bg-muted px-3 py-1.5 border-b border-border flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{onClick:ee,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.copyFilePath"),title:O("actions.copyPath"),children:y?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:s})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[X&&(0,r.jsx)("button",{onClick:$,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.searchInFile"),title:O("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),X&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:Z,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":O("actions.copyFileContent"),title:O("actions.copyContent"),children:b?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5"})}),eA("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:et,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":S?O("actions.exitFullscreen"):O("actions.fullscreen"),title:S?O("actions.exitFullscreen"):O("actions.fullscreen"),children:S?(0,r.jsx)(ej.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(ek.A,{className:"w-3.5 h-3.5"})})]})]}),eP=()=>(0,r.jsx)(eW,{searchInputRef:K,searchQuery:H,searchMatches:V,searchCurrentIdx:U,onQueryChange:Y,onPrev:G,onNext:J,onClose:q});if(Q&&u&&!x&&!g){let e=e=>"flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ".concat(e?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground");return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":s,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:eS.M.MAXIMIZED_EDITOR},children:[S?(0,r.jsxs)("div",{"data-testid":"markdown-file-immersive-controls",className:"absolute right-2 top-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-surface/90 shadow-sm",children:[(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:et,"aria-pressed":!0,"aria-label":O("actions.exitFullscreen"),className:eB,children:(0,r.jsx)(ej.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void el(),"aria-label":O("actions.close"),className:eB,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}):(0,r.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 border-b border-border bg-muted px-2",children:[(0,r.jsx)("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:s}),(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":O("fileViewer.modeSwitch"),className:"flex flex-shrink-0 items-center gap-0.5 rounded-lg bg-muted p-0.5",children:[(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-viewer","aria-pressed":"viewer"===E,onClick:()=>I("viewer"),className:e("viewer"===E),children:[(0,r.jsx)(eN.A,{className:"h-4 w-4"}),O("fileViewer.modeViewer")]}),(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===E,onClick:()=>I("editor"),className:e("editor"===E),children:[(0,r.jsx)(eC.A,{className:"h-4 w-4"}),O("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>L(!0),"aria-label":O("fileViewer.moreActions"),className:eB,children:(0,r.jsx)(d.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:et,"aria-pressed":!1,"aria-label":O("actions.fullscreen"),className:eB,children:(0,r.jsx)(ek.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void el(),"aria-label":O("actions.close"),className:eB,children:(0,r.jsx)(ew.A,{className:"h-5 w-5"})})]}),W&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eP()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===E?"flex min-h-0 flex-1 flex-col":"hidden",children:W?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eI()}):en?j?(0,r.jsxs)("div",{className:"flex h-full flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 bg-muted border-b border-border",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>Math.max(0,e-1)),disabled:0===N,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:O("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[N+1," / ",j.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>Math.min(j.length-1,e+1)),disabled:N===j.length-1,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:O("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:j[N],sandbox:"",title:O("fileViewer.slideTitle",{name:s,number:N+1}),className:"w-full flex-1 border-0"})]}):null:(0,r.jsx)("div",{"data-testid":"markdown-file-preview",className:"prose prose-sm dark:prose-invert min-h-0 max-w-none flex-1 overflow-y-auto p-4",children:(0,r.jsx)(em.G8,{content:ei,currentFilePath:s,worktreeId:a,onOpenFile:o})})}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===E?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(eO,{worktreeId:a,filePath:s,initialContent:u.content,embedded:!0,onSave:es,onDirtyChange:F,onContentChange:er,onOpenFile:o},s)})]}),(0,r.jsx)(eb,{open:M,onClose:()=>L(!1),onSearch:()=>{I("viewer"),$()},onCopyContent:Z,onCopyPath:ee,downloadUrl:eM,downloadName:eL,contentCopied:b,pathCopied:y})]})})}return S&&u&&!x&&!g?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eS.M.MAXIMIZED_EDITOR},children:[eR(),W&&eP(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:eE()})]}):(0,r.jsx)(m.Jh,{isOpen:t,onClose:n,title:s,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[x&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:O("fileViewer.loading")})]}),g&&(0,r.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-sm text-danger-foreground",children:g})]}),(0,r.jsx)("div",{className:"mt-3",children:eA("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium bg-surface border border-border text-foreground hover:bg-muted transition-colors",!0)})]}),u&&!x&&!g&&(0,r.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex-shrink-0",children:[eR(),W&&eP()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:eE()})]})]})})});var eK=n(46892),e$=n(41898),eq=n(26232),eJ=n(50857),eG=n(94442);function eY(e){let{worktreeId:t}=e,[n,a]=(0,i.useState)([]),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),[u,h]=(0,i.useState)(!0),[f,g]=(0,i.useState)(null),[p,b]=(0,i.useState)(""),[v,y]=(0,i.useState)(0),[w,j]=(0,i.useState)("all"),[k,N]=(0,i.useState)(!1),{showToast:C}=(0,eG.dj)(),S=(0,c.c)("worktree");(0,i.useEffect)(()=>{(async()=>{try{h(!0),g(null);let e=await _.y.getLogs(t);a(e)}catch(e){g((0,_.hS)(e))}finally{h(!1)}})()},[t]);let T=(0,i.useMemo)(()=>"all"===w?n:n.filter(e=>e.toLowerCase().includes(w)),[n,w]),E=async e=>{try{h(!0),g(null);let n=await _.y.getLogFile(t,e);d(n.content),l(e),b(""),y(0)}catch(e){g((0,_.hS)(e))}finally{h(!1)}},I=(0,i.useCallback)(async()=>{if(s)try{N(!0);let e=await _.y.getLogFile(t,s,{sanitize:!0});await (0,ey.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,_.hS)(e)}),"error")}finally{N(!1)}},[t,s,C,S]),M=(0,i.useMemo)(()=>{let e;if(!p||!o)return[];let t=RegExp((0,x.Nt)(p),"gi"),n=[];for(;null!==(e=t.exec(o));)n.push({index:e.index,length:e[0].length});return n},[p,o]);(0,i.useEffect)(()=>{y(0)},[p]);let L=()=>{M.length>0&&y(e=>(e+1)%M.length)},A=()=>{M.length>0&&y(e=>(e-1+M.length)%M.length)},R=(0,i.useMemo)(()=>{if(!o||!p||0===M.length)return o;let e="",t=0;return M.forEach((n,a)=>{e+=(0,x.ZD)(o.substring(t,n.index));let r=o.substring(n.index,n.index+n.length),s=a===v;e+='<mark class="'.concat(s?"bg-warning text-black":"bg-warning-border text-black",'" data-match-index="').concat(a,'">').concat((0,x.ZD)(r),"</mark>"),t=n.index+n.length}),e+=(0,x.ZD)(o.substring(t))},[o,p,M,v]);return(0,i.useEffect)(()=>{M.length>0&&v>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(v,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[v,M.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.aR,{children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(m.ZB,{children:S("logViewer.title")}),(0,r.jsx)(m.Ex,{variant:"gray",children:T.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(m.$n,{variant:"all"===w?"primary":"ghost",size:"sm",onClick:()=>j("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(m.$n,{variant:"claude"===w?"primary":"ghost",size:"sm",onClick:()=>j("claude"),children:S("logViewer.toolCount",{tool:"Claude",count:n.filter(e=>e.toLowerCase().includes("claude")).length})}),(0,r.jsx)(m.$n,{variant:"codex"===w?"primary":"ghost",size:"sm",onClick:()=>j("codex"),children:S("logViewer.toolCount",{tool:"Codex",count:n.filter(e=>e.toLowerCase().includes("codex")).length})}),(0,r.jsx)(m.$n,{variant:"gemini"===w?"primary":"ghost",size:"sm",onClick:()=>j("gemini"),children:S("logViewer.toolCount",{tool:"Gemini",count:n.filter(e=>e.toLowerCase().includes("gemini")).length})}),(0,r.jsx)(m.$n,{variant:"antigravity"===w?"primary":"ghost",size:"sm",onClick:()=>j("antigravity"),children:S("logViewer.toolCount",{tool:"Antigravity",count:n.filter(e=>e.toLowerCase().includes("antigravity")).length})})]})]})}),(0,r.jsxs)(m.Wu,{children:[u&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)(m.y$,{size:"lg",variant:"accent",className:"inline-block"})}),f&&(0,r.jsx)("div",{className:"p-3 bg-danger-subtle border border-danger-border rounded text-sm text-danger-foreground",children:f}),!u&&0===T.length&&!f&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground text-center py-4",children:"all"===w?S("logViewer.empty"):S("logViewer.emptyFiltered",{tool:w})}),T.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:T.map(e=>(0,r.jsx)("button",{onClick:()=>E(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(s===e?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"),children:e},e))})]})]}),s&&(0,r.jsxs)(m.Zp,{padding:"md",children:[(0,r.jsx)(m.aR,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(m.ZB,{className:"font-mono text-base",children:s}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:I,disabled:!s||k,title:S("logViewer.copyTitle"),children:k?S("logViewer.exporting"):S("logViewer.export")}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{l(null),d(null),b(""),y(0)},children:S("actions.close")})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)(m.pd,{type:"text",value:p,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?A():L())},placeholder:S("logViewer.searchPlaceholder"),className:"w-full pr-20"}),M.length>0&&(0,r.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:[v+1," / ",M.length]})]}),M.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:A,disabled:0===M.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:L,disabled:0===M.length,title:S("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,r.jsxs)(m.Wu,{children:[u&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(m.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!u&&o&&(0,r.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:p&&M.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:R||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:o})}),!u&&p&&0===M.length&&o&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:p})})]})]})]})}function eX(){let[e,t]=(0,i.useState)(null),[n,a]=(0,i.useState)(!0),[r,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return async function(){try{a(!0),s(null);let n=await _.GQ.checkForUpdate();e||t(n)}catch(t){e||s(t instanceof Error?t.message:"Failed to check for updates")}finally{e||a(!1)}}(),()=>{e=!0}},[]),{data:e,loading:n,error:r}}var eQ=n(31166);function eZ(e){let{hasUpdate:t,latestVersion:n,releaseUrl:a,updateCommand:s,installType:l}=e,o=(0,c.c)("worktree"),[d,m]=(0,i.useState)("idle"),[h,x]=(0,i.useState)(null),[f,g]=(0,i.useState)(null),p=(0,i.useRef)(!1),b="global"===l,v="npx"===l,y=b||v,w=v?"npx commandmate@latest":"commandmate update",j=(0,i.useCallback)(async()=>{m("starting");try{let e=await _.GQ.startUpdate();x(e.logPath),m(e.willRestart?"updating":"no-restart")}catch(e){e instanceof _.hD&&400===e.status?g(o("update.errorNotGlobal")):e instanceof _.hD&&409===e.status?g(o("update.errorInProgress")):g(o("update.errorGeneric")),m("error")}},[o]);return((0,i.useEffect)(()=>{if("updating"!==d)return;let e=!1,t=Date.now();p.current=!1;let n=setInterval(async()=>{if(e)return;if(Date.now()-t>3e5)return void m("timeout");let n=await _.GQ.ping();if(!e){if(!n){p.current=!0;return}p.current&&window.location.reload()}},2e3);return()=>{e=!0,clearInterval(n)}},[d]),t)?(0,r.jsxs)("div",{className:"bg-accent-50 border border-accent-200 rounded-lg p-3 mt-2",role:"status","aria-label":o("update.available"),"data-testid":"update-notification-banner",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800 mb-1",children:o("update.available")}),n&&(0,r.jsx)("p",{className:"text-sm text-accent-700 mb-2",children:o("update.latestVersion",{version:n})}),y&&"idle"===d&&(0,r.jsx)(eQ.$,{variant:"primary",size:"sm",className:"mb-2",onClick:()=>m("confirming"),"data-testid":"update-now-button",children:o("update.updateNow")}),v&&"idle"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-2","data-testid":"update-npx-notice",children:o("update.npxRestartNotice")}),("starting"===d||"updating"===d)&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-progress",children:[(0,r.jsxs)("p",{className:"flex items-center text-sm text-accent-800",children:[(0,r.jsx)(u.y,{size:"sm",className:"mr-2"}),"starting"===d?o("update.starting"):o("update.updating")]}),"updating"===d&&(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.updatingHint")})]}),"no-restart"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-no-restart",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.noRestartTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.noRestartDescription")})]}),"timeout"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-timeout",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.timeoutTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:o("update.timeoutDescription")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:w})]}),"error"===d&&(0,r.jsxs)("div",{className:"mb-2","data-testid":"update-error",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-accent-800",children:o("update.errorTitle")}),(0,r.jsx)("p",{className:"text-xs text-accent-600 mt-1",children:f}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 mt-1 text-xs text-accent-900 font-mono",children:w})]}),h&&("no-restart"===d||"timeout"===d)&&(0,r.jsx)("p",{className:"text-xs text-accent-500 mb-2","data-testid":"update-log-hint",children:o("update.logHint",{path:h})}),s&&b&&"idle"===d&&(0,r.jsxs)("div",{className:"mb-2",children:[(0,r.jsx)("p",{className:"text-xs text-accent-600 mb-1",children:o("update.updateCommand")}),(0,r.jsx)("code",{className:"block bg-accent-100 rounded px-2 py-1 text-xs text-accent-900 font-mono",children:s})]}),a&&(0,r.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[o("update.viewRelease"),(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]}),(0,r.jsx)("p",{className:"text-xs text-accent-500 mt-2",children:o("update.dataPreserved")}),(0,r.jsx)(eo.TM,{isOpen:"confirming"===d,title:o("update.confirmTitle"),description:o("update.confirmDescription",{version:null!=n?n:""}),confirmLabel:o("update.confirmButton"),onConfirm:j,onCancel:()=>m("idle")})]}):null}function e0(e){let{version:t,className:n}=e,a=(0,c.c)("worktree"),{data:s,loading:l}=eX(),o=(0,i.useMemo)(()=>s&&s.hasUpdate?{hasUpdate:s.hasUpdate,latestVersion:s.latestVersion,releaseUrl:s.releaseUrl,updateCommand:s.updateCommand,installType:s.installType}:null,[s]);return(0,r.jsxs)("div",{className:n,"data-testid":"version-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:a("update.version")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:t}),l&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),o&&(0,r.jsx)(eZ,{...o})]})}let e1="https://github.com/Kewton/CommandMate",e2="".concat(e1,"/issues"),e4="".concat(e1,"/issues/new"),e5="".concat(e4,"?template=bug_report.md"),e3="".concat(e4,"?template=feature_request.md"),e6="".concat(e4,"?template=question.md");function e8(e){let{className:t}=e,n=(0,c.c)("worktree"),a=[{href:e5,label:n("feedback.bugReport")},{href:e3,label:n("feedback.featureRequest")},{href:e6,label:n("feedback.question")},{href:e2,label:n("feedback.viewIssues")}];return(0,r.jsxs)("div",{className:t,"data-testid":"feedback-section",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-2",children:n("feedback.title")}),(0,r.jsx)("div",{className:"flex flex-col gap-1",children:a.map(e=>{let{href:t,label:n}=e;return(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-sm text-accent-600 hover:text-accent-800 underline",children:[n,(0,r.jsx)("span",{className:"ml-1","aria-hidden":"true",children:"→"})]},t)})})]})}var e7=n(94465),e9=n(87973),te=n(54014),tt=n(24033);let tn="application/x-commandmate-agent-instance",ta=(0,i.memo)(function(e){let{splitIndex:t,cliToolId:n,instanceId:a,instance:s,availableInstances:l,onInstanceChange:o,status:d="idle",onFocus:u,attaching:m=!1,headerExtras:x,terminal:f,footer:g,style:p,onDropInstance:b,draggedInstanceId:v}=e,y=(0,c.c)("worktree"),[w,j]=(0,i.useState)(null),k=null!=b,N=(0,i.useCallback)(()=>null==v||l.some(e=>e.id===v)?"allowed":"forbidden",[v,l]),C=(0,i.useCallback)(e=>{if(!k)return;e.preventDefault();let t=N();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",j(e=>e===t?e:t)},[k,N]),S=(0,i.useCallback)(e=>{if(!k)return;e.preventDefault();let t=N();j(e=>e===t?e:t)},[k,N]),T=(0,i.useCallback)(()=>{k&&j(null)},[k]),E=(0,i.useCallback)(e=>{if(!k)return;e.preventDefault(),j(null);let t=e.dataTransfer.getData(tn);t&&(null==b||b(t))},[k,b]),I=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),M=(0,i.useCallback)(()=>{u()},[u]),L="Terminal split ".concat(t+1),A=(0,te.sw)(null!=s?s:{cliTool:n}),R=y("terminal.selectInstance",{split:L});return(0,r.jsxs)("div",{role:"region","aria-label":L,"data-testid":"terminal-split-pane-".concat(t),"data-split-index":t,style:p,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===w?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===w?" ring-2 ring-accent-400":"forbidden"===w?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:M,onMouseDown:u,onDragOver:C,onDragEnter:S,onDragLeave:T,onDrop:E,children:[(0,r.jsxs)("div",{className:"px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)(eq.rI,{children:[(0,r.jsxs)(eq.ty,{"data-testid":"cli-selector-".concat(t),"aria-label":R,className:"flex items-center gap-1.5 min-w-0 max-w-[12rem] rounded px-1.5 py-0.5 text-xs border border-border bg-surface text-surface-foreground hover:bg-muted focus:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring transition-colors",children:[(0,r.jsx)(h.m,{status:d,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(t)}),(0,r.jsx)("span",{className:"truncate",children:A}),(0,r.jsx)(tt.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsx)(eq.SQ,{align:"start",className:"min-w-[10rem]",children:(0,r.jsx)(eq.Hr,{value:a,onValueChange:o,children:l.map(e=>(0,r.jsx)(eq.Ht,{value:e.id,children:(0,te.sw)(e)},e.id))})})]}),x,(0,r.jsx)("button",{type:"button",onClick:I,"aria-label":"Search terminal output for ".concat(L),"data-testid":"terminal-search-button-".concat(t),className:"ml-auto flex items-center gap-1 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,"aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[m?(0,r.jsxs)("div",{"data-testid":"terminal-attach-skeleton-".concat(t),className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground bg-surface-2/80",role:"status","aria-live":"polite",children:["Attaching ",A," session..."]}):null,f]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:g})]})});var tr=n(34681),ts=n(20562),tl=n(8803),ti=n(46980),to=n.n(ti),tc=n(62459);let td=new(n.n(tc)())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0});function tu(e){let t=e.replace(/\0/g,"");t.length>1048576&&(t=t.slice(0,1048576));let n=td.toHtml(t);return to().sanitize(n,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}let tm=/\x1b(?:\[[0-9;?]*)?$/,th=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07|\[[0-9;]*m/g;function tx(e){return""===e.replace(th,"").trim()}function tf(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:c,isAtMaxMatches:d=!1}=e,u=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=u.current)||e.focus()},[]);let m=(0,i.useCallback)(e=>{"Escape"===e.key&&c()},[c]),h=(0,i.useCallback)(e=>{n(e.target.value)},[n]),x=0===a?"0/0":d?"".concat(s+1,"/").concat(500,"以上"):"".concat(s+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-gray-800 border border-gray-600 rounded shadow-lg",role:"search","aria-label":"ターミナル内テキスト検索",children:[(0,r.jsx)("input",{ref:u,type:"text",value:t,onChange:h,onKeyDown:m,placeholder:"検索...",className:"bg-transparent text-gray-200 text-sm outline-none w-32 sm:w-40 placeholder-gray-500","aria-label":"検索キーワード",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-gray-400 text-xs min-w-[3rem] text-right",children:x}),(0,r.jsx)("button",{onClick:o,disabled:0===a,"aria-label":"前の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)("button",{onClick:l,disabled:0===a,"aria-label":"次の結果",className:"text-gray-300 hover:text-white disabled:text-gray-600 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)("button",{onClick:c,"aria-label":"検索を閉じる",className:"text-gray-400 hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}function tg(){return(0,r.jsxs)("div",{"data-testid":"thinking-indicator",className:"flex items-center gap-2 py-2 px-1 text-gray-400",children:[(0,r.jsxs)("span",{className:"flex gap-1",children:[(0,r.jsx)("span",{className:"animate-pulse delay-0",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-150",children:"."}),(0,r.jsx)("span",{className:"animate-pulse delay-300",children:"."})]}),(0,r.jsx)("span",{className:"text-sm",children:"Thinking"})]})}let tp=(0,i.memo)(function(e){let{output:t,isActive:n,attaching:a=!1,isThinking:s=!1,autoScroll:l=!0,onScrollChange:o,disableAutoFollow:c=!1,compactTuiLayoutPadding:d=!1,className:u=""}=e,{scrollRef:m,autoScroll:h,handleScroll:x,scrollToBottom:f,scrollToTop:g}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initialAutoScroll:t=!0,onAutoScrollChange:n}=e,a=(0,i.useRef)(null),[r,s]=(0,i.useState)(t),l=(0,i.useRef)(!1),o=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let c=(0,i.useCallback)(e=>{s(e),null==n||n(e)},[n]),d=(0,i.useCallback)(()=>{let e=a.current;if(!e)return!0;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;return n-r-t<=50},[]),u=(0,i.useCallback)(()=>{if(l.current)return;let e=d();e&&!r?c(!0):!e&&r&&c(!1)},[r,d,c]),m=(0,i.useCallback)(()=>{let e=a.current;e&&(l.current=!0,e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),r||c(!0),o.current=setTimeout(()=>{l.current=!1,o.current=null},500))},[r,c]),h=(0,i.useCallback)(()=>{let e=a.current;e&&(l.current=!0,e.scrollTo({top:0,behavior:"smooth"}),r&&c(!1),o.current=setTimeout(()=>{l.current=!1,o.current=null},500))},[r,c]);return{scrollRef:a,autoScroll:r,setAutoScroll:c,scrollToBottom:m,scrollToTop:h,handleScroll:u}}({initialAutoScroll:l,onAutoScrollChange:o}),p=null!=t?t:"",b=(0,i.useMemo)(()=>d?function(e){if(""===e)return"";let t=e.split("\n"),n=[],a=!1,r=0;for(;r<t.length;){if(!tx(t[r])){n.push(t[r]),a=!0,r++;continue}let e=r;for(;e<t.length&&tx(t[e]);)e++;let s=e-r,l=!a,i=e>=t.length;if(!l&&!i)if(s<=2)for(let a=r;a<e;a++)n.push(t[a]);else n.push(function(e){let t=e.match(th);return t?t.join(""):""}(t.slice(r,e).join("")));r=e}return n.join("\n")}(p):p,[d,p]),{isOpen:v,query:y,matchCount:w,currentIndex:j,isAtMaxMatches:k,openSearch:N,closeSearch:C,setQuery:S,nextMatch:T,prevMatch:E}=function(e){let{output:t,containerRef:n}=e,[a,r]=(0,i.useState)(!1),[s,l]=(0,i.useState)(""),[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(0),[m,h]=(0,i.useState)(!1),x=(0,i.useRef)(null),f=(0,i.useRef)(""),g=o.length,p=(0,i.useCallback)(e=>{var t;if(e.length<2||!n.current)return{positions:[],capped:!1};let a=(null!=(t=n.current.textContent)?t:"").toLowerCase(),r=e.toLowerCase(),s=[],l=0;for(;s.length<500;){let t=a.indexOf(r,l);if(-1===t)break;s.push({start:t,end:t+e.length}),l=t+1}let i=s.length>=500&&-1!==a.indexOf(r,l);return{positions:s,capped:i}},[n]),b=(0,i.useCallback)(e=>{let{positions:t,capped:a}=p(e);if(c(t),u(0),h(a),n.current)if(t.length>0){var r;r=n.current,eR(r,t,0,eE)}else eA(eE)},[p,n]),v=(0,i.useCallback)(e=>{l(e),x.current&&clearTimeout(x.current),f.current=e,x.current=setTimeout(()=>{b(e)},300)},[b]),y=(0,i.useCallback)(()=>{r(!0)},[]),w=(0,i.useCallback)(()=>{r(!1),l(""),f.current="",c([]),u(0),h(!1),x.current&&clearTimeout(x.current),eA(eE)},[]),j=(0,i.useCallback)(()=>{0!==g&&u(e=>{let t=(e+1)%g;return n.current&&o.length>0&&eR(n.current,o,t,eE),t})},[g,o,n]),k=(0,i.useCallback)(()=>{0!==g&&u(e=>{let t=(e-1+g)%g;return n.current&&o.length>0&&eR(n.current,o,t,eE),t})},[g,o,n]);return(0,i.useEffect)(()=>{f.current.length<2||b(f.current)},[t,b]),(0,i.useEffect)(()=>()=>{x.current&&clearTimeout(x.current),eA(eE)},[]),{isOpen:a,query:s,matchCount:g,currentIndex:d,isAtMaxMatches:m,openSearch:y,closeSearch:w,setQuery:v,nextMatch:j,prevMatch:k}}({output:b,containerRef:m}),I=(0,i.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),N())},[N]);(0,i.useEffect)(()=>{let e=()=>N();return window.addEventListener("terminal-search-open",e),()=>window.removeEventListener("terminal-search-open",e)},[N]);let[M,L]=(0,i.useState)(()=>b?[{key:0,html:tu(b)}]:[]),A=(0,i.useRef)(b),R=(0,i.useRef)(0);(0,i.useEffect)(()=>{let e=function(e,t){if(e===t)return{mode:"noop",text:t,appended:"",retainedLength:e.length};if(0===e.length||t.length<=e.length||!t.startsWith(e))return{mode:"replace",text:t,appended:"",retainedLength:0};let n=e.match(tm),a=n?e.length-n[0].length:e.length;return{mode:"append",text:t,appended:t.slice(a),retainedLength:a}}(A.current,b);if(A.current=b,"noop"!==e.mode){if("append"===e.mode)return void L(t=>(R.current+=1,t.length>=400)?[{key:R.current,html:tu(b)}]:[...t,{key:R.current,html:tu(e.appended)}]);R.current+=1,L(b?[{key:R.current,html:tu(b)}]:[])}},[b]);let[P,F]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a?F(!1):n&&F(!0)},[a,n]);let D=!t,z=D&&a,O=D&&!a&&!n&&P,B=(0,i.useRef)(!1);(0,i.useEffect)(()=>{c&&(B.current=!0)},[c]),(0,i.useEffect)(()=>{if(m.current){if(B.current&&c&&b){m.current.scrollTo({top:0,behavior:"instant"}),B.current=!1;return}!c&&h&&m.current.scrollTo({top:m.current.scrollHeight,behavior:"instant"})}},[M,b,h,c,m]);let _=(0,i.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",n?"active":"",u].filter(Boolean).join(" "),[n,u]),[W,H]=(0,i.useState)(!1),V=(0,i.useRef)(null),U=(0,i.useCallback)(()=>{H(!0),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>H(!1),1500)},[]);(0,i.useEffect)(()=>()=>{V.current&&clearTimeout(V.current)},[]);let K=(0,i.useCallback)(()=>{x(),U()},[x,U]),$=["absolute bottom-4 right-4 flex items-center justify-center h-9 w-9 rounded-full bg-surface/80 backdrop-blur border border-border text-muted-foreground shadow-lg transition-opacity hover:text-surface-foreground hover:opacity-100 focus-visible:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",W?"opacity-100":"opacity-60"].join(" ");return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[v&&(0,r.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,r.jsx)(tf,{query:y,onQueryChange:S,matchCount:w,currentIndex:j,onNext:T,onPrev:E,onClose:C,isAtMaxMatches:k})}),(0,r.jsxs)("div",{ref:m,role:"log","aria-live":"polite","aria-label":"Terminal output",className:_,onScroll:K,onKeyDown:I,tabIndex:0,children:[(0,r.jsx)("div",{className:"whitespace-pre-wrap break-words",children:M.map(e=>(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:e.html}},e.key))}),z&&(0,r.jsx)("div",{"data-testid":"terminal-loading-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"読込中..."}),O&&(0,r.jsx)("div",{"data-testid":"terminal-ended-placeholder",className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-500 select-none",children:"セッションは終了しました(メッセージ送信で再開できます)"}),n&&s&&(0,r.jsx)(tg,{})]}),h?(0,r.jsx)("button",{type:"button",onClick:g,className:$,"aria-label":"Scroll to top",children:(0,r.jsx)(ts.A,{size:16,"aria-hidden":"true"})}):(0,r.jsx)("button",{type:"button",onClick:f,className:$,"aria-label":"Scroll to bottom",children:(0,r.jsx)(tl.A,{size:16,"aria-hidden":"true"})})]})}),tb=[{key:"Left",label:"◀",ariaLabel:"Send Left"},{key:"Up",label:"▲",ariaLabel:"Send Up"},{key:"Down",label:"▼",ariaLabel:"Send Down"},{key:"Right",label:"▶",ariaLabel:"Send Right"},{key:"Enter",label:"↵",ariaLabel:"Send Enter"}],tv={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},ty={key:"q",label:"q",ariaLabel:"Send q (quit)"};function tw(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:s}=e,[l,o]=(0,i.useState)(null),c=er(t,n,a,s),d="codex"===n?[...tb,tv,ty]:[...tb,tv],u=(0,i.useCallback)(e=>{o(e),setTimeout(()=>o(null),ea.tX),c([e])},[c]);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 py-1.5 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 rounded-lg",role:"toolbar","aria-label":"Terminal navigation keys",children:[(0,r.jsx)("span",{className:"text-xs text-amber-700 dark:text-amber-400 mx-2",title:"Send navigation / escape keys when the terminal is stuck in a TUI overlay",children:"Navigate"}),d.map(e=>{let{key:t,label:n,ariaLabel:a}=e;return(0,r.jsx)("button",{type:"button",className:"min-w-[44px] min-h-[44px] px-3 py-2 text-sm font-medium rounded-md\n border border-amber-300 dark:border-amber-700\n focus:outline-none focus:ring-2 focus:ring-amber-500\n transition-colors duration-75\n ".concat(l===t?"bg-amber-500 text-white border-amber-500 scale-95":"bg-white dark:bg-gray-700 hover:bg-amber-50 dark:hover:bg-gray-600 active:bg-amber-100 dark:active:bg-gray-500"),"aria-label":a,onClick:()=>u(t),children:n},t)})]})}var tj=n(63365);function tk(e){let{worktreeId:t,cliToolId:n,instanceId:a,enabled:r=!0}=e,s=null!=a?a:n,[l,o]=(0,i.useState)(()=>({output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,attaching:!0,autoScroll:!0})),[c,d]=(0,i.useState)(()=>({visible:!1,data:null,messageId:null,answering:!1})),u=(0,i.useRef)(0),m=(0,i.useRef)(n);m.current=n;let h=(0,i.useRef)(s);h.current=s;let x=(0,i.useRef)(c.visible);x.current=c.visible;let{connected:f,subscribe:g,unsubscribe:p,addListener:b}=(0,tj.xM)(),v=(0,i.useRef)(0),y=(0,i.useRef)(0),w=(0,i.useRef)(null),j=(0,i.useRef)(null),[k,N]=(0,i.useState)(!1),C=(0,i.useCallback)(()=>{N(!0),null!==j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{j.current=null,N(!1)},5e3)},[]),S=(0,i.useCallback)(e=>{var t,n;let a=null!=(n=null!=(t=e.fullOutput)?t:e.realtimeSnippet)?n:"";!0===e.isUnclassifiedActive&&!0!==e.isPromptWaiting&&!0!==e.isSelectionListActive&&!0!==e.isPagerActive?(y.current+=1,null!=w.current||(w.current=Date.now())):(y.current=0,w.current=null);let r=y.current>=2&&null!==w.current&&Date.now()-w.current>=500;o(t=>{var n,s,l,i,o;let c=!1===e.isRunning,d=!!a||!!e.isRunning||c;return{...t,output:d?a:t.output,realtimeSnippet:null!=(n=e.realtimeSnippet)?n:"",isRunning:null!=(s=e.isRunning)&&s,isThinking:null!=(l=e.thinking)&&l,isSelectionListActive:null!=(i=e.isSelectionListActive)&&i,isPagerActive:null!=(o=e.isPagerActive)&&o,isUnclassifiedActive:r,attaching:!1}}),e.isPromptWaiting&&e.promptData?d(t=>{var n,a;return{...t,visible:!0,data:null!=(n=e.promptData)?n:t.data,messageId:null!=(a=t.messageId)?a:"prompt-".concat(Date.now())}}):!e.isPromptWaiting&&x.current&&d({visible:!1,data:null,messageId:null,answering:!1})},[]),T=(0,i.useCallback)(async()=>{let e=++u.current;try{let a=await fetch("/api/worktrees/".concat(t,"/current-output?cliTool=").concat(n,"&instance=").concat(encodeURIComponent(s)));if(!a.ok)return;let r=await a.json();if(u.current!==e||m.current!==n||h.current!==s||r.cliToolId&&r.cliToolId!==n)return;S(r)}catch(t){if(u.current!==e||m.current!==n||h.current!==s)return;console.error("[useTerminalPanePolling] fetch error:",t)}},[t,n,s,S]),E="".concat(t,"::").concat(n,"::").concat(s),I=(0,i.useRef)(E);(0,i.useEffect)(()=>{I.current!==E&&(I.current=E,u.current+=1,v.current=0,y.current=0,w.current=null,N(!1),null!==j.current&&(clearTimeout(j.current),j.current=null),o(e=>({...e,output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,attaching:!0})),d({visible:!1,data:null,messageId:null,answering:!1}))},[E]),(0,i.useEffect)(()=>{if(r)return g(t),()=>p(t)},[r,t,g,p]),(0,i.useEffect)(()=>{v.current=0,N(!1),null!==j.current&&(clearTimeout(j.current),j.current=null)},[f]),(0,i.useEffect)(()=>()=>{null!==j.current&&clearTimeout(j.current)},[]),(0,i.useEffect)(()=>{if(r)return b(e=>{var n;if("terminal_snapshot"!==e.type||e.worktreeId!==t||e.cliToolId!==m.current||e.instanceId!==h.current||e.version<=v.current)return;v.current=e.version,C();let a=e.output.split("\n").slice(-100).join("\n");S({fullOutput:e.output,realtimeSnippet:a,isRunning:e.isRunning,thinking:e.thinking,isSelectionListActive:e.isSelectionListActive,isPagerActive:e.isPagerActive,isUnclassifiedActive:e.isUnclassifiedActive,isPromptWaiting:e.isPromptWaiting,promptData:null!=(n=e.promptData)?n:null})})},[r,t,b,S,C]),(0,i.useEffect)(()=>{if(r)return b(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===h.current)&&(null==e.cliTool||e.cliTool===m.current)&&(v.current=0,S({fullOutput:"",realtimeSnippet:"",isRunning:!1,thinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,isPromptWaiting:!1,promptData:null}))})},[r,t,b,S]),(0,i.useEffect)(()=>{if(!r)return;let e=!1,t=c.visible||l.isSelectionListActive||l.isPagerActive||l.isUnclassifiedActive,n=setInterval(()=>{"hidden"!==document.visibilityState&&T()},f&&k&&!t?15e3:l.isRunning||t?2e3:5e3);"undefined"!=typeof document&&"hidden"!==document.visibilityState&&T();let a=()=>{"visible"!==document.visibilityState||e||T()};return document.addEventListener("visibilitychange",a),()=>{e=!0,null!==n&&(clearInterval(n),n=null),document.removeEventListener("visibilitychange",a)}},[r,f,k,l.isRunning,l.isSelectionListActive,l.isPagerActive,l.isUnclassifiedActive,c.visible,T]);let M=(0,i.useCallback)(e=>{o(t=>t.autoScroll===e?t:{...t,autoScroll:e})},[]),L=(0,i.useCallback)(e=>{d(t=>({...t,answering:e}))},[]);return{terminal:l,prompt:c,setAutoScroll:M,setPromptAnswering:L,clearPrompt:(0,i.useCallback)(()=>{d({visible:!1,data:null,messageId:null,answering:!1})},[]),refresh:(0,i.useCallback)(()=>T(),[T])}}let tN=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disableAutoFollow:s}=e,{terminal:l,prompt:i,setAutoScroll:o,refresh:c}=tk({worktreeId:t,cliToolId:n,instanceId:a}),d="claude"===n||"codex"===n,u=l.isUnclassifiedActive&&!i.visible;return(0,r.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(tp,{output:l.output,isActive:l.isRunning,isThinking:l.isThinking,autoScroll:l.autoScroll,onScrollChange:o,disableAutoFollow:s,compactTuiLayoutPadding:d,className:"h-full"})}),u?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(tw,{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:c})}):null]})});var tC=n(96195),tS=n(12181),tT=n(20508),tE=n(27937);function tI(e){if(0===e.length)return"0";let t=e[e.length-1],n=t.timestamp instanceof Date?t.timestamp.getTime():String(t.timestamp);return"".concat(e.length,"|").concat(t.id,"|").concat(n)}var tM=n(35299),tL=n(6132),tA=n(48314),tR=n(54916),tP=n(36809),tF=n(55041),tD=n(8574);let tz={en:tD.c,ja:tF.ja};function tO(e){var t;return null!=(t=tz[e])?t:tD.c}var tB=n(83012);let t_=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function tW(e){let t=e.split("\n");if(t.length<=2&&e.length<=100)return{text:e,isTruncated:!1};let n=t.slice(0,2).join("\n");return n.length>100&&(n=n.slice(0,100)),{text:n,isTruncated:!0}}let tH=(0,i.memo)(function(e){let{content:t,onFilePathClick:n}=e,a=(0,c.c)("worktree"),s=(0,i.useMemo)(()=>(function(e){let t=e.match(t_);if(!t||0===t.length)return[{type:"text",content:e}];let n=[],a=0;return t.forEach(t=>{let r=e.indexOf(t,a);r>a&&n.push({type:"text",content:e.slice(a,r)}),n.push({type:"path",content:t}),a=r+t.length}),a<e.length&&n.push({type:"text",content:e.slice(a)}),n})(t),[t]),l=(0,i.useCallback)(e=>()=>n(e),[n]);return(0,r.jsx)("span",{children:s.map((e,t)=>"path"===e.type?(0,r.jsx)("button",{type:"button",onClick:l(e.content),className:"text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:underline cursor-pointer font-mono text-sm","aria-label":a("conversation.openFile",{path:e.content}),children:e.content},t):(0,r.jsx)("span",{children:e.content},t))})});function tV(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"pending-indicator",className:"flex items-center gap-2 text-muted-foreground py-2",children:[(0,r.jsxs)("div",{className:"flex gap-1","aria-hidden":"true",children:[(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse"}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"150ms"}}),(0,r.jsx)("span",{className:"w-2 h-2 bg-muted-foreground rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),(0,r.jsx)("span",{className:"text-sm",children:e("conversation.waitingForResponse")})]})}let tU=(0,i.memo)(function(e){let{message:t,onFilePathClick:n,onCopy:a,onInsertToMessage:s,onRetryPending:l,onDiscardPending:i}=e,o=(0,tP.Ym)(),d=(0,c.c)("worktree"),u=(0,c.c)("common"),m=tO(o),h=(0,tB.bg)(t.timestamp,m),x=t.optimisticState,f=["group relative border-l-2 p-3 transition-opacity","error"===x?"border-danger-border bg-danger-subtle":"border-accent-500 bg-accent-500/10","sending"===x?"opacity-70":""].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:f,children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-700 dark:text-accent-400",children:d("conversation.you")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:h}),"sending"===x&&(0,r.jsxs)("span",{"data-testid":"optimistic-sending",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(tM.A,{size:12,className:"animate-spin","aria-hidden":"true"}),(0,r.jsx)("span",{children:d("conversation.sending")})]}),"error"===x&&(0,r.jsxs)("span",{"data-testid":"optimistic-error",className:"flex items-center gap-1 text-xs text-danger-foreground",children:[(0,r.jsx)(tL.A,{size:12,"aria-hidden":"true"}),(0,r.jsx)("span",{children:d("conversation.failedToSend")})]}),"error"===x?(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[l&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-retry",onClick:()=>l(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:bg-muted transition-colors","aria-label":d("conversation.retrySending"),title:u("retry"),children:[(0,r.jsx)(tA.A,{size:12,"aria-hidden":"true"}),u("retry")]}),i&&(0,r.jsxs)("button",{type:"button","data-testid":"pending-discard",onClick:()=>i(t.id),className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-muted-foreground hover:text-danger-foreground hover:bg-muted transition-colors","aria-label":d("conversation.discardMessage"),title:d("conversation.discard"),children:[(0,r.jsx)(ew.A,{size:12,"aria-hidden":"true"}),d("conversation.discard")]})]}):(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[s&&(0,r.jsx)("button",{type:"button","data-testid":"insert-user-message",onClick:()=>s(t.content),className:"p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-muted rounded transition-colors","aria-label":d("conversation.insertToMessage"),title:d("conversation.insertToMessage"),children:(0,r.jsx)(tR.A,{size:14,"aria-hidden":"true"})}),a&&(0,r.jsx)("button",{type:"button","data-testid":"copy-user-message",onClick:()=>a(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":d("conversation.copyMessage"),title:d("conversation.copy"),children:(0,r.jsx)(ex.A,{size:14,"aria-hidden":"true"})})]})]}),(0,r.jsx)("div",{"data-message-id":t.id,className:"text-sm text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:(0,r.jsx)(tH,{content:t.content,onFilePathClick:n})})]})}),tK=(0,i.memo)(function(e){let{message:t,index:n,total:a,isExpanded:s,onFilePathClick:l,onCopy:o,hasLongContent:d=!1,onToggleExpand:u}=e,m=(0,tP.Ym)(),h=(0,c.c)("worktree"),x=tO(m),f=(0,tB.bg)(t.timestamp,x),{text:g,isTruncated:p}=(0,i.useMemo)(()=>tW(t.content),[t.content]),b=s||!p?t.content:g;return(0,r.jsxs)("div",{className:"assistant-message-item group relative",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:h("conversation.assistant")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),a>1&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",n+1,"/",a,")"]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100",children:[0===n&&d&&!!u&&(0,r.jsxs)("button",{type:"button",onClick:u,className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-accent-700 dark:text-accent-400 hover:text-accent-600 dark:hover:text-accent-300 hover:bg-muted transition-colors","aria-expanded":s,"aria-label":h(s?"conversation.collapseMessage":"conversation.expandMessage"),children:[(0,r.jsx)(tt.A,{size:12,className:"transition-transform ".concat(s?"rotate-180":""),"aria-hidden":"true"}),h(s?"conversation.collapse":"conversation.expand")]}),o&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>o(t.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":h("conversation.copyMessage"),title:h("conversation.copy"),children:(0,r.jsx)(ex.A,{size:14,"aria-hidden":"true"})})]})]}),(0,r.jsxs)("div",{"data-message-id":t.id,className:"text-xs text-foreground whitespace-pre-wrap break-words [word-break:break-word] max-w-full overflow-x-hidden",children:[(0,r.jsx)(tH,{content:b,onFilePathClick:l}),!s&&p&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"..."})]})]})}),t$=(0,i.memo)(function(e){let{messages:t,isExpanded:n,onFilePathClick:a,onCopy:s,hasLongContent:l=!1,onToggleExpand:o}=e;return(0,r.jsx)("div",{className:"bg-surface-2/50 border-l-2 border-border p-2 border-t border-border space-y-2",children:t.map((e,c)=>(0,r.jsxs)(i.Fragment,{children:[c>0&&(0,r.jsx)("div",{"data-testid":"assistant-message-divider",className:"border-t border-dashed border-border"}),(0,r.jsx)(tK,{message:e,index:c,total:t.length,isExpanded:n,onFilePathClick:a,onCopy:s,hasLongContent:l,onToggleExpand:o})]},e.id))})});function tq(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{"data-testid":"orphan-indicator",className:"bg-warning/10 text-warning-foreground text-xs px-3 py-1 flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{children:e("conversation.systemMessage")})]})}let tJ=(0,i.memo)(function(e){var t;let{pair:n,onFilePathClick:a,isExpanded:s=!1,onToggleExpand:l,onCopy:o,onInsertToMessage:d,showAssistant:u=!0,onRetryPending:m,onDiscardPending:h}=e,x=(0,c.c)("worktree"),f=(null==(t=n.userMessage)?void 0:t.optimisticState)!==void 0,g=(0,i.useMemo)(()=>n.assistantMessages.some(e=>{let{isTruncated:t}=tW(e.content);return t}),[n.assistantMessages]),p=(0,i.useCallback)(()=>{l&&l()},[l]),b=(0,i.useMemo)(()=>{let e="pending"===n.status?"pending":"orphan"===n.status?"orphan border-l-4 border-warning":"";return"".concat("border border-border rounded-lg overflow-hidden mb-4 transition-colors"," ").concat(e).trim()},[n.status]),v=n.userMessage?x("conversation.conversationLabel",{preview:"".concat(n.userMessage.content.substring(0,50)).concat(n.userMessage.content.length>50?"...":"")}):x("conversation.systemMessageLabel");return(0,r.jsxs)("div",{"data-testid":"conversation-pair-card",role:"article","aria-label":v,className:b,children:["orphan"===n.status&&(0,r.jsx)(tq,{}),n.userMessage&&(0,r.jsx)(tU,{message:n.userMessage,onFilePathClick:a,onCopy:o,onInsertToMessage:d,onRetryPending:m,onDiscardPending:h}),"pending"!==n.status||f?u&&n.assistantMessages.length>0?(0,r.jsx)(t$,{messages:n.assistantMessages,isExpanded:s,onFilePathClick:a,onCopy:o,hasLongContent:g,onToggleExpand:p}):null:(0,r.jsx)("div",{className:"bg-muted/40 border-l-2 border-border p-3 border-t border-border",children:(0,r.jsx)(tV,{})})]})});function tG(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,isAtMaxMatches:u,onCompositionStart:m,onCompositionEnd:h}=e,x=(0,i.useRef)(null),f=(0,c.c)("worktree");(0,i.useEffect)(()=>{var e;null==(e=x.current)||e.focus()},[]);let g=(0,i.useCallback)(e=>{"Escape"===e.key&&d()},[d]),p=(0,i.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":u?f("history.search.countAtMax",{current:s+1,max:500}):"".concat(s+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border border-border rounded shadow-lg",role:"search","aria-label":f("history.search.regionLabel"),children:[(0,r.jsx)("input",{ref:x,type:"text",value:t,onChange:p,onKeyDown:g,onCompositionStart:m,onCompositionEnd:h,placeholder:f("history.search.placeholder"),className:"bg-transparent text-foreground text-sm outline-none w-32 sm:w-40 placeholder-muted-foreground","aria-label":f("history.search.keywordLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:b}),(0,r.jsx)("button",{type:"button",onClick:o,disabled:0===a,"aria-label":f("history.search.prev"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)("button",{type:"button",onClick:l,disabled:0===a,"aria-label":f("history.search.next"),className:"text-muted-foreground hover:text-foreground disabled:opacity-40 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":f("history.search.close"),className:"text-muted-foreground hover:text-foreground min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let tY="commandmate.worktree.historyVisible",tX="commandmate.worktree.historyWidth";function tQ(e){return Number.isFinite(e)?Math.min(60,Math.max(10,e)):40}let tZ="commandmate:historyPaneStateChange";function t0(e){try{window.dispatchEvent(new CustomEvent(tZ,{detail:e}))}catch(e){}}function t1(){let[e,t]=(0,i.useState)(!0),[n,a]=(0,i.useState)(40),r=(0,i.useRef)(e);r.current=e;let s=(0,i.useRef)(n);return s.current=n,(0,i.useEffect)(()=>{let e=function(){try{let e=window.localStorage.getItem(tY);if("true"===e)return!0;if("false"===e)return!1}catch(e){}return!0}(),n=function(){try{let e=window.localStorage.getItem(tX);if(null===e)return 40;let t=Number(e);if(Number.isFinite(t))return tQ(t)}catch(e){}return 40}();t(e),a(n)},[]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&(e.detail.visible!==r.current&&t(e.detail.visible),e.detail.width!==s.current&&a(e.detail.width))};return window.addEventListener(tZ,e),()=>window.removeEventListener(tZ,e)},[]),{visible:e,width:n,toggle:(0,i.useCallback)(()=>{let e=!r.current;t(e);try{window.localStorage.setItem(tY,String(e))}catch(e){}t0({visible:e,width:s.current})},[]),setWidth:(0,i.useCallback)(e=>{let t=tQ(e);a(t);try{window.localStorage.setItem(tX,String(t))}catch(e){}t0({visible:r.current,width:t})},[])}}var t2=n(72115);let t4="worktree-history-pane",t5=(0,i.memo)(function(e){let{onToggle:t}=e,n=(0,c.c)("worktree");return(0,r.jsx)("div",{"data-testid":"terminal-container-expand-bar",style:{width:"".concat(36,"px")},className:"flex-shrink-0 flex items-start justify-center bg-gray-100 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700",children:(0,r.jsxs)("button",{type:"button","data-testid":"history-pane-expand","aria-label":n("terminal.showHistory"),title:n("terminal.showHistory"),"aria-expanded":"false","aria-controls":t4,onClick:t,className:"flex flex-col items-center gap-2 w-full pt-2 text-gray-500 dark:text-gray-400 hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:n("terminal.historyLabel")})]})})}),t3=(0,i.memo)(function(e){let{history:t,terminal:n}=e,{visible:a,width:s,toggle:l,setWidth:o}=t1(),c=(0,i.useRef)(null),d=(0,i.useCallback)(e=>{let t=c.current;if(!t)return;let n=t.offsetWidth;0!==n&&o(s+e/n*100)},[s,o]);return(0,r.jsxs)("div",{ref:c,className:"flex h-full min-h-0 w-full",children:[null!=t&&(a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:t4,"data-testid":"terminal-container-history-slot","aria-label":"History pane",style:{width:"".concat(s,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(S,{componentName:"HistoryPane",children:t})}),(0,r.jsx)(t2.f,{onResize:d,orientation:"horizontal",ariaValueNow:s})]}):(0,r.jsx)(t5,{onToggle:l})),(0,r.jsx)("div",{"data-testid":"terminal-container-terminal-slot","aria-label":"Terminal pane",className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(S,{componentName:"TerminalAndFilePanel",children:n})})]})}),t6=[50,100,150,200,250,500,1e3],t8="commandmate:historyDisplayLimit";function t7(e){return t6.includes(e)}let t9="commandmate:historyUserOnly";function ne(e){return"split-history-slot-".concat(e)}function nt(){let e=(0,c.c)("worktree");return(0,r.jsx)("div",{"data-testid":"loading-indicator",role:"status","aria-label":e("history.loading"),children:[0,1,2].map(e=>(0,r.jsxs)("div",{className:"mb-4 overflow-hidden rounded-lg border border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-3",children:[(0,r.jsx)(m.EA,{className:"h-4 w-4 rounded-full"}),(0,r.jsx)(m.EA,{className:"h-4 w-1/3"})]}),(0,r.jsxs)("div",{className:"space-y-2 px-3 pb-3",children:[(0,r.jsx)(m.EA,{className:"h-3 w-full"}),(0,r.jsx)(m.EA,{className:"h-3 w-5/6"}),(0,r.jsx)(m.EA,{className:"h-3 w-2/3"})]})]},e))})}function nn(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[(0,r.jsx)("svg",{className:"w-12 h-12 mb-2 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),(0,r.jsx)("p",{className:"text-sm",children:e("history.empty")})]})}let na=["h-full","flex","flex-col","overflow-hidden","bg-surface-2","rounded-lg","border","border-border"],nr=(0,i.memo)(function(e){let{messages:t,worktreeId:n,onFilePathClick:a,isLoading:s=!1,className:l="",showToast:o,onInsertToMessage:d,onRetryPending:u,onDiscardPending:h,showArchived:x=!1,onShowArchivedChange:f,historyDisplayLimit:g,onHistoryDisplayLimitChange:p,historyUserOnly:b=!1,onHistoryUserOnlyChange:v,onCollapse:y,splitIndex:w,cliToolId:j}=e,k=(0,c.c)("worktree"),N=(0,i.useRef)(null),C=(0,i.useMemo)(()=>void 0===w?eI:{highlightName:"history-search-".concat(w),currentHighlightName:"history-search-current-".concat(w),fallbackOverlayId:"history-search-fallback-overlay-".concat(w),fallbackOverlayBgColor:eI.fallbackOverlayBgColor},[w]),S=void 0===w?"history-pane-collapse-button":"history-pane-collapse-button-".concat(w),T=void 0===w?t4:ne(w),E=(0,i.useRef)(!0),I=(0,i.useRef)(-1),M=(0,i.useRef)(null),{pairs:L,isExpanded:A,toggleExpand:R}=function(e){let t=(0,i.useMemo)(()=>(function(e){if(0===e.length)return[];let t=[...e].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),n=[],a=null;for(let e of t)if("user"===e.role)a={id:e.id,userMessage:e,assistantMessages:[],status:"pending"},n.push(a);else if("assistant"===e.role)if(a&&null!==a.userMessage)a.assistantMessages.push(e),a.status="completed";else if(a&&null===a.userMessage)a.assistantMessages.push(e);else{let t={id:"orphan-".concat(e.id),userMessage:null,assistantMessages:[e],status:"orphan"};n.push(t),a=t}return n})(e),[e]),[n,a]=(0,i.useState)(new Set),r=(0,i.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,i.useCallback)(e=>n.has(e),[n]),l=(0,i.useCallback)(()=>{a(new Set(t.map(e=>e.id)))},[t]);return{pairs:t,expandedPairs:n,toggleExpand:r,isExpanded:s,expandAll:l,collapseAll:(0,i.useCallback)(()=>{a(new Set)},[])}}(t),{isOpen:P,query:F,matchCount:D,currentIndex:O,isAtMaxMatches:B,matchPositions:_,currentMatch:W,openSearch:H,closeSearch:V,setQuery:U,onCompositionStart:K,onCompositionEnd:$,nextMatch:q,prevMatch:J}=function(e){let{messages:t}=e,[n,a]=(0,i.useState)(!1),[r,s]=(0,i.useState)(""),[l,o]=(0,i.useState)([]),[c,d]=(0,i.useState)(0),[u,m]=(0,i.useState)(!1),h=(0,i.useRef)(null),x=(0,i.useRef)(""),f=(0,i.useRef)(!1),g=(0,i.useRef)(tI(t)),p=(0,i.useRef)(t);p.current=t;let b=l.reduce((e,t)=>e+t.ranges.length,0),v=(0,i.useMemo)(()=>(function(e,t){if(0===e.length||t<0)return null;let n=0;for(let a of e){if(t<n+a.ranges.length)return{messageId:a.messageId,localIndex:t-n};n+=a.ranges.length}return null})(l,c),[l,c]),y=(0,i.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),w=(0,i.useCallback)(e=>{let{positions:t,capped:n}=function(e,t){if(t.length<2||0===e.length)return{positions:[],capped:!1};let n=t.toLowerCase(),a=t.length,r=[],s=0,l=!1;for(let t of e){if(l)break;let i=t.content;if(!i)continue;let o=i.toLowerCase(),c=[],d=0;for(;;){let r=o.indexOf(n,d);if(-1===r)break;if(c.push({start:r,end:r+a}),d=r+1,(s+=1)>=500){if(-1!==o.indexOf(n,d))l=!0;else{let a=e.indexOf(t)+1;for(let t=a;t<e.length;t++){let a=e[t].content;if(a&&-1!==a.toLowerCase().indexOf(n)){l=!0;break}}}break}}c.length>0&&r.push({messageId:t.id,ranges:c})}return{positions:r,capped:l}}(p.current,e);o(t),d(0),m(n)},[]),j=(0,i.useCallback)(e=>{y(),x.current=e,f.current||(h.current=setTimeout(()=>{w(e)},300))},[y,w]),k=(0,i.useCallback)(e=>{s(e),j(e)},[j]),N=(0,i.useCallback)(()=>{a(!0)},[]),C=(0,i.useCallback)(()=>{a(!1),s(""),x.current="",o([]),d(0),m(!1),y()},[y]),S=(0,i.useCallback)(()=>{d(e=>0===b?0:(e+1)%b)},[b]),T=(0,i.useCallback)(()=>{d(e=>0===b?0:(e-1+b)%b)},[b]),E=(0,i.useCallback)(()=>{f.current=!0,y()},[y]),I=(0,i.useCallback)(()=>{f.current=!1;let e=x.current;e.length>=2&&(y(),h.current=setTimeout(()=>{w(e)},300))},[y,w]);return(0,i.useEffect)(()=>{let e=tI(t);if(e===g.current)return;g.current=e;let n=x.current;n.length>=2&&w(n)},[t,w]),(0,i.useEffect)(()=>()=>{y(),x.current=""},[y]),{isOpen:n,query:r,matchCount:b,currentIndex:c,isAtMaxMatches:u,matchPositions:l,currentMatch:v,openSearch:N,closeSearch:C,setQuery:k,onCompositionStart:E,onCompositionEnd:I,nextMatch:S,prevMatch:T}}({messages:(0,i.useMemo)(()=>t.filter(e=>!e.archived&&"string"==typeof e.content&&e.content.length>0&&(!b||"user"===e.role)),[t,b])}),G=P&&_.length>0,[Y,X]=(0,i.useState)(new Set);(0,i.useEffect)(()=>{V()},[n]);let Q=(0,i.useMemo)(()=>b?L.filter(e=>e.userMessage):L,[L,b]),Z=(0,i.useMemo)(()=>{let e=new Map;for(let t of Q)for(let n of(t.userMessage&&e.set(t.userMessage.id,t.id),t.assistantMessages))e.set(n.id,t.id);return e},[Q]),ee=(0,i.useMemo)(()=>{let e=new Map;return Q.forEach((t,n)=>e.set(t.id,n)),e},[Q]),et=(0,tC.Te)({count:Q.length,getScrollElement:()=>N.current,estimateSize:()=>160,overscan:6,getItemKey:e=>{var t,n;return null!=(n=null==(t=Q[e])?void 0:t.id)?n:e}}),en=et.getVirtualItems(),ea=en.length>0?"".concat(en[0].index,"-").concat(en[en.length-1].index):"",er=(0,i.useCallback)(()=>{let e=N.current;e&&(E.current=function(e){let{scrollTop:t,scrollHeight:n,clientHeight:a}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:80,s=n-t-a;return!!Number.isFinite(s)&&s<=r}({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}))},[]);(0,i.useLayoutEffect)(()=>{let e=I.current,t=Q.length;I.current=t,-1!==e&&t>e&&t>0&&E.current&&!G&&et.scrollToIndex(t-1,{align:"end"})},[Q.length,G,et]),(0,i.useLayoutEffect)(()=>{if(!P||0===_.length)return void X(e=>0===e.size?e:new Set);X(function(e,t){let n=new Map;for(let e of t)for(let t of(e.userMessage&&n.set(e.userMessage.id,e.id),e.assistantMessages))n.set(t.id,e.id);let a=new Set;for(let t of e){let e=n.get(t.messageId);e&&a.add(e)}return a}(_,L))},[P,_,L]),(0,i.useEffect)(()=>{if(!P||!W)return;let e=Z.get(W.messageId);if(void 0===e)return;let t=ee.get(e);void 0!==t&&et.scrollToIndex(t,{align:"center"})},[P,W,Z,ee,et]),(0,i.useLayoutEffect)(()=>{let e=N.current;if(!e)return;if(!P||0===_.length)return void eP(C);let t=null;for(let a of _){var n;let r=(n=a.messageId,e.querySelector('[data-message-id="'.concat(CSS.escape(n),'"]')));if(!r)continue;let s=(null==W?void 0:W.messageId)===a.messageId,l=s?W.localIndex:-1;!function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eI;eR(e,t,n,a)}(r,a.ranges,l,C),s&&r instanceof HTMLElement&&(t=r)}return t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"}),()=>{eP(C)}},[P,_,W,Y,C,ea]),(0,i.useEffect)(()=>{let e=N.current;if(P)null===M.current&&e&&(M.current=e.scrollTop);else{if(null!==M.current&&e){let t=M.current;requestAnimationFrame(()=>{e.scrollTop=t})}M.current=null}},[P]);let es=(0,i.useMemo)(()=>[...na,l].filter(Boolean).join(" "),[l]),el=(0,i.useCallback)(e=>a(e),[a]),ei=(0,i.useCallback)(e=>()=>R(e),[R]),eo=(0,i.useRef)(k);eo.current=k;let ec=(0,i.useCallback)(async e=>{try{await (0,ey.l)(e),null==o||o(eo.current("history.copied"),"success")}catch(e){console.error("[HistoryPane] Failed to copy to clipboard"),null==o||o(eo.current("history.copyFailed"),"error")}},[o]),ed=e=>{var t,n;let a=(null==(t=e.userMessage)?void 0:t.archived)===!0||(null==(n=e.assistantMessages)?void 0:n.some(e=>!0===e.archived)),s=A(e.id)||Y.has(e.id);return(0,r.jsx)("div",{className:a?"opacity-60":"",children:(0,r.jsx)(tJ,{pair:e,onFilePathClick:el,isExpanded:s,onToggleExpand:ei(e.id),onCopy:ec,onInsertToMessage:d,onRetryPending:u,onDiscardPending:h,showAssistant:!b})})},eu=(0,i.useCallback)(e=>{let t=parseInt(e.target.value,10);t7(t)&&(null==p||p(t))},[p]),em=(0,i.useCallback)(()=>{P?V():H()},[P,H,V]);return(0,r.jsxs)("div",{role:"region","aria-label":k("history.regionLabel"),className:es,children:[(0,r.jsxs)("div",{className:"flex-shrink-0 bg-surface-2 border-b border-border px-4 py-2 flex items-center justify-between flex-wrap gap-1",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:k("history.title")}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[p&&void 0!==g&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)("span",{children:k("history.show")}),(0,r.jsx)("select",{value:g,onChange:eu,"aria-label":k("history.displayLimit"),className:"rounded border border-input bg-surface text-foreground text-xs px-1.5 py-0.5 focus:outline-none focus:ring-1 focus:ring-ring",children:t6.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),f&&(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer",children:[(0,r.jsx)(m.Sc,{checked:x,onCheckedChange:e=>f(!0===e),className:"h-3.5 w-3.5"}),k("history.showArchived")]}),v&&(0,r.jsx)("button",{type:"button",onClick:()=>v(!b),"aria-label":k("history.showUserOnly"),"aria-pressed":b,className:"p-1 rounded transition-colors ".concat(b?"bg-accent-500/15 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:text-foreground"),title:k(b?"history.showAllMessages":"history.showUserOnly"),children:b?(0,r.jsx)(tS.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(tT.A,{size:14,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:em,"aria-label":k(P?"history.closeSearch":"history.openSearch"),"aria-pressed":P,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:k(P?"history.closeSearch":"history.openSearch"),children:(0,r.jsx)(z.A,{size:14,"aria-hidden":"true"})}),y&&(0,r.jsx)("button",{type:"button",onClick:y,"aria-label":k("terminal.hideHistory"),"aria-expanded":"true","aria-controls":T,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:k("terminal.hideHistory"),"data-testid":S,children:(0,r.jsx)(tE.A,{size:14,"aria-hidden":"true"})})]})]}),P&&(0,r.jsx)("div",{className:"flex-shrink-0 px-3 py-2 bg-surface-2 border-b border-border",children:(0,r.jsx)(tG,{query:F,onQueryChange:U,matchCount:D,currentIndex:O,onNext:q,onPrev:J,onClose:V,isAtMaxMatches:B,onCompositionStart:K,onCompositionEnd:$})}),(0,r.jsx)("div",{ref:N,"data-testid":"history-scroll-container",onScroll:er,className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-4",children:s?(0,r.jsx)(nt,{}):0===Q.length?(0,r.jsx)(nn,{}):0===en.length?(0,r.jsx)("div",{"data-testid":"history-fallback-list",children:Q.slice(0,30).map(e=>(0,r.jsx)("div",{children:ed(e)},e.id))}):(0,r.jsx)("div",{style:{height:et.getTotalSize(),width:"100%",position:"relative"},children:en.map(e=>{let t=Q[e.index];return t?(0,r.jsx)("div",{"data-index":e.index,ref:et.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:"translateY(".concat(e.start,"px)")},children:ed(t)},e.key):null})})})]})}),ns={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var nl=n(7504),ni=n(22198),no=n(21786),nc=n(26754),nd=n(71360),nu=n(9286);function nm(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let nh=(0,i.memo)(function(e){let{isOpen:t,position:n,targetPath:a,targetType:s,onClose:l,onNewFile:o,onNewDirectory:d,onRename:u,onDelete:m,onUpload:h,onMove:x}=e,f=(0,c.c)("worktree"),g=(0,i.useRef)(null),{shouldRender:p,isExiting:b}=(0,nu.O)(t,ea.$B),v="".concat(n.x,":").concat(n.y,":").concat(s),[y,w]=(0,i.useState)(null),j=(null==y?void 0:y.key)===v?y:null;(0,i.useLayoutEffect)(()=>{if(!t)return;let e=g.current;if(!e)return;let a=e.getBoundingClientRect();w({key:v,left:nm(n.x,a.width,window.innerWidth),top:nm(n.y,a.height,window.innerHeight)})},[t,v,n.x,n.y]);let k=(0,i.useCallback)(e=>{e&&a&&e(a),l()},[a,l]),N=[{id:"new-file",label:f("fileTree.newFile"),icon:(0,r.jsx)(nl.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(o),showFor:["directory"]},{id:"new-directory",label:f("fileTree.newDirectory"),icon:(0,r.jsx)(ni.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(d),showFor:["directory"]},{id:"upload",label:f("contextMenu.uploadFile"),icon:(0,r.jsx)(no.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(h),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:f("contextMenu.rename"),icon:(0,r.jsx)(eC.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(u)},{id:"move",label:f("contextMenu.move"),icon:(0,r.jsx)(nc.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{x&&a&&s&&x(a,s),l()},showDividerAfter:!0},{id:"delete",label:f("contextMenu.delete"),icon:(0,r.jsx)(nd.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(m),variant:"danger"}].filter(e=>!e.showFor||s&&e.showFor.includes(s));return((0,i.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key)return void l();if("ArrowDown"===e.key||"ArrowUp"===e.key){var t;let n;e.preventDefault();let a=null==(t=g.current)?void 0:t.querySelectorAll('[role="menuitem"]');if(!(null==a?void 0:a.length))return;let r=Array.from(a).findIndex(e=>e===document.activeElement);n="ArrowDown"===e.key?r<a.length-1?r+1:0:r>0?r-1:a.length-1,a[n].focus()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,l]),(0,i.useEffect)(()=>{if(t&&g.current){let e=g.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),p)?(0,r.jsx)("div",{ref:g,"data-testid":"context-menu",role:"menu","aria-label":f("contextMenu.label"),className:"fixed min-w-[160px] py-1 bg-surface rounded-lg shadow-lg border border-border ".concat(b?"animate-out fade-out-0 zoom-out-95 duration-100 fill-mode-forwards pointer-events-none":"animate-in fade-in-0 zoom-in-95 duration-100"),style:{zIndex:eS.M.CONTEXT_MENU,left:"".concat(j?j.left:0,"px"),top:"".concat(j?j.top:0,"px")},children:N.map((e,t)=>(0,r.jsxs)(i.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:!a,className:"w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors focus:outline-none focus:bg-muted ".concat("danger"===e.variant?"text-danger hover:bg-danger-subtle focus:bg-danger-subtle":"text-foreground hover:bg-muted"," ").concat(a?"":"opacity-50 cursor-not-allowed"),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<N.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-border"})]},e.id))}):null});var nx=n(30061);let nf="commandmate.worktree.fileMetadataDisplay",ng={showSize:!0,showCreated:!1,showModified:!1},np="commandmate:fileMetadataDisplayChange";function nb(e){return void 0===e?"":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB")}let nv=(0,i.memo)(function(e){let{expanded:t}=e;return(0,r.jsx)("svg",{"data-testid":"chevron-icon",className:"w-4 h-4 text-muted-foreground transition-transform ".concat(t?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),ny=(0,i.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 text-warning",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):(0,r.jsx)("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),nw=(0,i.memo)(function(e){let{text:t,query:n}=e;if(!n||!n.trim())return(0,r.jsx)(r.Fragment,{children:t});let a=(0,x.Nt)(n),s=t.split(RegExp("(".concat(a,")"),"gi"));return(0,r.jsx)(r.Fragment,{children:s.map((e,t)=>e.toLowerCase()===n.toLowerCase()?(0,r.jsx)("mark",{className:"bg-warning-border text-foreground px-0.5 rounded",children:e},t):(0,r.jsx)("span",{children:e},t))})}),nj=(0,i.memo)(function(e){let{extension:t}=e,n=(0,i.useMemo)(()=>t&&({ts:"text-info",tsx:"text-info",js:"text-warning",jsx:"text-warning",json:"text-warning",md:"text-muted-foreground",css:"text-pink-500",scss:"text-pink-500",html:"text-warning",py:"text-success"})[t]||"text-muted-foreground",[t]);return(0,r.jsx)("svg",{"data-testid":"file-icon",className:"w-5 h-5 ".concat(n),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),nk=(0,i.memo)(function e(t){let{item:n,path:a,depth:s,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:h,onLoadChildren:x,onContextMenu:f,searchQuery:g,searchMode:p,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=ng}=t,w=(0,c.c)("worktree"),[j,k]=(0,i.useState)(!1),N=a?"".concat(a,"/").concat(n.name):n.name,C=o.has(N),S="directory"===n.type,T=d.get(N),E=(0,i.useMemo)(()=>v?tO(v):void 0,[v]),I=(0,i.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(w("fileTree.metadata.size"),": ").concat(nb(n.size))),n.birthtime){let t=(0,tB.bg)(new Date(n.birthtime),E);t&&e.push("".concat(w("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,tB.bg)(new Date(n.mtime),E);t&&e.push("".concat(w("fileTree.metadata.modified"),": ").concat(t))}return e.length>0?e.join("\n"):void 0},[S,n.size,n.birthtime,n.mtime,E,w]),M=(0,i.useCallback)(async()=>{S?(C||T||(k(!0),await x(N),k(!1)),m(N)):null==h||h(N)},[S,C,T,N,x,m,h]),L=(0,i.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),M())},[M]),A=(0,i.useCallback)(e=>{e.preventDefault(),null==f||f(e,N,S?"directory":"file")},[N,S,f]),R=function(e){let{delay:t=500,moveThreshold:n=10,onLongPress:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(null),l=(0,i.useRef)(null),o=(0,i.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),s.current=null,l.current=null},[]);(0,i.useEffect)(()=>()=>o(),[o]);let c=(0,i.useCallback)(e=>{if(1!==e.touches.length)return;let n=e.touches[0];s.current={x:n.clientX,y:n.clientY},l.current=e,r.current=setTimeout(()=>{l.current&&a(l.current),o()},t)},[t,a,o]),d=(0,i.useCallback)(e=>{if(!s.current||1!==e.touches.length)return;let t=e.touches[0],a=t.clientX-s.current.x,r=t.clientY-s.current.y;Math.sqrt(a*a+r*r)>n&&o()},[n,o]);return{onTouchStart:c,onTouchMove:d,onTouchEnd:(0,i.useCallback)(()=>{o()},[o]),onTouchCancel:(0,i.useCallback)(()=>{o()},[o])}}({onLongPress:(0,i.useCallback)(e=>{null==f||f(e,N,S?"directory":"file")},[N,S,f])}),P={...function(e){let t=Math.min(e,20);return{paddingLeft:"".concat(.5+ +t,"rem")}}(s),touchAction:"manipulation",WebkitTouchCallout:"none"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"tree-item-".concat(n.name),role:"treeitem","aria-selected":!1,"aria-expanded":S?C:void 0,tabIndex:0,className:"flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-muted rounded transition-colors",style:P,onClick:M,onKeyDown:L,onContextMenu:A,onTouchStart:R.onTouchStart,onTouchMove:R.onTouchMove,onTouchEnd:R.onTouchEnd,onTouchCancel:R.onTouchCancel,children:[S?(0,r.jsx)("span",{className:"w-4 h-4 flex items-center justify-center",children:j?(0,r.jsx)(u.y,{size:"xs",variant:"accent"}):(0,r.jsx)(nv,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4"}),S?(0,r.jsx)(ny,{open:C}):(0,r.jsx)(nj,{extension:n.extension}),(0,r.jsx)(nx.nR,{content:n.name,metadata:I,className:"flex-1 truncate text-sm text-foreground",children:"name"===p&&g?(0,r.jsx)(nw,{text:n.name,query:g}):n.name}),y.showSize&&(0,r.jsx)("span",{"data-testid":"tree-item-size",className:"text-xs text-muted-foreground flex-shrink-0",children:S?void 0!==n.itemCount&&w("fileTree.itemCount",{count:n.itemCount}):nb(n.size)}),!S&&y.showCreated&&n.birthtime&&(0,r.jsx)("span",{"data-testid":"tree-item-created",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,tB.fw)(n.birthtime,E)}),!S&&y.showModified&&n.mtime&&(0,r.jsx)("span",{"data-testid":"tree-item-modified",className:"text-xs text-muted-foreground flex-shrink-0",children:(0,tB.fw)(n.mtime,E)})]}),S&&C&&T&&(0,r.jsx)("div",{role:"group",children:T.filter(e=>{let t=N?"".concat(N,"/").concat(e.name):e.name;if(!(null==g?void 0:g.trim()))return!0;if("name"===p){let t=g.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===p&&b&&b.size>0){if(b.has(t))return!0;if("directory"===e.type){for(let e of b)if(e.startsWith(t+"/"))return!0}return!1}return!0}).map(t=>(0,r.jsx)(e,{item:t,path:N,depth:s+1,worktreeId:l,expanded:o,cache:d,onToggle:m,onFileSelect:h,onLoadChildren:x,onContextMenu:f,searchQuery:g,searchMode:p,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var nN=n(26989);let nC=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function nS(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let nT=(0,i.memo)(function(e){let{settings:t,onToggle:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.useState)(!1),o=(0,i.useRef)(null),d=(0,i.useRef)(null),u=(0,i.useRef)({x:0,y:0}),[h,x]=(0,i.useState)({x:0,y:0});(0,i.useEffect)(()=>{if(!s)return;let e=e=>{o.current&&!o.current.contains(e.target)&&l(!1)},t=e=>{"Escape"===e.key&&l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[s]),(0,i.useLayoutEffect)(()=>{let e=e=>{u.current=e,x(t=>t.x===e.x&&t.y===e.y?t:e)};if(!s)return void e({x:0,y:0});let t=d.current;if(!t)return;let n=t.getBoundingClientRect();e({x:nS(n.left-u.current.x,n.width,window.innerWidth),y:nS(n.top-u.current.y,n.height,window.innerHeight)})},[s]);let f=(0,i.useCallback)(e=>{n(e)},[n]);return(0,r.jsxs)("div",{className:"relative",ref:o,"data-testid":"file-metadata-toggle",children:[(0,r.jsx)("button",{type:"button","data-testid":"file-metadata-toggle-button",onClick:()=>l(e=>!e),"aria-haspopup":"menu","aria-expanded":s,"aria-label":a("fileTree.metadata.settingsLabel"),title:a("fileTree.metadata.settingsLabel"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(nN.A,{className:"w-4 h-4","aria-hidden":"true"})}),s&&(0,r.jsxs)("div",{ref:d,role:"menu","data-testid":"file-metadata-toggle-menu",className:"absolute right-0 top-full z-20 mt-1 min-w-[12rem] rounded border border-border bg-surface shadow-lg p-1",style:0!==h.x||0!==h.y?{transform:"translate(".concat(h.x,"px, ").concat(h.y,"px)")}:void 0,children:[(0,r.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:a("fileTree.metadata.settingsTitle")}),nC.map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-xs text-foreground hover:bg-muted rounded cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"file-metadata-toggle-".concat(e.key),checked:t[e.key],onCheckedChange:()=>f(e.key),className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:a(e.labelKey)})]},e.key))]})]})});function nE(e){let{intervalMs:t,enabled:n,onPoll:a}=e,r=(0,i.useRef)(a);r.current=a;let s=(0,i.useRef)(n);s.current=n;let l=(0,i.useRef)(null);(0,i.useEffect)(()=>{function e(){null!==l.current&&(clearInterval(l.current),l.current=null)}function a(){e(),l.current=setInterval(()=>{r.current()},t)}function i(){"hidden"===document.visibilityState?e():"visible"===document.visibilityState&&s.current&&(r.current(),a())}return n?a():e(),document.addEventListener("visibilitychange",i),()=>{e(),document.removeEventListener("visibilitychange",i)}},[t,n])}function nI(e){return"commandmate:file-tree-expanded:"+e}function nM(e){try{let t=window.localStorage.getItem(nI(e));if(!t)return new Set;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>"string"==typeof e))return new Set(n)}catch(e){}return new Set}var nL=n(89559);let nA=(0,i.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u,className:h="",refreshTrigger:f=0,pollingEnabled:g=!1,searchQuery:p,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:w}=e,j=(0,tP.Ym)(),k=(0,c.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,i.useState)(ng),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(nf);if(!t)return{...ng};return e=JSON.parse(t),"object"!=typeof e||null===e?{...ng}:{showSize:"boolean"==typeof e.showSize?e.showSize:ng.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:ng.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:ng.showModified}}catch(e){return{...ng}}}())},[]),(0,i.useEffect)(()=>{let e=e=>{if(e.detail){var a,r;a=e.detail.settings,r=n.current,(a.showSize!==r.showSize||a.showCreated!==r.showCreated||a.showModified!==r.showModified)&&t(e.detail.settings)}};return window.addEventListener(np,e),()=>window.removeEventListener(np,e)},[]);let a=(0,i.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(nf,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(np,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,i.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,T]=(0,i.useState)(!0),[E,I]=(0,i.useState)(null),[M,L]=(0,i.useState)([]),{expanded:A,setExpanded:R,resetExpanded:P}=function(e){let[t,n]=(0,i.useState)(()=>nM(e)),a=(0,i.useRef)(e);(0,i.useEffect)(()=>{a.current!==e&&(a.current=e,n(nM(e)))},[e]),(0,i.useEffect)(()=>{!function(e,t){try{let n=nI(e);if(0===t.size)return void window.localStorage.removeItem(n);window.localStorage.setItem(n,JSON.stringify(Array.from(t)))}catch(e){}}(a.current,t)},[t]);let r=(0,i.useCallback)(()=>{n(new Set)},[]);return{expanded:t,setExpanded:n,resetExpanded:r}}(t),[F,D]=(0,i.useState)(()=>new Map),z=(0,i.useRef)(null),O=(0,i.useRef)(A);O.current=A;let B=(0,i.useRef)(k);B.current=k;let _=(0,i.useRef)(new Set),{menuState:W,openMenu:H,closeMenu:V}=function(){let[e,t]=(0,i.useState)(ns),n=(0,i.useCallback)((e,n,a)=>{let r,s;if(e.preventDefault(),"touches"in e&&e.touches.length>0)r=e.touches[0].clientX,s=e.touches[0].clientY;else{if(!("clientX"in e))return;r=e.clientX,s=e.clientY}t({isOpen:!0,position:{x:r,y:s},targetPath:n,targetType:a})},[]),a=(0,i.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),r=(0,i.useCallback)(()=>{t(ns)},[]);return(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{a()},n=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(n),document.removeEventListener("click",t)}},[e.isOpen,a]),(0,i.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,a]),{menuState:e,openMenu:n,closeMenu:a,resetMenu:r}}(),U=(0,i.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{let n=e?"/api/worktrees/".concat(t,"/tree/").concat(e):"/api/worktrees/".concat(t,"/tree"),a=await fetch(n);if(!a.ok)throw Error(B.current("fileTree.loadDirectoryError",{status:a.status}));return await a.json()}catch(e){throw console.error("[FileTreeView] Error fetching directory:",e),e}},[t]),K=(0,i.useRef)(!0);(0,i.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]);let $=(0,i.useCallback)(async()=>{if(K.current){T(!0),I(null);try{let e=await U();if(!K.current||!e)return;let t=Array.from(O.current),n=new Map,a=[];for(let e=0;e<t.length;e+=5){if(!K.current)return;let r=t.slice(e,e+5);for(let[e,t]of(await Promise.allSettled(r.map(async e=>{let t=await U(e);return{dirPath:e,data:t}}))).entries())"fulfilled"===t.status&&t.value.data?n.set(t.value.dirPath,t.value.data.items):a.push(r[e])}if(!K.current)return;L(e.items),D(n),a.length>0&&R(e=>{let t=new Set(e);for(let e of a)e&&t.delete(e);return t})}catch(e){K.current&&I(e instanceof Error?e.message:B.current("fileTree.loadError"))}finally{K.current&&T(!1)}}},[U,R]);(0,i.useEffect)(()=>{$()},[$,f]);let q=(0,i.useRef)(null),J=(0,i.useRef)(!1);(0,i.useEffect)(()=>{q.current=null},[t]),nE({intervalMs:5e3,enabled:g,onPoll:(0,i.useCallback)(async()=>{if(K.current&&!J.current){J.current=!0;try{let e=["",...Array.from(O.current)],t=new Map;for(let n=0;n<e.length;n+=5){if(!K.current)return;let a=e.slice(n,n+5);for(let{dirPath:e,hash:n}of(await Promise.all(a.map(async e=>{try{var t;let n=await U(e);return{dirPath:e,hash:JSON.stringify(null!=(t=null==n?void 0:n.items)?t:null)}}catch(t){return{dirPath:e,hash:"unavailable"}}}))))t.set(e,n)}if(!K.current)return;let n=q.current;if(q.current=t,null===n)return;let a=!1;for(let[e,r]of t){let t=n.get(e);if(void 0!==t&&t!==r){a=!0;break}}a&&$()}finally{J.current=!1}}},[U,$])});let G=(0,i.useCallback)(async e=>{if(!(F.has(e)||_.current.has(e))){_.current.add(e);try{let t=await U(e);t&&D(n=>{let a=new Map(n);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{_.current.delete(e)}}},[F,U]),Y=(0,i.useCallback)(e=>{R(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[R]),X=(0,i.useCallback)(()=>{var e;P(),D(new Map),null==(e=z.current)||e.scrollTo({top:0}),null==w||w()},[P,w]),Q=(0,i.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,x.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,i.useEffect)(()=>{Q.size>0&&R(e=>{let t=new Set(e);for(let e of Q)(F.has(e)||(null==v?void 0:v.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[Q,F,v,R]);let Z=(0,i.useMemo)(()=>{if(!(null==p?void 0:p.trim()))return M;if("name"===b){let e=p.toLowerCase(),t=(n,a)=>n.filter(n=>{let r=a?"".concat(a,"/").concat(n.name):n.name,s=n.name.toLowerCase().includes(e);if("directory"===n.type){let e=F.get(r);if(e&&t(e,r).length>0)return!0}return s});return t(M,"")}return"content"===b&&Q.size>0?M.filter(e=>{if(Q.has(e.name))return!0;if("directory"===e.type){for(let t of Q)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):M},[M,p,b,Q,F]);if(S&&0===M.length)return(0,r.jsx)("div",{"data-testid":"file-tree-loading",className:"p-2 ".concat(h),role:"status","aria-label":k("fileTree.loading"),children:[0,8,16,8,0,8].map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1.5 pr-2",style:{paddingLeft:"".concat(8+e,"px")},children:[(0,r.jsx)(m.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(m.EA,{className:"h-4 ".concat(t%3==0?"w-32":t%3==1?"w-24":"w-40"," max-w-full")})]},t))});if(E&&0===M.length)return(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-danger-subtle border border-danger-border rounded-lg ".concat(h),children:(0,r.jsx)("p",{className:"text-sm text-danger",children:E})});let ee=S&&M.length>0,et=!!E&&M.length>0;return 0===M.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-muted-foreground ".concat(h),children:[(0,r.jsx)("p",{className:"text-sm",children:k("fileTree.empty")}),(a||s)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)(m.$n,{variant:"ghost","data-testid":"empty-new-file-button",onClick:()=>a(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(nl.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)(m.$n,{variant:"ghost","data-testid":"empty-new-directory-button",onClick:()=>s(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(ni.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==p?void 0:p.trim())&&0===Z.length?(0,r.jsx)("div",{"data-testid":"file-tree-no-results",className:"p-4 text-center text-muted-foreground ".concat(h),children:(0,r.jsx)("p",{className:"text-sm",children:k("content"===b?"fileTree.noResultsContaining":"fileTree.noResultsMatching",{query:p})})}):(0,r.jsxs)("div",{ref:z,"data-testid":"file-tree-view",role:"tree","aria-label":k("fileTree.label"),className:"overflow-auto bg-surface ".concat(h),children:[(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex items-center gap-1 p-1 border-b border-border",children:[a&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>a(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(nl.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),s&&(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>s(""),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(ni.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(nT,{settings:N,onToggle:C}),ee&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-indicator",role:"status","aria-live":"polite",className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"w-3 h-3 border-2 border-input border-t-cyan-500 rounded-full animate-spin"}),(0,r.jsx)("span",{className:"sr-only",children:k("fileTree.refreshing")})]}),(0,r.jsx)("button",{"data-testid":"file-tree-refresh-button",type:"button",onClick:()=>{$()},disabled:ee,"aria-label":k("fileTree.refreshLabel"),title:k("actions.refresh"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)(nL.A,{className:"w-4 h-4 ".concat(ee?"animate-spin":""),"aria-hidden":"true"})}),(0,r.jsx)("button",{"data-testid":"file-tree-reset-button",type:"button",onClick:X,"aria-label":k("fileTree.resetViewLabel"),title:k("actions.resetView"),className:"flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:(0,r.jsx)(tA.A,{className:"w-4 h-4","aria-hidden":"true"})})]})]}),et&&(0,r.jsxs)("div",{"data-testid":"file-tree-refetch-error",role:"alert",className:"flex items-center gap-2 px-2 py-1 text-xs bg-danger-subtle border-b border-danger-border text-danger-foreground",children:[(0,r.jsx)(tL.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:E}),(0,r.jsx)(m.$n,{variant:"ghost","data-testid":"file-tree-refetch-retry-button",onClick:()=>{$()},className:"px-2 py-0.5 text-xs rounded border border-danger-border hover:bg-danger-subtle transition-colors",children:k("actions.retry")})]}),Z.map(e=>(0,r.jsx)(nk,{item:e,path:"",depth:0,worktreeId:t,expanded:A,cache:F,onToggle:Y,onFileSelect:y||n,onLoadChildren:G,onContextMenu:H,searchQuery:p,searchMode:b,matchedPaths:Q,dateFnsLocaleStr:j,metadataDisplay:N},e.name)),(0,r.jsx)(nh,{isOpen:W.isOpen,position:W.position,targetPath:W.targetPath,targetType:W.targetType,onClose:V,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u})]})}),nR=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),nP=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),nF=(0,i.memo)(function(){let e=(0,c.c)("worktree");return(0,r.jsx)(u.y,{size:"sm",variant:"accent","data-testid":"search-loading",role:"status","aria-hidden":!1,"aria-label":e("search.searching")})}),nD=(0,i.memo)(function(e){let{query:t,mode:n,isSearching:a,error:s,onQueryChange:l,onModeChange:o,onClear:d,placeholder:u,className:m=""}=e,h=(0,i.useRef)(null),x=(0,c.c)("worktree"),f=(0,i.useCallback)(e=>{l(e.target.value)},[l]),g=(0,i.useCallback)(()=>{var e;d(),null==(e=h.current)||e.focus()},[d]),p=(0,i.useCallback)(e=>{if("Escape"===e.key)if(t)g();else{var n;null==(n=h.current)||n.blur()}},[t,g]);return(0,i.useEffect)(()=>{if(!(window.innerWidth<X.D)){let e=setTimeout(()=>{var e;null==(e=h.current)||e.focus()},100);return()=>clearTimeout(e)}},[]),(0,r.jsxs)("div",{"data-testid":"search-bar",className:"flex flex-col gap-2 p-2 bg-surface dark:bg-surface-2 border-b border-border ".concat(m),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(nR,{})}),(0,r.jsx)("input",{ref:h,type:"text","data-testid":"search-input",value:t,onChange:f,onKeyDown:p,placeholder:null!=u?u:x("search.placeholder"),className:"flex-1 min-w-0 px-2 py-1 text-sm bg-muted text-foreground border border-input rounded focus:outline-none focus:ring-1 focus:ring-ring focus:border-accent-500","aria-label":x("search.label"),"aria-busy":a}),(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?(0,r.jsx)(nF,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:g,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors","aria-label":x("search.clear"),children:(0,r.jsx)(nP,{})}):null})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1",children:x("search.mode")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>o("name"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("name"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"name"===n,children:x("search.modeName")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>o("content"),className:"px-2 py-0.5 text-xs rounded transition-colors ".concat("content"===n?"bg-accent-100 dark:bg-accent-900 text-accent-700 dark:text-accent-300 font-medium":"bg-muted text-muted-foreground hover:bg-muted/80"),"aria-pressed":"content"===n,children:x("search.modeContent")})]}),s&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-danger bg-danger-subtle px-2 py-1 rounded",role:"alert",children:s})]})});function nz(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var nO=n(12108),nB=n(60850);let n_=(0,i.memo)(function(e){var t,n;let{memo:a,onUpdate:s,onDelete:l,isSaving:o,error:d,className:u="",onInsertToMessage:m,onMoveUp:h,onMoveDown:x,canMoveUp:f=!0,canMoveDown:g=!0}=e,p=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=!!(h||x),[y,w]=(0,i.useState)(a.title),[j,k]=(0,i.useState)(a.content),[N,C]=(0,i.useState)(!1),S=(0,i.useRef)(void 0);(0,i.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let{isSaving:T,error:E,saveNow:I}=(0,nB.U)({value:y,saveFn:async e=>{await s(a.id,{title:e})}}),{isSaving:M,error:L,saveNow:A}=(0,nB.U)({value:j,saveFn:async e=>{await s(a.id,{content:e})}}),R=null!=(n=null!=(t=null!=d?d:null==E?void 0:E.message)?t:null==L?void 0:L.message)?n:null,P=(0,i.useCallback)(e=>{w(e.target.value)},[]),F=(0,i.useCallback)(e=>{k(e.target.value)},[]),D=(0,i.useCallback)(()=>{I()},[I]),z=(0,i.useCallback)(()=>{A()},[A]),O=(0,i.useCallback)(()=>{l(a.id)},[a.id,l]),B=(0,i.useCallback)(()=>{j.trim()&&(null==m||m(j))},[j,m]),_=(0,i.useCallback)(async()=>{if(j.trim())try{await (0,ey.l)(j),C(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>C(!1),2e3)}catch(e){}},[j]);return(0,r.jsxs)("div",{"data-testid":"memo-card","data-memo-id":a.id,tabIndex:-1,className:"bg-surface dark:bg-surface-2 border border-border rounded-lg p-4 space-y-3 focus:outline-none ".concat(u),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"text",value:y,onChange:P,onBlur:D,placeholder:p("memoTitlePlaceholder"),className:"flex-1 min-w-0 text-sm font-medium text-foreground bg-transparent border-none focus:outline-none focus:ring-0 p-0"}),(null!=o?o:T||M)&&(0,r.jsx)("span",{"data-testid":"saving-indicator",className:"text-xs text-muted-foreground",children:b("actions.saving")}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"memo-move-up-".concat(a.id),onClick:h,disabled:!f,"aria-label":p("memoMoveUp"),title:p("memoMoveUp"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(nO.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:x,disabled:!g,"aria-label":p("memoMoveDown"),title:p("memoMoveDown"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(tt.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),m&&(0,r.jsx)("button",{type:"button","data-testid":"insert-memo-content",onClick:B,"aria-label":p("memoInsertToMessage"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 transition-colors rounded",title:p("memoInsertToMessage"),children:(0,r.jsx)(tR.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:_,"aria-label":p("memoCopyContent"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded",children:N?(0,r.jsx)(eh.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(ex.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:O,"aria-label":p("memoDelete"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-danger transition-colors rounded",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,r.jsx)("textarea",{value:j,onChange:F,onBlur:z,placeholder:p("memoContentPlaceholder"),rows:4,className:"w-full text-sm text-foreground bg-muted border border-border rounded-md p-2 resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),R&&(0,r.jsx)("div",{className:"text-xs text-danger",children:R})]})}),nW=(0,i.memo)(function(e){let{currentCount:t,maxCount:n,onAdd:a,isLoading:s=!1,className:l=""}=e,i=(0,c.c)("schedule"),o=Math.max(0,n-t),d=t>=n||s;return(0,r.jsxs)("div",{"data-testid":"memo-add-button",className:"flex flex-col items-center gap-2 ".concat(l),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{d||a()},disabled:d,"aria-label":i("memoAdd"),"aria-disabled":d,className:"\n flex items-center gap-2 px-4 py-2 rounded-lg border-2 border-dashed\n transition-colors focus:outline-none focus:ring-2 focus:ring-ring\n ".concat(d?"border-border text-muted-foreground cursor-not-allowed opacity-50":"border-border text-muted-foreground hover:border-accent-400 dark:hover:border-accent-500 hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/30","\n "),children:[s?(0,r.jsx)(u.y,{"data-testid":"loading-indicator",size:"md",variant:"accent"}):(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:i("memoAdd")})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:i("memoRemaining",{count:o})})]})});function nH(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:s,onNext:l,onPrev:o,onClose:d,onCompositionStart:u,onCompositionEnd:h}=e,x=(0,c.c)("schedule"),f=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null==(e=f.current)||e.focus()},[]);let g=(0,i.useCallback)(e=>{"Escape"===e.key?d():"Enter"===e.key&&(e.preventDefault(),l())},[d,l]),p=(0,i.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":"".concat(s+1,"/").concat(a);return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border border-input rounded",role:"search","aria-label":x("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:f,type:"text",value:t,onChange:p,onKeyDown:g,onCompositionStart:u,onCompositionEnd:h,placeholder:x("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":x("memoSearchInputLabel"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{role:"status","aria-live":"polite","aria-atomic":"true",className:"text-muted-foreground text-xs min-w-[3rem] text-right",children:b}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===a,"aria-label":x("memoSearchPrev"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▲"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,disabled:0===a,"aria-label":x("memoSearchNext"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50 min-w-[36px] min-h-[36px] flex items-center justify-center text-base",children:"▼"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:d,"aria-label":x("memoSearchClose"),className:"text-muted-foreground hover:text-foreground dark:hover:text-white min-w-[36px] min-h-[36px] flex items-center justify-center text-base ml-1",children:"✕"})]})}let nV=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a}=e,s=(0,c.c)("schedule"),l=(0,c.c)("common"),o=(0,eo.SC)(),[d,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(!0),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[w,j]=(0,i.useState)(!1),k=(0,i.useRef)(null),{query:N,matches:C,currentMatch:S,totalCount:T,setQuery:E,reset:I,navigateNext:M,navigatePrev:L,onCompositionStart:A,onCompositionEnd:R}=function(e){let{memos:t}=e,[n,a]=(0,i.useState)(""),[r,s]=(0,i.useState)([]),[l,o]=(0,i.useState)(-1),c=(0,i.useRef)(null),d=(0,i.useRef)(""),u=(0,i.useRef)(!1),m=(0,i.useRef)(nz(t)),h=(0,i.useRef)(t);h.current=t;let x=r.length,f=(0,i.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),g=(0,i.useCallback)(e=>{let t=function(e,t){if(t.length<2||0===e.length)return[];let n=t.toLowerCase();return e.filter(e=>-1!==e.title.toLowerCase().indexOf(n)||-1!==e.content.toLowerCase().indexOf(n))}(h.current,e);s(t),o(t.length>0?0:-1)},[]),p=(0,i.useCallback)(e=>{f(),d.current=e,u.current||(c.current=setTimeout(()=>{g(e)},300))},[f,g]),b=(0,i.useCallback)(e=>{a(e),p(e)},[p]),v=(0,i.useCallback)(()=>{a(""),d.current="",s([]),o(-1),f()},[f]),y=(0,i.useCallback)(()=>{o(e=>0===x?-1:(e+1)%x)},[x]),w=(0,i.useCallback)(()=>{o(e=>0===x?-1:(e-1+x)%x)},[x]),j=(0,i.useCallback)(()=>{u.current=!0,f()},[f]),k=(0,i.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=2&&(f(),c.current=setTimeout(()=>{g(e)},300))},[f,g]);return(0,i.useEffect)(()=>{let e=nz(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=2&&g(n)},[t,g]),(0,i.useEffect)(()=>()=>{f(),d.current=""},[f]),{query:n,matches:r,currentMatch:l,totalCount:x,setQuery:b,reset:v,navigateNext:y,navigatePrev:w,onCompositionStart:j,onCompositionEnd:k}}({memos:d}),P=w&&N.length>0,F=P?C:d,D=(0,i.useCallback)(async()=>{x(!0),b(null);try{let e=await _.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,_.hS)(e))}finally{x(!1)}},[t]);(0,i.useEffect)(()=>{D()},[D]);let O=(0,i.useCallback)(async()=>{g(!0),y(null);try{let e=await _.$T.create(t,{title:s("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,_.hS)(e))}finally{g(!1)}},[t,s]),B=(0,i.useCallback)(async(e,n)=>{await _.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),W=(0,i.useCallback)(async e=>{var n;let a=d.find(t=>t.id===e);if(await o({description:l("confirmDelete",{name:null!=(n=null==a?void 0:a.title)?n:""}),variant:"danger"}))try{await _.$T.delete(t,e),m(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t,d,o,l]),H=(0,i.useCallback)(async(e,n)=>{let a=e+n;if(a<0||a>=d.length)return;let r=[...d];[r[e],r[a]]=[r[a],r[e]],m(r);try{await _.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,_.hS)(e)),await D()}},[d,t,D]),V=(0,i.useCallback)(()=>{D()},[D]),U=(0,i.useCallback)(()=>{j(e=>(e&&I(),!e))},[I]),K=(0,i.useCallback)(()=>{j(!1),I()},[I]);return((0,i.useEffect)(()=>{var e;if(!P||S<0)return;let t=C[S];if(!t)return;let n=null==(e=k.current)?void 0:e.querySelector('[data-memo-id="'.concat(t.id,'"]'));n&&(n.scrollIntoView({block:"nearest"}),n.focus({preventScroll:!0}))},[P,S,C]),h)?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{"data-testid":"memo-loading",className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:s("memoLoading")})]})}):p?(0,r.jsx)("div",{"data-testid":"memo-pane",className:"flex flex-col items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3 text-center",children:[(0,r.jsx)("svg",{className:"w-12 h-12 text-danger",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{className:"text-sm text-danger-foreground",children:p}),(0,r.jsx)("button",{type:"button",onClick:V,"aria-label":l("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:l("retry")})]})}):(0,r.jsxs)("div",{ref:k,"data-testid":"memo-pane",className:"flex flex-col gap-4 p-4 overflow-y-auto ".concat(n),children:[(0,r.jsx)("div",{"data-testid":"memo-pane-header",className:"flex items-center gap-2",children:w?(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(nH,{query:N,onQueryChange:E,matchCount:T,currentIndex:S,onNext:M,onPrev:L,onClose:K,onCompositionStart:A,onCompositionEnd:R})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("button",{type:"button","data-testid":"memo-search-toggle",onClick:U,"aria-label":s("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(z.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===d.length&&!P&&!v&&(0,r.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,r.jsx)("p",{children:s("memoEmpty")}),(0,r.jsx)("p",{className:"text-sm",children:s("memoEmptyHint")})]}),P&&0===F.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:s("memoNoMatch")})}),F.map((e,t)=>(0,r.jsx)(n_,{memo:e,onUpdate:B,onDelete:W,onInsertToMessage:a,onMoveUp:P?void 0:()=>H(t,-1),onMoveDown:P?void 0:()=>H(t,1),canMoveUp:!P&&t>0,canMoveDown:!P&&t<d.length-1},e.id)),v&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:v}),!P&&(0,r.jsx)(nW,{currentCount:d.length,maxCount:20,onAdd:O,isLoading:f,className:"mt-2"})]})});var nU=n(85872),nK=n(53292),n$=n(53482);let nq={todo:"border-input text-muted-foreground",doing:"border-warning-border bg-warning-subtle text-warning-foreground",done:"border-success-border bg-success-subtle text-success-foreground"},nJ=i.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common"),l=(0,eo.SC)(),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(""),[h,x]=(0,i.useState)(!0),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[w,j]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),T=(0,i.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),E=(0,i.useCallback)(async()=>{x(!0),b(null);try{let e=await nU.Ar.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{x(!1)}},[t,a]);(0,i.useEffect)(()=>{E()},[t]);let I=(0,i.useCallback)(async()=>{let e=u.trim();if(e&&!f){g(!0),b(null);try{let n=await nU.Ar.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{g(!1)}}},[u,f,t,a]),M=(0,i.useCallback)(async e=>{let n=function(e){let t=nU.KG.indexOf(e);return nU.KG[(t+1)%nU.KG.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await nU.Ar.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),E()}},[t,E,a]),L=(0,i.useCallback)(async e=>{if(await l({description:s("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await nU.Ar.remove(t,e.id),d(t=>t.filter(t=>t.id!==e.id))}catch(e){b(e instanceof Error?e.message:a("todo.deleteError"))}}},[t,a,l,s]),A=(0,i.useCallback)(e=>{y(e),j(e.content),N(e.detail),b(null)},[]),R=(0,i.useCallback)(()=>{y(null),S(!1)},[]),P=(0,i.useCallback)(async()=>{if(!v)return;let e=w.trim();if(e&&!C){S(!0),b(null);try{let n=await nU.Ar.update(t,v.id,{content:e,detail:k});d(e=>e.map(e=>e.id===v.id?n:e)),R()}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),S(!1)}}},[v,w,k,C,t,R,a]),F=(0,i.useCallback)(async(e,n)=>{let r=e+n;if(r<0||r>=o.length)return;let s=[...o];[s[e],s[r]]=[s[r],s[e]],d(s),b(null);try{await nU.Ar.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),E()}},[o,t,E,a]),D=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),I())},[I]),z=(0,i.useMemo)(()=>({todo:o.filter(e=>"todo"===e.status).length,doing:o.filter(e=>"doing"===e.status).length,done:o.filter(e=>"done"===e.status).length}),[o]);return(0,r.jsxs)("div",{"data-testid":"todo-pane",className:"flex flex-col h-full overflow-y-auto p-4 ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,r.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),onKeyDown:D,maxLength:nK.Ll,placeholder:a("todo.addPlaceholder"),"data-testid":"todo-input",className:"flex-1 min-w-0 rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),(0,r.jsx)("button",{type:"button",onClick:I,disabled:f||0===u.trim().length,"data-testid":"todo-add-button",className:"shrink-0 rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.add")})]}),(0,r.jsxs)("div",{className:"mb-2 flex justify-end gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{"data-testid":"todo-count-todo",children:[T("todo")," ",z.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[T("doing")," ",z.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[T("done")," ",z.done]})]}),p&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:p}),h?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:a("todo.loading")}):0===o.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-empty",children:a("todo.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"todo-list",children:o.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center gap-2 rounded-md px-1 py-1 hover:bg-muted group","data-testid":"todo-item",children:[(0,r.jsx)("button",{type:"button",onClick:()=>M(e),"data-testid":"todo-status","data-status":e.status,"aria-label":a("todo.cycleStatus",{status:T(e.status)}),title:a("todo.cycleStatus",{status:T(e.status)}),className:"shrink-0 inline-flex min-h-[44px] items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium sm:min-h-0 ".concat(nq[e.status]),children:T(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>A(e),"data-testid":"todo-content","aria-label":a("todo.edit"),title:a("todo.edit"),className:"group/content flex min-h-[44px] min-w-0 flex-1 items-center gap-1.5 text-left sm:min-h-0",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm ".concat("done"===e.status?"line-through text-muted-foreground":"text-foreground group-hover/content:text-accent-700 dark:group-hover/content:text-accent-300"),children:e.content}),""!==e.detail.trim()&&(0,r.jsxs)("svg",{"data-testid":"todo-detail-indicator","aria-label":a("todo.hasDetail"),className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,r.jsx)("title",{children:a("todo.hasDetail")}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h10"})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>F(t,-1),disabled:0===t,"aria-label":a("todo.moveUp"),"data-testid":"todo-move-up",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>F(t,1),disabled:t===o.length-1,"aria-label":a("todo.moveDown"),"data-testid":"todo-move-down",className:"p-1 text-muted-foreground hover:text-foreground disabled:opacity-30",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}),(0,r.jsx)("button",{type:"button",onClick:()=>L(e),"aria-label":a("todo.delete"),"data-testid":"todo-delete",className:"inline-flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center text-muted-foreground opacity-100 transition-opacity hover:text-danger-foreground sm:min-h-0 sm:min-w-0 sm:opacity-0 sm:group-hover:opacity-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},e.id))}),(0,r.jsx)(e7.a,{isOpen:null!==v,onClose:R,title:a("todo.editTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.contentLabel")}),(0,r.jsx)("input",{type:"text",value:w,onChange:e=>j(e.target.value),maxLength:nK.Ll,placeholder:a("todo.contentPlaceholder"),"data-testid":"todo-edit-content",className:"w-full rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("span",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:a("todo.detailLabel")}),""!==k.trim()&&(0,r.jsx)(n$.i,{text:k,label:a("todo.copyDetail"),className:"!border-input !bg-surface dark:!bg-surface-2 !text-muted-foreground hover:!bg-muted"})]}),(0,r.jsx)("textarea",{value:k,onChange:e=>N(e.target.value),maxLength:nK.bu,rows:6,placeholder:a("todo.detailPlaceholder"),"data-testid":"todo-edit-detail",className:"w-full resize-y rounded-md border border-input bg-surface dark:bg-surface-2 px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:R,"data-testid":"todo-edit-cancel",className:"rounded-md border border-input px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted",children:a("todo.cancel")}),(0,r.jsx)("button",{type:"button",onClick:P,disabled:C||0===w.trim().length,"data-testid":"todo-edit-save",className:"rounded-md bg-accent-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-700 disabled:opacity-50",children:a("todo.save")})]})]})})]})});var nG=n(95740),nY=n(66630),nX=n(37586),nQ=n(47650);function nZ(e){let{isOpen:t,onClose:n,title:a,children:s,footer:l,showCloseButton:o=!0}=e,d=(0,c.c)("common"),[u,m]=(0,i.useState)(null);return((0,i.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n]),(0,i.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),(0,i.useEffect)(()=>{if(!t)return;let e=window.visualViewport;if(!e)return;let n=()=>m(e.height);return n(),e.addEventListener("resize",n),()=>e.removeEventListener("resize",n)},[t]),t)?(0,nQ.createPortal)((0,r.jsxs)("div",{"data-testid":"full-screen-modal",role:"dialog","aria-modal":"true",className:"fixed inset-0 flex flex-col bg-surface animate-slide-up",style:{zIndex:eS.M.MODAL,height:u?"".concat(u,"px"):"100dvh"},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-foreground truncate pr-2",children:a}),o&&(0,r.jsx)("button",{type:"button",onClick:n,"aria-label":d("close"),"data-testid":"full-screen-modal-close",className:"flex-shrink-0 -mr-1 p-1 text-muted-foreground hover:text-foreground transition-colors",children:(0,r.jsx)(ew.A,{className:"w-6 h-6"})})]}),(0,r.jsx)("div",{"data-testid":"full-screen-modal-body",className:"flex-1 min-h-0 overflow-y-auto overscroll-contain px-4 py-4",onFocusCapture:e=>{let t=e.target;t&&"function"==typeof t.scrollIntoView&&window.requestAnimationFrame(()=>{t.scrollIntoView({block:"center",behavior:"smooth"})})},children:s}),l&&(0,r.jsx)("div",{"data-testid":"full-screen-modal-footer",className:"flex-shrink-0 border-t border-border bg-surface px-4 py-3",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:l})]}),document.body):null}let n0=["default","acceptEdits","plan","dontAsk","bypassPermissions"],n1=["read-only","workspace-write","danger-full-access"],n2=["allow-all-tools","yolo"],n4=["--dangerously-skip-permissions"],n5=[],n3={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions"};function n6(e){switch(e){case"codex":return n1;case"copilot":return n2;case"antigravity":return n4;case"claude":return n0;default:return n5}}let n8=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/,n7=/^[a-zA-Z0-9][a-zA-Z0-9\-._/:]*$/,n9=new Set(["copilot"]),ae=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],at={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=n3.claude)?a:"",model:""},an="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring",aa="block text-xs font-semibold text-foreground mb-1",ar="mt-1 text-xs text-danger-foreground";function as(e){let{onClick:t,label:n,title:a,testId:s}=e;return(0,r.jsxs)("button",{type:"button","data-testid":s,onClick:t,title:a,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle transition-colors",children:[(0,r.jsx)(nG.A,{size:14,"aria-hidden":"true"}),n]})}function al(e){let{id:t,title:n,summary:a,icon:s,isOpen:l,onToggle:i,children:o}=e,c="schedule-section-".concat(t,"-content");return(0,r.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-section-".concat(t),"aria-expanded":l,"aria-controls":c,onClick:()=>i(t),className:"w-full flex items-center gap-3 px-3 py-2.5 text-left bg-surface-2 hover:bg-muted transition-colors",children:[(0,r.jsx)("span",{className:"flex-shrink-0 text-accent-600 dark:text-accent-400",children:s}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-semibold text-foreground",children:n}),a&&(0,r.jsx)("span",{"data-testid":"schedule-section-".concat(t,"-summary"),className:"block truncate text-xs text-muted-foreground",children:a})]}),(0,r.jsx)(tt.A,{className:"flex-shrink-0 w-4 h-4 text-muted-foreground transition-transform ".concat(l?"rotate-180":"")})]}),l&&(0,r.jsx)("div",{id:c,className:"px-3 py-3 flex flex-col gap-4",children:o})]})}function ai(e){var t,n;let{isOpen:a,worktreeId:s,initialValues:l,originalName:o,onInsertToMessage:d,instances:u,onClose:h,onSaved:x}=e,f=(0,c.c)("schedule"),g=(0,X.a)(),p=(0,i.useMemo)(()=>u&&u.length>0?u:(0,te.lu)([...te.XH]),[u]),[b,v]=(0,i.useState)(at),[y,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(null),[T,E]=(0,i.useState)(()=>new Set(["basic","advanced","message"]));(0,i.useEffect)(()=>{var e,t,n,r,s,i,o,c,d,u;if(!a)return;S(null),N(!1);let m=null!=(t=null==l?void 0:l.cliToolId)?t:at.cliToolId;v({name:null!=(n=null==l?void 0:l.name)?n:at.name,cronExpression:null!=(r=null==l?void 0:l.cronExpression)?r:at.cronExpression,message:null!=(s=null==l?void 0:l.message)?s:at.message,cliToolId:m,enabled:null!=(i=null==l?void 0:l.enabled)?i:at.enabled,permission:null!=(o=null==l?void 0:l.permission)?o:at.permission,model:null!=(c=null==l?void 0:l.model)?c:at.model});let h=p.find(e=>e.cliTool===m);w(null!=(u=null!=(d=null==h?void 0:h.id)?d:null==(e=p[0])?void 0:e.id)?u:m)},[a,l,p]),(0,i.useEffect)(()=>{a&&E(new Set(g?["basic"]:["basic","advanced","message"]))},[a,g]);let I=(0,i.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=n6(b.cliToolId),L=M.length>0,A="copilot"===b.cliToolId,R=!!o,P=(0,i.useMemo)(()=>{let e=b.name.trim();return e?e.length>100?f("edit.errorNameTooLong",{max:100}):n8.test(e)?null:f("edit.errorNameInvalid"):f("edit.errorNameRequired")},[b.name,f]),F=(0,i.useMemo)(()=>!function(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}(b.cronExpression.trim())?f("edit.errorCronInvalid"):null,[b.cronExpression,f]),D=(0,i.useMemo)(()=>b.message.trim()?b.message.length>1e4?f("edit.errorMessageTooLong",{max:1e4}):null:f("edit.errorMessageRequired"),[b.message,f]),z=(0,i.useMemo)(()=>{var e;return A&&b.model.trim()?(e=b.model.trim(),/[\x00-\x1f\x7f]/.test(e)?{valid:!1,reason:"Model name contains control characters"}:""===e.trim()?{valid:!1,reason:"Model name must not be empty"}:!n7.test(e)?{valid:!1,reason:"Model name contains invalid characters"}:e.length>128?{valid:!1,reason:"Model name exceeds ".concat(128," characters")}:{valid:!0}).valid?null:f("edit.errorModelInvalid"):null},[A,b.model,f]),O=!P&&!F&&!D&&!z,B=(0,i.useCallback)(e=>{v(t=>({...t,cliToolId:e,permission:function(e){let t=n3[e];if(void 0!==t)return t;let n=n6(e);return n.length>0?n[0]:""}(e),model:"copilot"===e?t.model:""}))},[]),_=(0,i.useCallback)(e=>{let t=p.find(t=>t.id===e);t&&(w(e),B(t.cliTool))},[p,B]),W=ae.some(e=>e.value===b.cronExpression)?b.cronExpression:"custom",H=(0,i.useCallback)(e=>{"custom"!==e&&v(t=>({...t,cronExpression:e}))},[]),V=(0,i.useCallback)(e=>{null==d||d(e),h()},[d,h]),U=(0,i.useCallback)(async()=>{if(O&&!k){N(!0),S(null);try{let e=await fetch("/api/worktrees/".concat(s,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name.trim(),cronExpression:b.cronExpression.trim(),message:b.message.trim(),cliToolId:b.cliToolId,enabled:b.enabled,permission:L?b.permission:"",model:A&&b.model.trim()?b.model.trim():void 0,originalName:null!=o?o:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));S(t.error||f("edit.saveError"));return}x(),h()}catch(e){S(f("edit.saveError"))}finally{N(!1)}}},[O,k,s,b,L,A,o,x,h,f]),K=null!=(n=null==(t=p.find(e=>e.id===y))?void 0:t.alias)?n:(0,te.f_)(b.cliToolId),$=b.name.trim()?"".concat(b.name.trim()," \xb7 ").concat(b.cronExpression):b.cronExpression,q=[K,L?b.permission:null,A&&b.model.trim()?b.model.trim():null].filter(Boolean).join(" \xb7 "),J=b.message.trim(),G=J.length>32?"".concat(J.slice(0,32),"…"):J,Y=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aa,htmlFor:"schedule-name-input",children:f("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:b.name,maxLength:100,placeholder:f("edit.namePlaceholder"),onChange:e=>v(t=>({...t,name:e.target.value})),className:an}),P&&(0,r.jsx)("p",{className:ar,"data-testid":"schedule-name-error",children:P})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-cron-input",children:f("edit.cron")}),d&&(0,r.jsx)(as,{testId:"schedule-cron-ask-ai",label:f("edit.askAiCron"),title:f("edit.askAiHint"),onClick:()=>V(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(f,b.cronExpression))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,r.jsx)("input",{id:"schedule-cron-input","data-testid":"schedule-cron-input",type:"text",value:b.cronExpression,placeholder:f("edit.cronPlaceholder"),onChange:e=>v(t=>({...t,cronExpression:e.target.value})),className:"".concat(an," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":f("edit.cronPreset"),value:W,onChange:e=>H(e.target.value),className:"".concat(an," sm:w-48"),children:[ae.map(e=>(0,r.jsx)("option",{value:e.value,children:f("edit.".concat(e.labelKey))},e.value)),(0,r.jsx)("option",{value:"custom",children:f("edit.cronPresetCustom")})]})]}),F&&(0,r.jsx)("p",{className:ar,"data-testid":"schedule-cron-error",children:F})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-enabled-toggle",checked:b.enabled,onCheckedChange:e=>v(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.enabledLabel")})]})]}),Q=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aa,htmlFor:"schedule-cli-tool-select",children:f("edit.cliTool")}),(0,r.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:y,onChange:e=>_(e.target.value),className:an,children:p.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),A&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aa,htmlFor:"schedule-model-input",children:f("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:b.model,placeholder:f("edit.modelPlaceholder"),onChange:e=>v(t=>({...t,model:e.target.value})),className:an}),z&&(0,r.jsx)("p",{className:ar,"data-testid":"schedule-model-error",children:z})]}),L&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aa,htmlFor:"schedule-permission-select",children:f("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:b.permission,onChange:e=>v(t=>({...t,permission:e.target.value})),className:an,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),Z=(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground",htmlFor:"schedule-message-input",children:f("edit.message")}),d&&(0,r.jsx)(as,{testId:"schedule-message-ask-ai",label:f("edit.askAiMessage"),title:f("edit.askAiHint"),onClick:()=>V(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(f,b.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:b.message,rows:4,maxLength:1e4,placeholder:f("edit.messagePlaceholder"),onChange:e=>v(t=>({...t,message:e.target.value})),className:"".concat(an," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[D?(0,r.jsx)("p",{className:ar,"data-testid":"schedule-message-error",children:D}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:f("edit.charCount",{count:b.message.length,max:1e4})})]})]}),ee=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(al,{id:"basic",title:f("edit.sectionBasic"),summary:$,icon:(0,r.jsx)(j.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:I,children:Y}),(0,r.jsx)(al,{id:"advanced",title:f("edit.sectionAdvanced"),summary:q,icon:(0,r.jsx)(nY.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:I,children:Q}),(0,r.jsx)(al,{id:"message",title:f("edit.sectionMessage"),summary:G,icon:(0,r.jsx)(nX.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:I,children:Z}),C&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:C})]}),et=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:h,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:f("edit.cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void U(),disabled:!O||k,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:f("edit.save")})]}),en=R?f("edit.titleEdit"):f("edit.titleCreate");return g?(0,r.jsx)(nZ,{isOpen:a,onClose:h,title:en,footer:et,children:ee}):(0,r.jsx)(e7.a,{isOpen:a,onClose:h,title:en,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[ee,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:et})]})})}function ao(e){return new Date(e).toLocaleString()}function ac(e,t){if(null===t)return null;let n=t-e;if(n<0)return null;let a=Math.floor(n/1e3),r=Math.floor(a/60),s=a%60;return r>0?"".concat(r,"m ").concat(s,"s"):"".concat(s,"s")}let ad=(0,i.memo)(function(e){let{worktreeId:t,logs:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)(null),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(async e=>{if(s===e){l(null),d(null);return}try{let n=await fetch("/api/worktrees/".concat(t,"/execution-logs/").concat(e));if(n.ok){let t=await n.json();d(t.log),l(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,s]);return 0===n.length?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")}):(0,r.jsx)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>void u(e.id),className:"w-full text-left p-3 hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm truncate max-w-[60%]",children:e.schedule_name||a("unknownSchedule")}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e){switch(e){case"completed":return"text-success-foreground bg-success-subtle";case"failed":return"text-danger-foreground bg-danger-subtle";case"timeout":return"text-warning-foreground bg-warning-subtle";case"running":return"text-accent-600 dark:text-accent-400 bg-accent-50 dark:bg-accent-900/30";case"cancelled":return"text-muted-foreground bg-muted"}}(e.status)),children:a("status.".concat(e.status))})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[ao(e.started_at),ac(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",ac(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]})]}),s===e.id&&o&&(0,r.jsxs)("div",{className:"border-t border-border p-3 bg-muted space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("message")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground",children:o.message})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:a("response")}),(0,r.jsx)("pre",{className:"text-xs whitespace-pre-wrap font-mono text-foreground max-h-60 overflow-y-auto",children:o.result||a("noOutput")})]})]})]},e.id))})});function au(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function am(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let ah=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:s}=e,l=(0,c.c)("schedule"),o=(0,eo.SC)(),[d,u]=(0,i.useState)([]),[h,x]=(0,i.useState)([]),[f,g]=(0,i.useState)([]),[p,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[w,j]=(0,i.useState)("schedules"),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(void 0),[I,M]=(0,i.useState)(void 0),L=(0,i.useCallback)(async()=>{b(!0),y(null);try{let[e,n,a]=await Promise.all([fetch("/api/worktrees/".concat(t,"/execution-logs")),fetch("/api/worktrees/".concat(t,"/schedules")),fetch("/api/worktrees/".concat(t,"/schedules/active"))]);if(e.ok){let t=await e.json();u(t.logs||[])}if(n.ok){let e=await n.json();x(e.schedules||[])}if(a.ok){let e=await a.json();g(e.schedules||[])}else g([])}catch(e){y(e instanceof Error?e.message:"Failed to fetch data")}finally{b(!1)}},[t]);(0,i.useEffect)(()=>{L()},[L]);let A=(0,i.useCallback)(async e=>{try{var n,a,r,s,l,i,o;let c=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md"));if(!c.ok)return null;let d=await c.json(),u="string"==typeof d.content?d.content:"",m=(null!=(n=(function(e){let t=new Map,n=e.split("\n"),a=null,r=!1,s=!1;for(let e of n){let n=e.trim(),l=n.match(/^##\s+(.+)$/);if(l){a=l[1].trim(),r=!1,s=!1,t.has(a)||t.set(a,[]);continue}if(!n||!n.startsWith("|")||!a)continue;if(!r){r=!0;continue}if(!s){if(n.match(/^\|[\s-:|]+\|$/)){s=!0;continue}s=!0}let i=n.split("|").slice(1,-1).map(e=>e.trim());i.length>0&&t.get(a).push(i)}return t})(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let h=function(e){let t=e.trim();if(!t)return{cliToolId:"claude",model:void 0};let n=t.split(/\s+/),a=n[0];return 1===n.length?{cliToolId:a,model:void 0}:n9.has(a)?3===n.length&&"--model"===n[1]?{cliToolId:a,model:n[2]}:{cliToolId:a,error:"".concat(a," only supports: ").concat(a," --model <modelName>")}:{cliToolId:a,error:'CLI Tool "'.concat(a,'" does not support additional options')}}(null!=(a=m[3])?a:"claude"),x=(null!=(r=m[4])?r:"true").trim().toLowerCase();return{name:e,cronExpression:(null!=(s=m[1])?s:"").trim(),message:(null!=(l=m[2])?l:"").trim(),cliToolId:h.cliToolId||"claude",enabled:""===x||"true"===x,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=h.model)?o:""}}catch(e){return null}},[t]),R=(0,i.useCallback)(()=>{M(void 0),E(void 0),S(!0)},[]),P=(0,i.useCallback)(async e=>{let t=await A(e.name);M(e.name),E(null!=t?t:{name:e.name,cronExpression:e.cron_expression,message:e.message,cliToolId:e.cli_tool_id,enabled:1===e.enabled,permission:"",model:""}),S(!0)},[A]),F=(0,i.useCallback)(async e=>{if(await o({description:l("edit.confirmDelete",{name:e}),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})).ok&&await L()}catch(e){console.error("Failed to delete schedule:",e)}},[t,l,L,o]),D=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/cmate/schedules"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,enabled:1!==e.enabled})})).ok&&await L()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,L]);return p?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:l("loading")})]})}):v?(0,r.jsx)("div",{className:"flex items-center justify-center h-full p-4 ".concat(n),children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("span",{className:"text-sm text-danger-foreground",children:v}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void L(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:l("retry")})]})}):(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(n),children:[(0,r.jsxs)("div",{className:"flex shrink-0 border-b border-border px-4 pt-3",children:[(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-schedules",role:"tab","aria-selected":"schedules"===w,onClick:()=>j("schedules"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("schedules"===w?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[l("tabs.schedules")," (",h.length,")"]}),(0,r.jsxs)("button",{type:"button","data-testid":"schedule-tab-logs",role:"tab","aria-selected":"logs"===w,onClick:()=>j("logs"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("logs"===w?"border-accent-500 text-accent-700 dark:text-accent-300":"border-transparent text-muted-foreground hover:text-foreground"),children:[l("tabs.logs")," (",d.length,")"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"schedules"===w?(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"rounded border border-accent-100 bg-accent-50/60 p-3 dark:border-accent-900/40 dark:bg-accent-950/20",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsxs)("span",{className:"text-sm font-semibold text-accent-900 dark:text-accent-200",children:[l("activeSchedulesTitle")," (",f.length,")"]}),(0,r.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:l("activeSchedulesDescription")})]}),0===f.length?(0,r.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:l("noActiveSchedules")}):(0,r.jsx)("div",{className:"space-y-2",children:f.map(e=>(0,r.jsxs)("div",{className:"rounded border border-accent-200/80 bg-white/80 p-3 dark:border-accent-900/40 dark:bg-surface/60",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm text-foreground",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(e.isCronActive?"bg-success-subtle text-success-foreground":"bg-danger-subtle text-danger-foreground"),children:e.isCronActive?l("activeState.active"):l("activeState.inactive")}),e.isExecuting&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-100 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300",children:l("activeState.executing")})]})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cronExpression||"N/A"]}),(0,r.jsxs)("span",{className:"ml-3",children:[l("agentLabel"),": ",e.cliToolId]}),e.model&&(0,r.jsxs)("span",{className:"ml-3",children:["model: ",e.model]}),e.nextRunAt&&(0,r.jsxs)("span",{className:"ml-3",children:[l("nextRun"),": ",ao(e.nextRunAt)]})]})]},e.scheduleId))})]}),0===h.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsxs)("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",className:"w-7 h-7",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5V12l3 2"})]})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:l("emptyState.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:l("emptyState.description")}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:R,className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),l("emptyState.createButton")]}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-manual-toggle","aria-expanded":k,onClick:()=>N(e=>!e),className:"mt-5 text-xs text-accent-700 dark:text-accent-300 hover:underline",children:l("emptyState.manualToggle")}),k&&(0,r.jsxs)("ol",{"data-testid":"schedule-manual-steps",className:"mt-3 text-xs text-left inline-block space-y-1.5 list-decimal list-inside text-muted-foreground",children:[(0,r.jsx)("li",{children:l("noSchedulesStep1")}),(0,r.jsx)("li",{children:l("noSchedulesStep2")}),(0,r.jsx)("li",{children:l("noSchedulesStep3")}),(0,r.jsx)("li",{children:l("noSchedulesStep4")})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,r.jsxs)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:R,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3.5 h-3.5",children:(0,r.jsx)("path",{d:"M10 4a1 1 0 011 1v4h4a1 1 0 110 2h-4v4a1 1 0 11-2 0v-4H5a1 1 0 110-2h4V5a1 1 0 011-1z"})}),l("edit.newSchedule")]})}),(0,r.jsx)("div",{className:"space-y-2",children:h.map(e=>{let t=1===e.enabled;return(0,r.jsxs)("div",{className:"border border-border rounded p-3 bg-white dark:bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium text-sm truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":t?l("edit.disable"):l("edit.enable"),title:t?l("edit.disable"):l("edit.enable"),"data-testid":"schedule-toggle-".concat(e.name),onClick:()=>void D(e),className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ".concat(t?"bg-success":"bg-input"),children:(0,r.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform ".concat(t?"translate-x-4":"translate-x-0.5")})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-edit-".concat(e.name),"aria-label":l("edit.edit"),title:l("edit.edit"),onClick:()=>void P(e),className:"p-1.5 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded transition-colors",children:(0,r.jsx)(au,{})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button","data-testid":"schedule-delete-".concat(e.name),"aria-label":l("edit.delete"),title:l("edit.delete"),onClick:()=>void F(e.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,r.jsx)(am,{})})]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,r.jsxs)("span",{children:[l("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[l("lastRun"),": ",ao(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(ad,{worktreeId:t,logs:d})}),(0,r.jsx)(ai,{isOpen:C,worktreeId:t,initialValues:T,originalName:I,onInsertToMessage:a,instances:s,onClose:()=>S(!1),onSaved:()=>{L()}})]})}),ax=(0,i.memo)(function(e){let{worktreeId:t,vibeLocalModel:n,onVibeLocalModelChange:a,vibeLocalContextWindow:s,onVibeLocalContextWindowChange:l}=e,o=(0,c.c)("schedule"),[d,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(null),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null!=s?String(s):""),[w,j]=(0,i.useState)(!1);(0,i.useEffect)(()=>{y(null!=s?String(s):"")},[s]),(0,i.useEffect)(()=>{let e=!1;return g(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),x(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),x("Failed to fetch models"))}).finally(()=>{e||g(!1)}),()=>{e=!0}},[]);let k=(0,i.useCallback)(async e=>{let n=e.target.value,r=""===n?null:n;b(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalModel:r})})).ok&&a(r)}catch(e){}finally{b(!1)}},[t,a]),N=(0,i.useCallback)(e=>{y(e.target.value)},[]),C=(0,i.useCallback)(async()=>{let e=v.trim(),n=parseInt(e,10),a=""===e||Number.isNaN(n)?null:n,r=null!=s?s:null;if(a!==r){j(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({vibeLocalContextWindow:a})})).ok?null==l||l(a):y(null!=r?String(r):"")}catch(e){y(null!=r?String(r):"")}finally{j(!1)}}},[v,s,t,l]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:o("vibeLocalModel")}),f?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),o("loading")]}):h&&0===d.length?(0,r.jsx)("p",{className:"text-xs text-warning-foreground",children:o("ollamaNotAvailable")}):(0,r.jsxs)("select",{"data-testid":"vibe-local-model-select",value:null!=n?n:"",onChange:k,disabled:p,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:o("vibeLocalModelDefault")}),d.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.parameterSize?" (".concat(e.parameterSize,")"):""]},e.name))]}),(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:o("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:te.vz,max:te.NL,value:v,onChange:N,onBlur:C,placeholder:o("vibeLocalContextWindowDefault"),disabled:w,className:"w-full text-sm border border-input rounded-md px-3 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"})]})]})}),af=(0,i.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,maxAgents:u=2,availableAgents:h=te.XH,persistToServer:x=!0}=e,f=(0,c.c)("schedule"),g=n.length>u?n.slice(0,u):n,[p,b]=(0,i.useState)(()=>new Set(g)),[v,y]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1),k=(0,i.useRef)(p);k.current=p,(0,i.useEffect)(()=>{w||b(new Set(g))},[n,w,u]);let N=p.has("vibe-local"),C=(0,i.useCallback)(async(e,n)=>{let r=new Set(k.current);if(n?r.add(e):(r.delete(e),j(!0)),b(r),r.size>=2){let e=Array.from(r);if(!x){b(new Set(e)),a(e),j(!1);return}y(!0);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({selectedAgents:e})})).ok?(b(new Set(e)),a(e)):b(new Set(g))}catch(e){b(new Set(g))}finally{y(!1),j(!1)}}},[t,g,a,x]),S=p.size>=u;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:f("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:f("selectAgents")}),(0,r.jsx)("div",{className:"space-y-3",children:h.map(e=>{let t=p.has(e),n=!t&&S;return(0,r.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-lg border transition-colors ".concat(t?"border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30":n?"border-border bg-muted opacity-50":"border-border hover:border-input hover:bg-muted"),children:[(0,r.jsx)(m.Sc,{"data-testid":"agent-checkbox-".concat(e),"aria-label":(0,te.oo)(e),checked:t,disabled:n||v,onCheckedChange:t=>C(e,!0===t)}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,te.oo)(e)})]},e)})}),v&&(0,r.jsxs)("div",{"data-testid":"agent-settings-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),f("loading")]}),N&&(0,r.jsx)(ax,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})});function ag(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function ap(e,t){if(0===t.length)return[];if(null!==e){let n=new Set(e),a=t.filter(e=>n.has(e.id));if(a.length>0)return a}return[...t]}var ab=n(49476),av=n(20017),ay=n(6191);let aw=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d}=e,m=(0,c.c)("schedule"),h=(0,c.c)("common"),x=(0,eo.SC)(),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)({}),[w,j]=(0,i.useState)(te.XH[0]),[k,N]=(0,i.useState)(null),C=n.length>=te.Ab,S=n.length<=1,T=n.some(e=>"vibe-local"===e.cliTool),E=(0,i.useCallback)(async e=>{let n=e.map((e,t)=>({...e,order:t}));g(!0),b(null);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:n})})).ok?a(n):b(m("agentInstanceSaveError"))}catch(e){b(m("agentInstanceSaveError"))}finally{g(!1)}},[t,a,m]),I=(0,i.useCallback)(()=>{if(n.length>=te.Ab)return;let e=function(e,t){let n=new Set(t.map(e=>e.id));if(!n.has(e))return e;let a=2;for(;n.has("".concat(e,"-").concat(a));)a++;return"".concat(e,"-").concat(a)}(w,n);E([...n,{id:e,cliTool:w,alias:function(e,t){let n=(0,te.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(w,e),order:n.length}])},[w,n,E]),M=(0,i.useCallback)(async e=>{var t;if(n.length<=1)return;let a=n.find(t=>t.id===e);await x({description:h("confirmDelete",{name:null!=(t=null==a?void 0:a.alias)?t:""}),variant:"danger"})&&E(n.filter(t=>t.id!==e))},[n,E,x,h]),L=(0,i.useCallback)((e,t)=>{let a=e+t;if(a<0||a>=n.length)return;let r=[...n];[r[e],r[a]]=[r[a],r[e]],E(r)},[n,E]),A=(0,i.useCallback)((e,t)=>{y(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n});let a=n.find(t=>t.id===e);a&&t!==a.alias&&E(n.map(n=>n.id===e?{...n,alias:t}:n))},[n,E]),R=(0,i.useCallback)((e,t)=>{if(e===t||e<0||t<0||e>=n.length||t>=n.length)return;let a=[...n],[r]=a.splice(e,1);a.splice(t,0,r),E(a)},[n,E]);return(0,r.jsxs)("div",{className:"p-4","data-testid":"agent-instances-pane",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:m("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:m("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:n.map((e,t)=>{let a=e.id in v?v[e.id]:e.alias,s=k===t;return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>N(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==k&&R(k,t),N(null)},onDragEnd:()=>N(null),className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface transition-colors hover:border-accent-300 dark:hover:border-accent-700 focus-within:border-accent-500 ".concat(s?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(ab.A,{className:"w-4 h-4"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("input",{type:"text","data-testid":"agent-instance-alias-".concat(e.id),"aria-label":m("agentInstanceAliasLabel"),value:a,maxLength:te.pQ,disabled:f,placeholder:m("agentInstanceAliasPlaceholder"),onChange:t=>y(n=>({...n,[e.id]:t.target.value})),onBlur:t=>A(e.id,t.target.value),onKeyDown:e=>{"Enter"===e.key&&e.currentTarget.blur()},className:"w-full text-sm font-medium border border-input rounded-md px-2 py-1 bg-surface dark:bg-surface-2 text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50"}),(0,r.jsx)(nx.nR,{content:(0,te.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"})]}),(0,r.jsxs)(eq.rI,{children:[(0,r.jsx)(eq.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":m("agentInstanceActions"),title:m("agentInstanceActions"),disabled:f,className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted disabled:opacity-30 disabled:cursor-not-allowed",children:(0,r.jsx)(av.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(eq.SQ,{align:"end",children:[(0,r.jsxs)(eq._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>L(t,-1),children:[(0,r.jsx)(nO.A,{className:"w-4 h-4"}),m("agentInstanceMoveUp")]}),(0,r.jsxs)(eq._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===n.length-1,onSelect:()=>L(t,1),children:[(0,r.jsx)(tt.A,{className:"w-4 h-4"}),m("agentInstanceMoveDown")]}),(0,r.jsx)(eq.mB,{}),(0,r.jsxs)(eq._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:S,onSelect:()=>{M(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(nd.A,{className:"w-4 h-4"}),m("agentInstanceDelete")]})]})]})]},e.id)})}),(0,r.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,r.jsx)("select",{"data-testid":"agent-instance-add-tool","aria-label":m("agentInstanceBaseTool"),value:w,disabled:f||C,onChange:e=>j(e.target.value),className:"flex-1 min-w-0 text-sm border border-input rounded-md px-2 py-2 bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-accent-500 disabled:opacity-50",children:te.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,te.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:f||C,onClick:I,className:"flex items-center gap-1 text-sm font-medium px-3 py-2 rounded-md border border-accent-200 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 hover:bg-accent-100 dark:hover:bg-accent-900/50 disabled:opacity-40 disabled:cursor-not-allowed shrink-0",children:[(0,r.jsx)(ay.A,{className:"w-4 h-4"}),m("agentInstanceAdd")]})]}),C&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:m("agentInstanceMax",{max:te.Ab})}),S&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:m("agentInstanceMin",{min:1})}),f&&(0,r.jsxs)("div",{"data-testid":"agent-instances-loading",className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"xs",variant:"muted"}),m("loading")]}),p&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:p}),T&&(0,r.jsx)(ax,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})}),aj=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o,visibleInstanceIds:d,onToggleInstanceVisible:u}=e,h=(0,c.c)("schedule"),x=new Set(d),f=d.length<=1;return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(aw,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o}),(0,r.jsxs)("div",{"data-testid":"mobile-visible-instances",className:"px-4 pb-4 border-t border-border mt-2 pt-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:h("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:h("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{let t=x.has(e.id),n=t&&f;return(0,r.jsxs)("label",{className:"flex items-center gap-2 p-2 rounded-lg cursor-pointer ".concat(n?"opacity-60 cursor-not-allowed":"hover:bg-muted"),children:[(0,r.jsx)(m.Sc,{"data-testid":"mobile-visible-instance-toggle-".concat(e.id),checked:t,disabled:n,onCheckedChange:()=>u(e.id)}),(0,r.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-foreground truncate",children:(0,te.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,te.oo)(e.cliTool)})]})]},e.id)})}),f&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:h("mobileVisibleInstanceMin")})]})]})}),ak=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var aN=n(82912),aC=n.n(aN);let aS=[36e5,108e5,288e5],aT={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function aE(e){if(e.length>500)return{valid:!1,error:"Pattern must be ".concat(500," characters or less")};if(!aC()(e))return{valid:!1,error:"Pattern may cause performance issues (catastrophic backtracking detected)"};try{return new RegExp(e),{valid:!0}}catch(e){return{valid:!1,error:"Invalid regular expression syntax"}}}function aI(e){let t=Math.max(0,e-Date.now()),n=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4),r=Math.floor(t%6e4/1e3);return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))}function aM(e){let t=Math.floor(e/6e4),n=Math.floor(t/60),a=t%60;return n>0&&a>0?"".concat(n,"h ").concat(a,"m"):n>0?"".concat(n,"h"):"".concat(a,"m")}let aL="w-full px-3 py-2 text-sm border border-input rounded-md bg-surface dark:bg-surface-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring";function aA(e){let{isOpen:t,worktreeId:n,instances:a,onClose:s,onSaved:l}=e,o=(0,c.c)("schedule"),d=(0,X.a)(),u=(0,i.useMemo)(()=>a&&a.length>0?a:(0,te.lu)([...te.XH]),[a]),[m,h]=(0,i.useState)(""),[x,f]=(0,i.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:te.XH[0]}),[g,p]=(0,i.useState)(ak[0]),[b,v]=(0,i.useState)(!1),[y,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{var e,n;t&&(h(""),p(ak[0]),w(null),v(!1),f(null!=(n=null==(e=u[0])?void 0:e.id)?n:te.XH[0]))},[t,u]),(0,i.useEffect)(()=>{if(!u.some(e=>e.id===x)){var e,t;f(null!=(t=null==(e=u[0])?void 0:e.id)?t:te.XH[0])}},[u,x]);let j=m.trim().length>0&&!b,k=(0,i.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===x);if(e){w(null),v(!0);try{let t=await fetch("/api/worktrees/".concat(n,"/timers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cliToolId:e.cliTool,instanceId:e.id,message:m.trim(),delayMs:g})});if(t.ok){let e=await t.json();l(),"session_not_running"===e.warning?(w("session_not_running"),h("")):s()}}catch(e){}finally{v(!1)}}},[n,u,x,m,g,b,l,s]),N=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-instance-select",children:o("timer.agent")}),(0,r.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:x,onChange:e=>f(e.target.value),className:aL,children:u.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-message-input",children:o("timer.message")}),(0,r.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:m,onChange:e=>h(e.target.value),placeholder:o("timer.message"),maxLength:1e4,rows:3,className:"".concat(aL," resize-none")})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1",htmlFor:"timer-delay-select",children:o("timer.delay")}),(0,r.jsx)("select",{id:"timer-delay-select","data-testid":"timer-delay-select",value:g,onChange:e=>p(Number(e.target.value)),className:aL,children:ak.map(e=>(0,r.jsx)("option",{value:e,children:aM(e)},e))})]}),"session_not_running"===y&&(0,r.jsx)("div",{"data-testid":"timer-session-warning",className:"text-xs p-2 rounded bg-warning-subtle text-warning-foreground",children:o("timer.sessionWarning")})]}),C=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:o("timer.close")}),(0,r.jsx)("button",{type:"button","data-testid":"timer-register-button",onClick:()=>void k(),disabled:!j,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-md transition-colors",children:o("timer.register")})]}),S=o("timer.titleCreate");return d?(0,r.jsx)(nZ,{isOpen:t,onClose:s,title:S,footer:C,children:N}):(0,r.jsx)(e7.a,{isOpen:t,onClose:s,title:S,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[N,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:C})]})})}function aR(e){return new Date(e).toLocaleString()}function aP(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,c.c)("schedule"),o=(0,X.a)();if(!a)return null;let d=null!=(n=null==(t=s.find(e=>e.id===a.instanceId))?void 0:t.alias)?n:a.cliToolId,u=e=>{let{label:t,children:n}=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-0.5",children:t}),(0,r.jsx)("div",{className:"text-sm text-foreground break-words",children:n})]})},m=(0,r.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"timer-detail-body",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:i("timer.message")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-message",className:"text-sm whitespace-pre-wrap break-words font-mono text-foreground bg-muted rounded p-2 max-h-60 overflow-y-auto",children:a.message})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(u,{label:i("timer.agent"),children:(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:d})}),(0,r.jsx)(u,{label:i("timer.statusLabel"),children:(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(a.status),children:i("timer.status.".concat(a.status))})}),(0,r.jsx)(u,{label:i("timer.delay"),children:aM(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:aR(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:aR(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:aR(a.sentAt)})]}),"failed"===a.status&&a.error&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-danger-foreground mb-1",children:i("timer.failureReason")}),(0,r.jsx)("pre",{"data-testid":"timer-detail-error",className:"text-xs whitespace-pre-wrap break-words font-mono text-danger-foreground bg-danger-subtle rounded p-2 max-h-40 overflow-y-auto",children:a.error})]})]}),h=(0,r.jsx)("div",{className:"flex items-center justify-end",children:(0,r.jsx)("button",{type:"button","data-testid":"timer-detail-close",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:i("timer.close")})}),x=i("timer.detailTitle");return o?(0,r.jsx)(nZ,{isOpen:!0,title:x,onClose:l,footer:h,children:m}):(0,r.jsx)(e7.a,{isOpen:!0,title:x,onClose:l,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[m,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:h})]})})}let aF=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),s=(0,eo.SC)(),l=(0,i.useMemo)(()=>n&&n.length>0?n:(0,te.lu)([...te.XH]),[n]),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),[,p]=(0,i.useState)(0),b=(0,i.useRef)(null),y=(0,i.useRef)(null),w=(0,i.useRef)(null),j=(0,i.useCallback)(async()=>{try{let n=await fetch("/api/worktrees/".concat(t,"/timers"));if(n.ok){var e;let t=await n.json();d(t.timers),m(null!=(e=t.hasMore)&&e),t.timers.length>0?w.current=t.timers[t.timers.length-1].createdAt:w.current=null}}catch(e){}},[t]),k=(0,i.useCallback)(async()=>{if(null!=w.current)try{let n=new URLSearchParams;n.set("before",String(w.current)),n.set("limit",String(50));let a=await fetch("/api/worktrees/".concat(t,"/timers?").concat(n));if(a.ok){var e;let t=await a.json();d(e=>[...e,...t.timers]),m(null!=(e=t.hasMore)&&e),t.timers.length>0&&(w.current=t.timers[t.timers.length-1].createdAt)}}catch(e){}},[t]);(0,i.useEffect)(()=>{function e(){return j(),b.current=setInterval(()=>{j()},1e4),y.current=setInterval(()=>{p(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),y.current&&clearInterval(y.current),b.current=null,y.current=null}e();let n=()=>{"hidden"===document.visibilityState?t():e()};return document.addEventListener("visibilitychange",n),()=>{t(),document.removeEventListener("visibilitychange",n)}},[j]);let N=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&j()}catch(e){}},[t,j]),C=(0,i.useCallback)(async()=>{if(await s({description:a("timer.clearConfirm"),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/timers/history"),{method:"DELETE"})).ok&&j()}catch(e){}},[t,j,a,s]),S=o.filter(e=>"pending"===e.status).length>=5;return(0,r.jsxs)("div",{className:"flex flex-col h-full p-3 gap-3 overflow-auto",children:[0===o.length?(0,r.jsxs)("div",{className:"flex flex-col items-center text-center py-8 px-4",children:[(0,r.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-accent-50 text-accent-600 dark:bg-accent-900/30 dark:text-accent-300",children:(0,r.jsx)(v.A,{className:"w-7 h-7"})}),(0,r.jsx)("p",{className:"font-semibold text-foreground mb-1",children:a("timer.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:a("timer.noTimers")}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-empty-cta",onClick:()=>x(!0),className:"inline-flex items-center gap-1.5 px-5 py-2.5 text-sm font-semibold text-white bg-accent-600 hover:bg-accent-700 rounded-lg shadow-sm transition-colors",children:[(0,r.jsx)(ay.A,{className:"w-4 h-4"}),a("timer.createButton")]})]}):(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[S&&(0,r.jsx)("span",{className:"text-xs text-warning-foreground",children:a("timer.maxReached",{max:5})}),(0,r.jsxs)("button",{type:"button","data-testid":"timer-new-button",onClick:()=>x(!0),disabled:S,className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded transition-colors whitespace-nowrap",children:[(0,r.jsx)(ay.A,{className:"w-3.5 h-3.5"}),a("timer.newTimer")]})]}),o.map(e=>{var t,n;return(0,r.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"timer-row",onClick:()=>g(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),g(e))},className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-surface text-left cursor-pointer hover:bg-muted transition-colors",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm text-foreground truncate",children:e.message.length>60?e.message.slice(0,60)+"...":e.message}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 font-medium",children:null!=(n=null==(t=l.find(t=>t.id===e.instanceId))?void 0:t.alias)?n:e.cliToolId}),(0,r.jsx)("span",{className:function(e){switch(e){case"pending":return"text-info";case"sending":case"no_session":return"text-warning-foreground";case"sent":return"text-success-foreground";case"failed":return"text-danger-foreground";default:return"text-muted-foreground"}}(e.status),children:a("timer.status.".concat(e.status))}),"pending"===e.status&&(0,r.jsx)("span",{className:"text-muted-foreground",children:aI(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:aM(e.delayMs)})]})]}),"pending"===e.status&&(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),N(e.id)},className:"px-2 py-1 text-xs text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:a("timer.cancel")})]},e.id)}),u&&(0,r.jsx)("button",{type:"button",onClick:k,className:"px-3 py-2 text-sm text-accent-600 dark:text-accent-400 hover:bg-accent-50 dark:hover:bg-accent-900/20 rounded-md transition-colors text-center",children:a("timer.loadMore")}),o.some(e=>"pending"!==e.status)&&(0,r.jsx)("button",{type:"button",onClick:C,className:"px-3 py-2 text-sm text-muted-foreground hover:bg-muted rounded-md transition-colors text-center",children:a("timer.clearHistory")})]}),(0,r.jsx)(aA,{isOpen:h,worktreeId:t,instances:n,onClose:()=>x(!1),onSaved:()=>{j()}}),(0,r.jsx)(aP,{timer:f,instances:l,onClose:()=>g(null)})]})});var aD=n(35626),az=n(75333),aO=n(34380),aB=n(37381),a_=n(80130),aW=n(95584);let aH={status:"loading",skills:[],failure:null},aV={status:"loading",skills:[],failure:null};function aU(e){var t,n,a,s,l,o,d,u;let{worktreeId:h,className:x=""}=e,f=(0,c.c)("skills"),[g,p]=(0,i.useState)(aH),[b,v]=(0,i.useState)(aV),[y,w]=(0,i.useState)(null),[j,k]=(0,i.useState)(0),[N,C]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=new AbortController;return p(aH),(0,a_.s5)(e.signal).then(t=>{e.signal.aborted||p(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[j]),(0,i.useEffect)(()=>{let e=new AbortController;return v(aV),(0,a_.Gj)(h,e.signal).then(t=>{e.signal.aborted||v(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[h,N]);let S=(0,i.useMemo)(()=>new Set(b.skills.map(e=>e.skillId)),[b.skills]),T=(0,i.useMemo)(()=>new Map(g.skills.map(e=>[e.id,{name:e.name,summary:e.summary}])),[g.skills]),E=(0,i.useMemo)(()=>{var e;return null!=(e=g.skills.find(e=>e.id===y))?e:null},[g.skills,y]),I=(0,i.useMemo)(()=>{var e;return null!=(e=b.skills.find(e=>e.skillId===y))?e:null},[b.skills,y]);if(y){let e=null!=(a=null==E?void 0:E.compatibility)?a:null,t=E?E.recommendedVersion:null!=(s=null==I?void 0:I.version)?s:null,n=E?E.recommendedVersion?e&&"compatible"!==e.status?f("detail.install.blockedIncompatible",{reason:f((0,aW.e5)(e.messageKey),{range:e.requiredRange,currentVersion:null!=(l=e.currentVersion)?l:""})}):null:f("detail.install.blockedNoVersion"):null;return(0,r.jsxs)("div",{className:"flex flex-col min-h-0 ".concat(x).trim(),"data-testid":"worktree-skills-pane",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 border-b border-border p-3",children:[(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:()=>{w(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(aD.A,{size:14,"aria-hidden":"true",className:"mr-1"}),f("worktreePane.back")]}),(0,r.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:null!=(o=null==E?void 0:E.name)?o:y})]}),(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:(0,r.jsx)(aO.B,{skillId:y,version:t,blockedReason:n,worktreeId:h})})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(x).trim(),"data-testid":"worktree-skills-pane",children:(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto p-3",children:[(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-installed",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:f("worktreePane.installedHeading")}),"loading"===b.status?(0,r.jsx)(m.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===b.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,r.jsxs)(aB.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("worktreePane.installedError")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(d=null==(t=b.failure)?void 0:t.code)?d:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>C(e=>e+1),"data-testid":"worktree-skills-installed-retry",children:f("state.retry")})]}):0===b.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("worktreePane.installedEmpty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:b.skills.map(e=>{var t;let n=T.get(e.skillId);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>w(e.skillId),"data-testid":"worktree-skills-installed-".concat(e.skillId),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"break-all text-sm font-semibold text-foreground",children:null!=(t=null==n?void 0:n.name)?t:e.skillId}),(0,r.jsx)(az.qW,{risk:e.effectiveRisk})]}),(null==n?void 0:n.summary)&&(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-installed-summary-".concat(e.skillId),children:n.summary}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:f("worktreePane.version",{version:e.version})})]})},e.skillId)})})]}),(0,r.jsxs)("section",{className:"space-y-2","data-testid":"worktree-skills-catalog",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:f("worktreePane.catalogHeading")}),"loading"===g.status?(0,r.jsx)(m.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===g.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(aB.u,{tone:"danger",children:[(0,r.jsx)("p",{children:f("state.errorNotice")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:f("state.errorCode",{code:null!=(u=null==(n=g.failure)?void 0:n.code)?u:""})})]}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:()=>k(e=>e+1),"data-testid":"worktree-skills-catalog-retry",children:f("state.retry")})]}):0===g.skills.length?(0,r.jsx)(m.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:f("state.empty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:g.skills.map(e=>{let t=(0,aW.gh)(e);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>w(e.id),"data-testid":"worktree-skills-catalog-".concat(e.id),className:"w-full rounded-lg border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-all text-sm font-semibold text-foreground",children:e.name}),S.has(e.id)&&(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-installed-badge-".concat(e.id),children:f("worktreePane.installedBadge")})]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:f("card.provider",{provider:e.provider.name})}),e.summary&&(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2","data-testid":"worktree-skills-catalog-summary-".concat(e.id),children:e.summary}),(0,r.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.compatibility&&(0,r.jsx)(az.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(az.qW,{risk:t})]})]})},e.id)})})]})]})})}let aK=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"}],a$=(0,i.memo)(function(e){let{worktreeId:t,className:n="",selectedAgents:a,onSelectedAgentsChange:s,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:u,maxAgents:m,availableAgents:h,persistToServer:x,onInsertToMessage:f,useInstanceManagement:g=!1,instances:p,onInstancesChange:b,visibleInstanceIds:v,onToggleInstanceVisible:y}=e,w=(0,c.c)("schedule"),[j,k]=(0,i.useState)("notes"),N=(0,i.useCallback)(e=>{k(e)},[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(n),children:[(0,r.jsx)("div",{className:"flex overflow-x-auto scrollbar-hide border-b border-border bg-surface dark:bg-surface-2 flex-shrink-0",children:aK.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>N(e.id),className:"flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ".concat(j===e.id?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:w(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===j&&(0,r.jsx)(nV,{worktreeId:t,className:"h-full",onInsertToMessage:f}),"logs"===j&&(0,r.jsx)(ah,{worktreeId:t,className:"h-full",onInsertToMessage:f,instances:p}),"agent"===j&&(g&&p&&b&&v&&y?(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:(0,r.jsx)(aj,{worktreeId:t,instances:p,onInstancesChange:b,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:u,visibleInstanceIds:v,onToggleInstanceVisible:y})}):(0,r.jsx)(af,{worktreeId:t,selectedAgents:a,onSelectedAgentsChange:s,vibeLocalModel:l,onVibeLocalModelChange:o,vibeLocalContextWindow:d,onVibeLocalContextWindowChange:u,maxAgents:m,availableAgents:h,persistToServer:x})),"timer"===j&&(0,r.jsx)(aF,{worktreeId:t,instances:p,selectedAgents:a}),"todo"===j&&(0,r.jsx)(nJ,{worktreeId:t,className:"h-full"}),"skills"===j&&(0,r.jsx)(aU,{worktreeId:t,className:"h-full"})]})]})});var aq=n(2317);let aJ=["status","changes","history","advanced"],aG="commandmate:gitPane:",aY={activeTab:"".concat(aG,"activeTab"),historyOpen:"".concat(aG,"historyOpen"),advancedOpen:"".concat(aG,"advancedOpen")};function aX(e){return"string"==typeof e&&aJ.includes(e)}let aQ=e=>"boolean"==typeof e,aZ=i.useLayoutEffect;function a0(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let a1=(0,i.memo)(function(e){var t,n;let{branches:a,busy:s,actionError:l,hasRunningSession:o,isMobile:d,onCheckout:u}=e,h=(0,c.c)("worktree"),x=(0,c.c)("common"),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(!1),w=(0,i.useRef)(null),j=(0,i.useRef)(null),[k,N]=(0,i.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,i.useCallback)(()=>{let e=w.current,t=j.current;if(!e||!t)return;let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),r=window.innerHeight-n.bottom,s=n.top;N({top:a0(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:a0(n.left,a.width,window.innerWidth)})},[]);aZ(()=>f?(S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}):void N(null),[f,C.length,S]);let T=(0,i.useCallback)(e=>{y(!1),b({...e}),g(!1)},[]),E=(0,i.useCallback)(()=>{p&&(u(p,v),b(null))},[p,v,u]);return(0,r.jsxs)("div",{className:"relative",ref:w,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:()=>g(e=>!e),disabled:s||0===C.length,className:"flex items-center gap-1 px-2 py-1 text-xs rounded border border-input text-accent-700 dark:text-accent-300 hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-checkout-dropdown-toggle","aria-haspopup":"menu","aria-expanded":f,"aria-label":h("git.checkout.ariaLabel"),children:[h("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),f&&"undefined"!=typeof document&&(0,nQ.createPortal)((0,r.jsx)("div",{ref:j,className:"fixed z-50 min-w-[12rem] max-w-[calc(100vw-1rem)] max-h-64 overflow-y-auto rounded border border-border bg-surface shadow-lg",style:{top:null!=(t=null==k?void 0:k.top)?t:-9999,left:null!=(n=null==k?void 0:k.left)?n:-9999},role:"menu","data-testid":"branch-checkout-menu",children:0===C.length?(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:h("git.checkout.noBranches")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:C.map(e=>{var t;let n=null!==e.checkedOutWorktreePath;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",role:"menuitem",onClick:()=>T(e),disabled:s||n,className:"w-full text-left px-3 py-1.5 font-mono text-xs text-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":h("git.checkout.checkoutBranch",{name:e.name}),title:n?h("git.checkout.checkedOutElsewhere",{path:null!=(t=e.checkedOutWorktreePath)?t:""}):void 0,children:[e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:h("git.checkout.defaultBadge")})]})},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})}),document.body),l&&(0,r.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:l}),p&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-checkout-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[h("git.checkout.confirmTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:p.name}),h("git.checkout.confirmTitleSuffix")]}),(0,r.jsx)("div",{className:"rounded border border-warning-border bg-warning-subtle px-3 py-2 text-xs text-warning-foreground",role:"alert","data-testid":"branch-history-loss-warning",children:h("git.checkout.historyLossWarning")}),o&&(0,r.jsx)("div",{className:"rounded border border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground",role:"alert","data-testid":"branch-session-warning",children:h("git.checkout.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:v,onCheckedChange:e=>y(!0===e),"data-testid":"branch-checkout-force"}),h("git.checkout.forceLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 ".concat(d?"flex-wrap":""),children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>b(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:x("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:E,disabled:s,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50","data-testid":"branch-checkout-confirm-button",children:h("git.checkout.action")})]})]})})]})}),a2=(0,i.memo)(function(e){let{open:t,onToggle:n,children:a}=e,s=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex flex-col border-t border-border","data-testid":"git-advanced-section",children:[(0,r.jsxs)("button",{type:"button",onClick:n,className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground","data-testid":"git-advanced-toggle","aria-expanded":t,children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:t?"▼":"▶"}),s("git.advancedOperations")]}),t&&(0,r.jsx)("div",{className:"flex flex-col","data-testid":"git-advanced-content",children:a})]})}),a4=(0,i.createContext)(null);function a5(e){let{value:t,children:n}=e;return(0,r.jsx)(a4.Provider,{value:t,children:n})}function a3(){let e=(0,i.useContext)(a4);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let a6=(0,i.memo)(function(e){let{path:t}=e;return(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),a8={status:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",changes:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",history:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",advanced:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"},a7={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},a9=(0,i.memo)(function(e){let{activeTab:t,onTabChange:n}=e,a=(0,c.c)("worktree");return(0,r.jsx)("div",{role:"tablist","aria-label":a("git.paneSections"),"data-testid":"git-pane-mobile-tabs",className:"flex shrink-0 border-b border-border bg-surface sticky top-0 z-30",children:aJ.map(e=>{let s=e===t,l=a(a7[e]);return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":s,"aria-label":l,"data-testid":"git-tab-".concat(e),onClick:()=>n(e),className:"flex flex-1 flex-col items-center justify-center gap-1 py-2 px-1 text-xs transition-colors border-b-2 ".concat(s?"text-accent-600 dark:text-accent-400 border-accent-500 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground border-transparent hover:text-foreground hover:bg-muted"),children:[(0,r.jsx)(a6,{path:a8[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function re(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=a3();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(a9,{activeTab:t,onTabChange:n}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0","data-testid":"git-pane-mobile-panel","data-active-tab":t,children:["status"===t&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[s,l]}),"changes"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:i}),"history"===t&&o,"advanced"===t&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:c})]})]}):(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-desktop",children:[(0,r.jsx)("div",{"data-testid":"git-group-read","data-git-group":"read",className:"border-l-2 border-info-border bg-info-subtle",children:s}),(0,r.jsxs)("div",{"data-testid":"git-group-write","data-git-group":"write",className:"border-l-2 border-input bg-muted/70 dark:bg-muted/30",children:[l,i]}),(0,r.jsx)("div",{"data-testid":"git-group-history","data-git-group":"read",className:"flex-1 flex flex-col min-h-0 border-l-2 border-info-border bg-info-subtle",children:o}),(0,r.jsx)("div",{"data-testid":"git-group-advanced","data-git-group":"advanced",className:"border-l-2 border-t-2 border-input bg-muted/50 dark:bg-muted/40",children:c})]})}let rt={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-teal-600 dark:text-teal-400",unmerged:"text-warning-foreground"},rn=(0,i.memo)(function(){return(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),ra=(0,i.memo)(function(e){let{onClick:t,disabled:n=!1,testId:a,className:s=""}=e,l=(0,c.c)("worktree");return(0,r.jsxs)("button",{type:"button",disabled:n,onClick:t,className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-info-border text-info-foreground hover:bg-info-subtle disabled:opacity-50 disabled:cursor-not-allowed ".concat(s),"data-testid":a,title:l("git.askAiTooltip"),children:[(0,r.jsx)(nG.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),rr=(0,i.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),rs=(0,i.memo)(function(e){let{message:t}=e;return(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-danger-foreground",role:"alert",children:t})}),rl={no_upstream:{badgeKey:"git.currentStatus.noUpstreamBadge",tooltipKey:"git.currentStatus.noUpstreamTooltip"},upstream_gone:{badgeKey:"git.currentStatus.upstreamGoneBadge",tooltipKey:"git.currentStatus.upstreamGoneTooltip"},detached:{badgeKey:"git.currentStatus.detachedBadge",tooltipKey:"git.currentStatus.detachedTooltip"},error:{badgeKey:"git.currentStatus.aheadBehindErrorBadge",tooltipKey:"git.currentStatus.aheadBehindErrorTooltip"}},ri=(0,i.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:s,onRefresh:l,refreshing:o=!1}=e,{isMobile:d}=a3(),m=(0,c.c)("worktree"),h=(0,tP.Ym)(),x=(0,i.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,tB.fw)(new Date(e).toISOString(),tO(h));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,h,m]),f=n&&!n.aheadBehind&&null!=(t=n.aheadBehindReason)?t:null;return(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-status-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:m("git.currentStatus.title")}),(0,r.jsx)("button",{type:"button",onClick:l,disabled:o,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":o?m("git.currentStatus.refreshing"):m("git.currentStatus.refresh"),"aria-busy":o,"data-testid":"git-status-refresh-button",children:o?(0,r.jsx)(u.y,{size:"sm",variant:"accent"}):(0,r.jsx)(rn,{})})]}),a&&!n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:m("git.currentStatus.loading")})]}),s&&!n&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:s}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap ".concat(d?"gap-1.5":"gap-2"),children:[(0,r.jsx)("span",{className:"inline-flex items-center max-w-full truncate rounded px-2 py-0.5 text-xs font-mono bg-accent-50 text-accent-700 dark:bg-accent-900/30 dark:text-accent-300","data-testid":"git-status-branch-chip",title:n.currentBranch,children:n.currentBranch}),n.isDirty&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-warning-subtle text-warning-foreground","data-testid":"git-status-dirty-badge",children:m("git.currentStatus.uncommitted")}),n.aheadBehind&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-xs font-mono bg-muted text-foreground","data-testid":"git-status-ahead-behind",children:[(0,r.jsxs)("span",{title:m("git.currentStatus.aheadTooltip"),children:["↑",n.aheadBehind.ahead]}),(0,r.jsxs)("span",{title:m("git.currentStatus.behindTooltip"),children:["↓",n.aheadBehind.behind]})]}),f&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-muted text-muted-foreground border border-border","data-testid":"git-status-ahead-behind-reason","data-reason":f,title:m(rl[f].tooltipKey),children:m(rl[f].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:x}),n.isBranchMismatch&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs bg-warning-subtle text-warning-foreground border border-warning-border",role:"alert","data-testid":"git-status-mismatch-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),(0,r.jsxs)("span",{children:[m("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:n.initialBranch})," ",m("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n.currentBranch})]})]})]})]})}),ro=(0,i.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:s,conflictFiles:l,hasUpstream:o,onFetch:d,onPull:m,onPush:h,onAbort:x,extraActions:f}=e,{isMobile:g}=a3(),p=(0,c.c)("worktree"),b="running"===t,v=null!=a?a:p("git.network.failed"),[y,w]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(!b)return void w(0);let e=setInterval(()=>w(e=>e+1),1e3);return()=>clearInterval(e)},[b]),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-network-section",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:p("git.network.quickActions")}),(0,r.jsxs)("div",{className:"flex items-center ".concat(g?"flex-wrap gap-1.5":"gap-2"),children:[d&&(0,r.jsx)("button",{type:"button",onClick:d,disabled:b,className:"px-2 py-1 text-xs rounded border border-border text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:p("git.network.fetch")}),(0,r.jsx)("button",{type:"button",onClick:m,disabled:b,className:"px-2 py-1 text-xs rounded border border-accent-300 dark:border-accent-700 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50","data-testid":"git-pull-button",children:p("git.network.pull")}),(0,r.jsx)("button",{type:"button",onClick:h,disabled:b,className:"px-2 py-1 text-xs rounded border border-success-border text-success-foreground hover:bg-success-subtle disabled:opacity-50","data-testid":"git-push-button",title:o?void 0:p("git.network.noUpstreamTooltip"),children:p("git.network.push")}),f]}),b&&(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded px-2 py-1 text-xs bg-accent-50 text-accent-800 dark:bg-accent-900/20 dark:text-accent-300 ".concat(g?"sticky top-0 z-40":""),"data-testid":"git-network-progress-bar",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",role:"status","data-testid":"git-network-operation-spinner",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:p("git.network.progress",{operation:p("push"===n?"git.network.pushing":"pull"===n?"git.network.pulling":"git.network.fetching"),elapsed:y})})]}),(0,r.jsx)("button",{type:"button",onClick:x,className:"ml-auto px-1.5 py-0.5 rounded border border-accent-400 dark:border-accent-600 hover:bg-accent-100 dark:hover:bg-accent-900/40","data-testid":"git-network-abort-button",children:p("git.network.abort")})]}),"error"===t&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-network-operation-error",children:v}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:p("git.network.conflicts",{files:l.join(", ")})})]})}),rc=(0,i.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:s,mode:l,defaultOpen:o,busy:d,onDiff:u,onToggleStage:h,onPreview:x}=e,f=(0,c.c)("worktree"),[g,p]=(0,i.useState)(o),[b,v]=(0,i.useState)(null),[y,w]=(0,i.useState)(null),[j,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),S=(0,i.useCallback)(async e=>{if(b===e){v(null),w(null),C(null);return}v(e),w(null),C(null),k(!0);try{let t=await x(e,l);w(null!=t?t:"")}catch(e){C(f("git.changes.previewFailed"))}finally{k(!1)}},[b,x,l,f]);return(0,r.jsxs)("div",{className:"border-t border-border","data-testid":n,children:[(0,r.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),className:"w-full flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:g?"▼":"▶"}),f("git.changes.listHeader",{title:t,count:a.length})]}),g&&0===a.length&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:f("git.changes.empty")}),g&&a.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:a.map(e=>{let t=b===e.path;return(0,r.jsxs)("li",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)("span",{className:"inline-block w-16 shrink-0 text-xs font-medium ".concat(rt[e.status]),children:e.status}),(0,r.jsx)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.path,children:e.path}),(0,r.jsx)("button",{type:"button",onClick:()=>S(e.path),className:"shrink-0 w-5 text-center text-xs text-muted-foreground hover:text-foreground","aria-label":f("git.changes.togglePreview",{path:e.path}),"aria-expanded":t,"data-testid":"git-changes-preview-toggle",children:t?"▼":"▶"}),(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":f("git.changes.showDiff",{path:e.path}),"data-testid":"git-changes-diff-button",children:f("git.changes.diff")}),(0,r.jsx)("button",{type:"button",onClick:()=>h(e.path),disabled:d,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","aria-label":f("git.changes.fileAction",{action:s,path:e.path}),"data-testid":"git-changes-toggle-button",children:s})]}),t&&(0,r.jsxs)("div",{className:"px-3 pb-2 bg-muted/40","data-testid":"git-changes-inline-preview",children:[j&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:f("git.changes.loadingPreview")})]}),N&&(0,r.jsx)("div",{className:"py-2 text-xs text-danger-foreground",role:"alert",children:N}),!j&&!N&&null!==y&&(""===y.trim()?(0,r.jsx)("div",{className:"py-2 text-xs text-muted-foreground",children:f("git.changes.noDiff")}):(0,r.jsxs)("div",{className:"overflow-x-auto",children:[(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:y.split("\n").slice(0,20).map((e,t)=>(0,r.jsx)(rr,{line:e},t))})}),y.split("\n").length>20&&(0,r.jsx)("button",{type:"button",onClick:()=>u(e.path,l),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:f("git.changes.truncated")})]}))]})]},"".concat(e.status,":").concat(e.path))})})]})}),rd=(0,i.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:i,busy:o,commitMessage:d,amend:u,committing:h,commitError:x,onRefresh:f,onDiff:g,onPreview:p,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:w,onCommit:j,onCommitAndPush:k}=e,{isMobile:N}=a3(),C=(0,c.c)("worktree"),S=null!=(t=null==s?void 0:s.staged)?t:[],T=null!=(n=null==s?void 0:s.unstaged)?n:[],E=null!=(a=null==s?void 0:s.untracked)?a:[],I=!h&&d.trim().length>0&&(S.length>0||u),M=!N;return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-changes-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:C("git.changes.title")}),(0,r.jsx)("button",{type:"button",onClick:f,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":C("git.changes.refresh"),children:(0,r.jsx)(rn,{})})]}),l&&!s&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:C("git.changes.loading")})]}),i&&!s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-changes-error",children:i}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rc,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:M,busy:o,onDiff:g,onPreview:p,onToggleStage:v}),(0,r.jsx)(rc,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:T,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:M,busy:o,onDiff:g,onPreview:p,onToggleStage:b}),(0,r.jsx)(rc,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:E,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:M,busy:o,onDiff:g,onPreview:p,onToggleStage:b}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 px-3 py-2 border-t border-border",children:[(0,r.jsx)("textarea",{value:d,onChange:e=>y(e.target.value),placeholder:C("git.changes.commitMessage"),rows:N?2:3,className:"w-full resize-y rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"git-commit-message","aria-label":C("git.changes.commitMessage")}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:u,onCheckedChange:e=>w(!0===e),"data-testid":"git-amend-checkbox"}),C("git.changes.amend")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:j,disabled:!I,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-button",children:C(h?"git.changes.committing":"git.changes.commit")}),(0,r.jsx)("button",{type:"button",onClick:k,disabled:!I||o,title:C("git.changes.commitAndPushTooltip"),className:"px-3 py-1 text-xs font-medium rounded border border-accent-600 text-accent-700 dark:text-accent-300 hover:bg-accent-50 dark:hover:bg-accent-900/30 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"git-commit-push-button",children:C("git.changes.commitAndPush")})]})]}),x&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:x})]})]})]})}),ru=(0,i.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:s,onToggleCommitList:l,onRefresh:o,selectedCommit:d,onCommitSelect:m,inlineDiffCommit:h,inlineFiles:x,inlineFilesLoading:f,inlineFilesError:g,onToggleInlineDiff:p,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:w,selectedFile:j,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=a3(),T=(0,c.c)("worktree"),[E,I]=(0,i.useState)(!0),[M,L]=(0,i.useState)(!0);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:s?"▼":"▶"}),T("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:o,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":T("git.history.refresh"),children:(0,r.jsx)(rn,{})})]}),s&&n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,r.jsx)(u.y,{size:"lg",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loading")})]}),s&&a&&!n&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:a}),s&&!n&&!a&&0===t.length&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:T("git.history.empty")}),!n&&!a&&t.length>0&&(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[s&&(0,r.jsx)("div",{className:"overflow-y-auto ".concat(d?"max-h-[40%] shrink-0":"flex-1"),children:(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>{let t=h===e.hash;return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{className:"flex items-stretch",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>m(e.hash),className:"flex-1 min-w-0 text-left px-3 py-2 text-sm hover:bg-muted transition-colors ".concat(d===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400 shrink-0",children:e.shortHash}),(0,r.jsx)("span",{className:"truncate text-foreground",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:e.author}),(0,r.jsx)("span",{children:new Date(e.date).toLocaleDateString()})]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>p(e.hash),className:"shrink-0 px-2 text-xs text-accent-600 dark:text-accent-400 hover:bg-muted hover:underline","aria-label":T("git.history.viewDiffFor",{hash:e.shortHash}),"aria-expanded":t,"data-testid":"git-commit-view-diff-button",children:t?T("git.history.hideDiff"):T("git.history.viewDiff")})]}),t&&(0,r.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[f&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingChangedFiles")})]}),g&&(0,r.jsx)(rs,{message:g}),!f&&!g&&0===x.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noChangedFiles")}),!f&&x.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:x.map(t=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>b(e.hash,t.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(j===t.path&&d===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),"aria-label":T("git.history.showCommitDiff",{path:t.path}),"data-testid":"git-commit-inline-file",children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(rt[t.status]),children:t.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:t.path})]})},t.path))})]})]},e.hash)})})}),d&&(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>I(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:E?"▼":"▶"}),T("git.history.changedFiles")]}),E&&(0,r.jsxs)(r.Fragment,{children:[w&&(0,r.jsx)(rs,{message:w}),y&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingChangedFiles")})]}),!y&&!w&&0===v.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noChangedFiles")}),!y&&v.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:v.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>k(e.path),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-muted transition-colors ".concat(j===e.path?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(rt[e.status]),children:e.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:e.path})]})},e.path))})]}),S&&j&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>L(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground bg-surface-2 sticky top-0 z-10 cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"w-4 text-center",children:M?"▼":"▶"}),T("git.history.diffLabel",{file:j})]}),M&&(0,r.jsxs)(r.Fragment,{children:[C&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(u.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:T("git.history.loadingDiff")})]}),!C&&N&&(0,r.jsx)("div",{className:"overflow-x-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:N.split("\n").map((e,t)=>(0,r.jsx)(rr,{line:e},t))})})}),!C&&!N&&!w&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noDiff")})]})]}),!S&&j&&!w&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground border-t border-border",children:C?T("git.history.loadingDiff"):T("git.history.diffInFilePanel",{file:j})})]})]})]})});function rm(e){return"`"+e+"`"}let rh={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},rx=(0,i.memo)(function(e){let{branches:t,include:n,loading:a,error:s,busy:l,actionError:o,onIncludeChange:d,onRefresh:u,onCreate:h,onDelete:x}=e,{isMobile:f,onInsertToMessage:g}=a3(),p=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!f),[w,j]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(""),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(!1),L=(0,i.useCallback)(()=>{0!==k.trim().length&&(h(k.trim(),C.trim()||void 0),j(!1),N(""),S(""))},[k,C,h]),A=(0,i.useCallback)(()=>{T&&(x(T.name,I),E(null),M(!1))},[T,I,x]);return(0,r.jsxs)("div",{className:"flex flex-col border-b border-border","data-testid":"git-branches-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),p("git.branches.title")]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>j(!0),className:"px-2 py-0.5 text-xs rounded border border-input text-foreground hover:bg-muted","data-testid":"git-branch-create-open",children:p("git.branches.newButton")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":p("git.branches.refresh"),children:(0,r.jsx)(rn,{})})]})]}),v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center gap-1 px-3 pb-2",children:["local","remote","all"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>d(e),className:"px-2 py-0.5 text-xs rounded ".concat(n===e?"bg-accent-100 text-accent-800 dark:bg-accent-900/40 dark:text-accent-200":"text-muted-foreground hover:bg-muted"),"data-testid":"git-branches-tab-".concat(e),children:p(rh[e])},e))}),a&&0===t.length&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:p("git.branches.loading")})]}),s&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:s}),o&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:o}),!a&&!s&&0===t.length&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-muted-foreground",children:p("git.branches.empty")}),t.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:t.map(e=>{let t=l||e.isCurrent||e.isDefault;return(0,r.jsxs)("li",{className:"flex items-center gap-2 px-3 py-1.5","data-testid":"git-branch-row",children:[(0,r.jsxs)("span",{className:"flex-1 truncate font-mono text-xs text-foreground",title:e.name,children:[e.isCurrent&&(0,r.jsx)("span",{className:"text-accent-600 dark:text-accent-400 mr-1",children:"●"}),e.name,e.isDefault&&(0,r.jsx)("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:p("git.branches.defaultBadge")})]}),(0,r.jsx)("button",{type:"button",onClick:()=>{M(!1),E(e)},disabled:t,className:"shrink-0 px-1.5 py-0.5 text-xs rounded border border-input text-danger-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed","aria-label":p("git.branches.deleteBranch",{name:e.name}),children:p("git.branches.delete")})]},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})]}),w&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-create-modal",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-foreground",children:p("git.branches.createTitle")}),(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:p("git.branches.namePlaceholder"),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-name-input","aria-label":p("git.branches.nameLabel")}),(0,r.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"w-full rounded border border-input bg-surface dark:bg-surface-2 px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring","data-testid":"branch-create-from-select","aria-label":p("git.branches.baseLabel"),children:[(0,r.jsx)("option",{value:"",children:p("git.branches.currentHead")}),t.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},"from:".concat(e.isRemote?"r":"l",":").concat(e.name)))]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[g&&(0,r.jsx)(ra,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===k.trim().length,onClick:()=>{g(function(e,t,n){let a=n&&n.trim().length>0?rm(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:rm(t.trim())})}(p,k,C)),j(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>j(!1),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:L,disabled:l||0===k.trim().length,className:"px-3 py-1 text-xs font-medium rounded bg-accent-600 text-white hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"branch-create-submit",children:p("git.branches.create")})]})]})}),T&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","data-testid":"branch-delete-confirm",children:(0,r.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-surface p-4 shadow-xl flex flex-col gap-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium text-foreground",children:[p("git.branches.deleteTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:T.name}),p("git.branches.deleteTitleSuffix")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:I,onCheckedChange:e=>M(!0===e),"data-testid":"branch-delete-force"}),p("git.branches.forceDeleteLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[g&&T&&(0,r.jsx)(ra,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{g(p(I?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:rm(T.name)})),E(null),M(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>E(null),className:"px-3 py-1 text-xs rounded border border-input text-foreground hover:bg-muted",children:b("cancel")}),(0,r.jsx)("button",{type:"button",onClick:A,disabled:l,className:"px-3 py-1 text-xs font-medium rounded bg-danger text-white hover:bg-danger/90 disabled:opacity-50","data-testid":"branch-delete-confirm-button",children:p("git.branches.delete")})]})]})})]})}),rf=(0,i.memo)(function(e){let{stashes:t,loading:n,error:a,busy:s,actionError:l,conflictNotice:o,hasRunningSession:d,onRefresh:u,onPush:h,onPop:x,onApply:f,onDrop:g}=e,{isMobile:p,onInsertToMessage:b}=a3(),v=(0,c.c)("worktree"),y=(0,c.c)("common"),[w,j]=(0,i.useState)(!p),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null);return(0,r.jsxs)("div",{className:"border-b border-border","data-testid":"git-stash-section",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>j(e=>!e),className:"flex items-center gap-1 text-sm font-medium text-muted-foreground cursor-pointer hover:text-foreground",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:w?"▼":"▶"}),v("git.stash.titlePrefix"),t.length>0&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:v("git.stash.count",{count:t.length})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[w&&b&&t.length>0&&(0,r.jsx)(ra,{testId:"stash-cleanup-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashCleanup");if(0===t.length)return n;let a=t.map(e=>"- stash@{".concat(e.index,"}: ").concat(e.message)).join("\n");return"".concat(n,"\n\n").concat(e("git.aiPrompts.stashCleanupCurrent"),"\n").concat(a)}(v,t))}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.stash.refresh"),children:(0,r.jsx)(rn,{})})]})]}),w&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-error",children:a}),l&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:l}),o&&(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-stash-conflict",children:o}),b&&(0,r.jsx)(ra,{className:"shrink-0",testId:"stash-conflict-ask-ai",onClick:()=>b(function(e,t){let n=e("git.aiPrompts.stashConflict");return t&&t.trim().length>0?"".concat(n,"\n\n").concat(t.trim()):n}(v,o))})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:v("git.stash.messagePlaceholder"),className:"w-full px-2 py-1 text-xs border border-input rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"git-stash-push-message"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,r.jsx)(m.Sc,{checked:C,onCheckedChange:e=>S(!0===e),"data-testid":"git-stash-include-untracked"}),v("git.stash.includeUntracked")]}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>{h(k,C),N(""),S(!1)},className:"px-2 py-1 text-xs rounded bg-accent-600 hover:bg-accent-700 text-white disabled:opacity-50","data-testid":"stash-push-button",children:v("git.stash.push")})]})]}),n?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",role:"status",children:v("git.stash.loading")}):0===t.length?(0,r.jsx)("div",{className:"py-3 text-center text-xs text-muted-foreground",children:v("git.stash.empty")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>(0,r.jsx)("li",{className:"py-1.5","data-testid":"git-stash-row",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("span",{className:"font-mono text-xs text-accent-600 dark:text-accent-400",children:["stash@","{",e.index,"}"]}),(0,r.jsx)("span",{className:"ml-2 text-xs text-foreground truncate",children:e.message})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>f(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-apply-button",children:v("git.stash.apply")}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>x(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-input hover:bg-muted disabled:opacity-50","data-testid":"stash-pop-button",children:v("git.stash.pop")}),(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>E(e.index),className:"px-1.5 py-0.5 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"stash-drop-button",children:v("git.stash.drop")})]})]})},e.index))})]}),null!==T&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"git-stash-drop-confirm",role:"dialog",children:[(0,r.jsxs)("p",{className:"text-xs text-danger-foreground",children:["stash@","{",T,"}",v("git.stash.dropConfirmSuffix")]}),d&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger-foreground","data-testid":"git-stash-drop-session-warning",children:v("git.danger.runningSessionWarning")}),(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:s,onClick:()=>{g(T),E(null)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"git-stash-drop-confirm-button",children:v("git.stash.drop")}),(0,r.jsx)("button",{type:"button",onClick:()=>E(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:y("cancel")})]})]})]})}),rg={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},rp=(0,i.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:s,currentBranch:l,aheadCount:o,hasRunningSession:d,onReset:u,onRevert:h,onForcePush:x}=e,{isMobile:f,onInsertToMessage:g}=a3(),p=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!1),[w,j]=(0,i.useState)("mixed"),[k,N]=(0,i.useState)(!0),[C,S]=(0,i.useState)(""),[T,E]=(0,i.useState)(!1),[I,M]=(0,i.useState)(!1),[L,A]=(0,i.useState)(!1),[R,P]=(0,i.useState)(!1),[F,D]=(0,i.useState)(!0),z=k?"HEAD":t,O=!k&&!t;return(0,r.jsxs)("div",{className:"border-t-2 border-danger-border","data-testid":"git-danger-zone-section",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>y(e=>!e),className:"w-full flex items-center gap-1 px-3 py-2 text-sm font-medium text-danger-foreground bg-danger-subtle cursor-pointer hover:bg-danger-subtle","data-testid":"git-danger-zone-toggle",children:[(0,r.jsx)("span",{className:"text-xs w-4 text-center",children:v?"▼":"▶"}),p("git.danger.title")]}),v&&(0,r.jsxs)("div",{className:"px-3 py-3 space-y-2 bg-danger-subtle",children:[a&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-danger-zone-error",children:a}),s&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:s}),(0,r.jsxs)("div",{className:"flex ".concat(f?"flex-col":"flex-row"," gap-2"),children:[(0,r.jsx)("button",{type:"button",onClick:()=>E(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle","data-testid":"git-danger-zone-reset-open",children:p("git.danger.resetOpen")}),(0,r.jsx)("button",{type:"button",disabled:!t,onClick:()=>M(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-danger-zone-revert-open",children:p("git.danger.revertOpen")}),x&&(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>P(!0),className:"px-2 py-1 text-xs rounded border border-danger-border text-danger-foreground hover:bg-danger-subtle disabled:opacity-50","data-testid":"git-force-push-open",children:p("git.danger.forcePushOpen")})]}),!t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:p("git.danger.selectCommitHint")})]}),T&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"reset-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:p("git.danger.resetTitle")}),(0,r.jsxs)(m.z6,{value:k?"head":"commit",onValueChange:e=>N("head"===e),name:"reset-target",className:"flex flex-col gap-1 mb-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:"head","data-testid":"reset-target-head"}),p("git.danger.resetTargetHead")]}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:"commit",disabled:!t,"data-testid":"reset-target-commit"}),p("git.danger.resetTargetSelectedPrefix"),t?p("git.danger.resetTargetSelectedHash",{hash:t.slice(0,7)}):p("git.danger.resetTargetNoneSelected")]})]}),(0,r.jsx)(m.z6,{value:w,onValueChange:e=>j(e),name:"reset-mode",className:"flex flex-col gap-1 mb-2",children:["soft","mixed","hard"].map(e=>(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground",children:[(0,r.jsx)(m.CU,{value:e,"data-testid":"reset-mode-".concat(e)}),p(rg[e])]},e))}),"hard"===w&&(0,r.jsxs)("div",{className:"mb-2 space-y-1",children:[(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-history-loss-warning",children:p("git.danger.resetHardWarning")}),d&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:p("git.danger.runningSessionWarning")}),(0,r.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:p("git.danger.confirmPlaceholder",{branch:null!=l?l:""}),className:"w-full px-2 py-1 text-xs border border-danger-border rounded bg-surface dark:bg-surface-2 text-foreground","data-testid":"reset-hard-branch-input"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,r.jsx)(ra,{className:"mr-auto",testId:"reset-ask-ai",disabled:O,onClick:()=>{z&&(g("hard"===w?p("git.aiPrompts.resetHard",{target:rm(z)}):p("git.aiPrompts.reset",{target:rm(z),mode:w})),E(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||O||"hard"===w&&C!==(null!=l?l:""),onClick:()=>{z&&(u(z,w,"hard"===w?C:void 0),E(!1),S(""))},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"reset-confirm-button",children:p("git.danger.reset")}),(0,r.jsx)("button",{type:"button",onClick:()=>{E(!1),S("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),I&&t&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"revert-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:p("git.danger.revertTitle")}),(0,r.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[p("git.danger.revertBodyPrefix"),(0,r.jsx)("span",{className:"font-mono",children:t.slice(0,7)})]}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"revert-session-warning",children:p("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(m.Sc,{checked:L,onCheckedChange:e=>A(!0===e),"data-testid":"revert-no-commit"}),p("git.danger.revertNoCommit")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,r.jsx)(ra,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{g(p("git.aiPrompts.revert",{commit:rm(t.slice(0,7))})),M(!1),A(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{h(t,L),M(!1),A(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"revert-confirm-button",children:p("git.danger.revert")}),(0,r.jsx)("button",{type:"button",onClick:()=>{M(!1),A(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),R&&x&&(0,r.jsxs)("div",{className:"px-3 py-3 border-t border-danger-border bg-danger-subtle","data-testid":"force-push-confirm",role:"dialog",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-danger-foreground mb-2",children:p("git.danger.forcePushTitle")}),(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:p("git.danger.protectedBranchWarning")}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:p("git.danger.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1 text-xs text-foreground mb-2",children:[(0,r.jsx)(m.Sc,{checked:F,onCheckedChange:e=>D(!0===e),"data-testid":"force-push-with-lease"}),p("git.danger.forceWithLease")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[g&&(0,r.jsx)(ra,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{g(function(e,t){let{branch:n,ahead:a}=t,r=n?rm(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:rm("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(p,{branch:l,ahead:null!=o?o:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(F),P(!1)},className:"px-2 py-1 text-xs rounded bg-danger hover:bg-danger/90 text-white disabled:opacity-50","data-testid":"force-push-confirm-button",children:p("git.danger.forcePush")}),(0,r.jsx)("button",{type:"button",onClick:()=>P(!1),className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]})]})}),rb=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,onDiffSelect:o,isMobile:d=!1,worktree:u,onInsertToMessage:h,className:x=""}=e,f=(0,c.c)("worktree"),{activeTab:g,setActiveTab:p,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:w}=function(){let{value:e,setValue:t,isAvailable:n}=(0,aq.V)({key:aY.activeTab,defaultValue:"status",validate:aX}),{value:a,setValue:r}=(0,aq.V)({key:aY.historyOpen,defaultValue:!0,validate:aQ}),{value:s,setValue:l}=(0,aq.V)({key:aY.advancedOpen,defaultValue:!1,validate:aQ}),o=(0,i.useCallback)(e=>t(e),[t]);return{activeTab:e,setActiveTab:o,historyOpen:a,toggleHistory:(0,i.useCallback)(()=>r(e=>!e),[r]),advancedOpen:s,toggleAdvanced:(0,i.useCallback)(()=>l(e=>!e),[l]),isPersistent:n}}(),j=Object.values(null!=(n=null==u?void 0:u.sessionStatusByCli)?n:{}).some(e=>(null==e?void 0:e.isRunning)===!0),{gitStatus:k,statusLoading:N,statusError:C,fetchStatus:S}=function(e){let[t,n]=(0,i.useState)(null),[a,r]=(0,i.useState)(!0),[s,l]=(0,i.useState)(null),o=(0,i.useCallback)(async()=>{l(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/status"));if(!t.ok){let e=await t.json().catch(()=>({}));l(e.error||"Failed to fetch git status");return}let a=await t.json();n(a)}catch(e){l("Failed to fetch git status")}finally{r(!1)}},[e]);return(0,i.useEffect)(()=>{o()},[o]),{gitStatus:t,statusLoading:a,statusError:s,fetchStatus:o}}(l),{commits:T,selectedCommit:E,changedFiles:I,inlineDiffCommit:M,inlineFiles:L,inlineFilesLoading:A,inlineFilesError:R,selectedFile:P,diffContent:F,isLoading:D,isLoadingFiles:z,isLoadingDiff:O,commitError:B,detailError:_,setDiffContent:W,fetchCommits:H,handleCommitSelect:V,handleFileSelect:U,handleToggleInlineDiff:K,handleInlineDiffFile:$,handleRefresh:q}=function(e,t){let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)([]),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(!1),[f,g]=(0,i.useState)(null),[p,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[w,j]=(0,i.useState)(!0),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(null),L=(0,i.useCallback)(async()=>{j(!0),E(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/log"));if(!t.ok){let e=await t.json();E(e.error||"Failed to fetch commit history");return}let n=await t.json();a(n.commits)}catch(e){E("Failed to fetch commit history")}finally{j(!1)}},[e]),A=(0,i.useCallback)(async t=>{N(!0),o([]),b(null),y(null),M(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json();M(e.error||"Failed to fetch commit details");return}let a=await n.json();o(a.files)}catch(e){M("Failed to fetch commit details")}finally{N(!1)}},[e]),R=(0,i.useCallback)(async(n,a)=>{S(!0),y(null),M(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/diff?commit=").concat(n,"&file=").concat(encodeURIComponent(a)));if(!r.ok){let e=await r.json();M(e.error||"Failed to fetch diff");return}let s=await r.json();y(s.diff),t(s.diff,a)}catch(e){M("Failed to fetch diff")}finally{S(!1)}},[e,t]);(0,i.useEffect)(()=>{L()},[L]);let P=(0,i.useCallback)(e=>{s(e),A(e)},[A]),F=(0,i.useCallback)(e=>{r&&(b(e),R(r,e))},[r,R]),D=(0,i.useCallback)(async t=>{if(c===t){d(null),m([]),g(null);return}d(t),m([]),g(null),x(!0);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));g(e.error||"Failed to fetch commit details");return}let a=await n.json();m(Array.isArray(a.files)?a.files:[])}catch(e){g("Failed to fetch commit details")}finally{x(!1)}},[e,c]),z=(0,i.useCallback)((e,t)=>{s(e),b(t),o(u),R(e,t)},[u,R]),O=(0,i.useCallback)(()=>{s(null),o([]),b(null),y(null),M(null),L()},[L]);return{commits:n,selectedCommit:r,changedFiles:l,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:h,inlineFilesError:f,selectedFile:p,diffContent:v,isLoading:w,isLoadingFiles:k,isLoadingDiff:C,commitError:T,detailError:I,setDiffContent:y,fetchCommits:L,handleCommitSelect:P,handleFileSelect:F,handleToggleInlineDiff:D,handleInlineDiffFile:z,handleRefresh:O}}(l,o),J=(0,i.useCallback)(async()=>{await H(),await S()},[H,S]),{staged:G,stagedLoading:Y,stagedError:X,opBusy:Q,commitMessage:Z,setCommitMessage:ee,amend:et,setAmend:en,committing:ea,changesCommitError:er,fetchStaged:es,handleStage:el,handleUnstage:ei,handleChangesDiff:eo,fetchWorkingDiffText:ec,commit:ed,commitAndPush:eu}=function(e,t){let{onWorkingDiff:n,onCommitted:a}=t,[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!0),[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(""),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),w=(0,i.useCallback)(async()=>{d(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/staged"));if(!t.ok){let e=await t.json().catch(()=>({}));d(e.error||"Failed to fetch changes");return}let n=await t.json();s(n)}catch(e){d("Failed to fetch changes")}finally{o(!1)}},[e]);(0,i.useEffect)(()=>{w()},[w]);let j=(0,i.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/stage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to stage file");return}await w()}catch(e){d("Failed to stage file")}finally{m(!1)}},[e,w]),k=(0,i.useCallback)(async t=>{m(!0),d(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/unstage"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[t]})});if(!n.ok){let e=await n.json().catch(()=>({}));d(e.error||"Failed to unstage file");return}await w()}catch(e){d("Failed to unstage file")}finally{m(!1)}},[e,w]),N=(0,i.useCallback)(async()=>{y(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:h,amend:f})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return x(""),g(!1),await w(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,h,f,w,a]),C=(0,i.useCallback)(async()=>{b(!0);try{await N()}finally{b(!1)}},[N]),S=(0,i.useCallback)(async e=>{b(!0);try{await N()&&await e()}finally{b(!1)}},[N]);return{staged:r,stagedLoading:l,stagedError:c,opBusy:u,commitMessage:h,setCommitMessage:x,amend:f,setAmend:g,committing:p,changesCommitError:v,fetchStaged:w,handleStage:j,handleUnstage:k,handleChangesDiff:(0,i.useCallback)(async(t,a)=>{try{let r=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(a));if(!r.ok)return;let s=await r.json();"string"==typeof s.diff&&n(s.diff,t)}catch(e){}},[e,n]),fetchWorkingDiffText:(0,i.useCallback)(async(t,n)=>{try{let a=await fetch("/api/worktrees/".concat(e,"/git/working-diff?file=").concat(encodeURIComponent(t),"&mode=").concat(n));if(!a.ok)return null;let r=await a.json();return"string"==typeof r.diff?r.diff:null}catch(e){return null}},[e]),commit:C,commitAndPush:S}}(l,{onWorkingDiff:(0,i.useCallback)((e,t)=>{W(e),o(e,t)},[W,o]),onCommitted:J}),{branches:em,branchInclude:eh,branchesLoading:ex,branchesError:ef,branchBusy:eg,branchActionError:ep,fetchBranches:eb,handleBranchIncludeChange:ev,handleBranchesRefresh:ey,handleCheckout:ew,handleBranchCreate:ej,handleBranchDelete:ek}=function(e,t){let{onCheckoutCascade:n}=t,[a,r]=(0,i.useState)([]),[s,l]=(0,i.useState)("local"),[o,c]=(0,i.useState)(!0),[d,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),g=(0,i.useCallback)(async t=>{u(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/branches?include=").concat(t));if(!n.ok){let e=await n.json().catch(()=>({}));u(e.error||"Failed to fetch branches");return}let a=await n.json();r(Array.isArray(a.branches)?a.branches:[])}catch(e){u("Failed to fetch branches")}finally{c(!1)}},[e]);(0,i.useEffect)(()=>{g(s)},[g,s]);let p=(0,i.useCallback)(e=>{l(e)},[]),b=(0,i.useCallback)(()=>{g(s)},[g,s]),v=(0,i.useCallback)(async(t,a)=>{h(!0),f(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t.name,force:a})});if(!r.ok){let e=await r.json().catch(()=>({}));f(e.error||"Failed to checkout branch");return}await Promise.all([n(),g(s)])}catch(e){f("Failed to checkout branch")}finally{h(!1)}},[e,s,n,g]),y=(0,i.useCallback)(async(t,n)=>{h(!0),f(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,from:n})});if(!a.ok){let e=await a.json().catch(()=>({}));f(e.error||"Failed to create branch");return}await g(s)}catch(e){f("Failed to create branch")}finally{h(!1)}},[e,s,g]),w=(0,i.useCallback)(async(t,n)=>{h(!0),f(null);try{let a=await fetch("/api/worktrees/".concat(e,"/git/branch/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,force:n})});if(!a.ok){let e=await a.json().catch(()=>({}));f(e.error||"Failed to delete branch");return}await g(s)}catch(e){f("Failed to delete branch")}finally{h(!1)}},[e,s,g]);return{branches:a,branchInclude:s,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:x,fetchBranches:g,handleBranchIncludeChange:p,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:w}}(l,{onCheckoutCascade:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),H()])},[S,es,H])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eT,stashActionError:eE,stashConflictNotice:eI,fetchStash:eM,handleStashPush:eL,handleStashPop:eA,handleStashApply:eR,handleStashDrop:eP}=function(e,t){let{onStashMutated:n}=t,[a,r]=(0,i.useState)([]),[s,l]=(0,i.useState)(!0),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[x,f]=(0,i.useState)(null),g=(0,i.useCallback)(async()=>{c(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/stash"));if(!t.ok){let e=await t.json().catch(()=>({}));c(e.error||"Failed to fetch stashes");return}let n=await t.json();r(Array.isArray(n.stashes)?n.stashes:[])}catch(e){c("Failed to fetch stashes")}finally{l(!1)}},[e]);(0,i.useEffect)(()=>{g()},[g]);let p=(0,i.useCallback)(async()=>{await Promise.all([g(),n()])},[g,n]),b=(0,i.useCallback)(async(e,t,n)=>{u(!0),h(null),f(null);try{let a=await fetch(e,t),r=await a.json().catch(()=>({}));if(!a.ok)return void h(r.error||n);if(r.conflict){let e=Array.isArray(r.conflictFiles)?r.conflictFiles.join(", "):"",t=r.stashRetained?" (stash retained)":"";f("Stash operation produced conflicts: ".concat(e).concat(t))}await p()}catch(e){h(n)}finally{u(!1)}},[p]),v=(0,i.useCallback)((t,n)=>{b("/api/worktrees/".concat(e,"/git/stash/push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t||void 0,includeUntracked:n})},"Failed to stash changes")},[e,b]),y=(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/pop"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to pop stash")},[e,b]);return{stashes:a,stashLoading:s,stashError:o,stashBusy:d,stashActionError:m,stashConflictNotice:x,fetchStash:g,handleStashPush:v,handleStashPop:y,handleStashApply:(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({index:t})},"Failed to apply stash")},[e,b]),handleStashDrop:(0,i.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/").concat(t),{method:"DELETE"},"Failed to drop stash")},[e,b])}}(l,{onStashMutated:(0,i.useCallback)(async()=>{await Promise.all([S(),es()])},[S,es])}),{dangerBusy:eF,dangerActionError:eD,dangerConflictNotice:ez,handleReset:eO,handleRevert:eB}=function(e,t){let{onHeadMoved:n}=t,[a,r]=(0,i.useState)(!1),[s,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(null);return{dangerBusy:a,dangerActionError:s,dangerConflictNotice:o,handleReset:(0,i.useCallback)(async(t,a,s)=>{r(!0),l(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/reset"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:t,mode:a,confirmBranch:s})});if(!r.ok){let e=await r.json().catch(()=>({}));l(e.error||"Failed to reset");return}await n()}catch(e){l("Failed to reset")}finally{r(!1)}},[e,n]),handleRevert:(0,i.useCallback)(async(t,a)=>{r(!0),l(null),c(null);try{let r=await fetch("/api/worktrees/".concat(e,"/git/revert"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commitHash:t,noCommit:a})});if(!r.ok){let e=await r.json().catch(()=>({}));l(e.error||"Failed to revert");return}let s=await r.json().catch(()=>({}));if(s.conflict){let e=Array.isArray(s.conflictFiles)?s.conflictFiles.join(", "):"";c("Revert produced conflicts: ".concat(e))}await n()}catch(e){l("Failed to revert")}finally{r(!1)}},[e,n])}}(l,{onHeadMoved:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),eb(eh),H()])},[S,es,eb,eh,H])}),{operation:e_,progressState:eW,error:eH,errorReason:eV,conflict:eU,conflictFiles:eK,runFetch:e$,runPull:eq,runPush:eJ,abort:eG}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onCascade:n}=t,[a,r]=(0,i.useState)(null),[s,l]=(0,i.useState)("idle"),[o,c]=(0,i.useState)(null),[d,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,f]=(0,i.useState)([]),g=(0,i.useRef)(null),p=(0,i.useRef)(n);(0,i.useEffect)(()=>{p.current=n},[n]),(0,i.useEffect)(()=>()=>{var e;null==(e=g.current)||e.abort()},[]);let b=(0,i.useCallback)(async(t,n,a)=>{var s,i,o;c(null),u(null),h(!1),f([]),r(t),l("running");let d=new AbortController;g.current=d;try{let r=await fetch("/api/worktrees/".concat(e,"/git/").concat(n),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:d.signal});if(!r.ok){let e=await r.json().catch(()=>({}));u((s=null==e?void 0:e.reason,"auth_failed"===s?"auth_failed":"protected_branch"===s?"protected_branch":null)),c((i=null==e?void 0:e.error,"string"==typeof i&&i.length>0?i:null)),l("error");return}let o=await r.json().catch(()=>({success:!0}));"pull"===t&&(null==o?void 0:o.conflict)&&(h(!0),f(Array.isArray(o.conflictFiles)?o.conflictFiles:[])),l("idle")}catch(e){e instanceof Error&&"AbortError"===e.name?l("idle"):(c(null),u(null),l("error"))}finally{r(null),g.current=null,null==(o=p.current)||o.call(p,t)}},[e]),v=(0,i.useCallback)(e=>{let t={prune:!0===e.prune};return void 0!==e.remote&&(t.remote=e.remote),b("fetch","fetch",t)},[b]),y=(0,i.useCallback)(e=>{let t={rebase:!0===e.rebase,ffOnly:!0===e.ffOnly};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("pull","pull",t)},[b]);return{operation:a,progressState:s,error:o,errorReason:d,conflict:m,conflictFiles:x,runFetch:v,runPull:y,runPush:(0,i.useCallback)(e=>{let t={force:!0===e.force,forceWithLease:!0===e.forceWithLease,setUpstream:!0===e.setUpstream};return void 0!==e.remote&&(t.remote=e.remote),void 0!==e.branch&&(t.branch=e.branch),b("push","push",t)},[b]),abort:(0,i.useCallback)(()=>{var e;null==(e=g.current)||e.abort()},[])}}(l,{onCascade:(0,i.useCallback)(e=>{S(),eb(eh),"pull"===e&&(es(),H())},[S,eb,eh,es,H])}),eY="auth_failed"===eV?f("git.network.authFailedGuidance"):"protected_branch"===eV?f("git.danger.protectedBranchWarning"):eH,eX="running"===eW&&("push"===e_||"pull"===e_),eQ=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,i.useCallback)(()=>{e$({})},[e$]),e0=(0,i.useCallback)(()=>eu(()=>eJ({setUpstream:!eQ})),[eu,eJ,eQ]);nE({intervalMs:5e3,enabled:"running"!==eW,onPoll:S});let e1=(0,i.useMemo)(()=>({isMobile:d,onDiffSelect:o,onInsertToMessage:h}),[d,o,h]),e2=(0,r.jsx)(ri,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eW}),e4=(0,r.jsx)(ro,{progressState:eW,operation:e_,error:eY,conflict:eU,conflictFiles:eK,hasUpstream:eQ,onPull:()=>eq({}),onPush:()=>eJ({setUpstream:!eQ}),onAbort:eG,extraActions:(0,r.jsx)(a1,{branches:em,busy:eg||eX,actionError:ep,hasRunningSession:j,isMobile:d,onCheckout:ew})}),e5=(0,r.jsx)(rd,{staged:G,loading:Y,error:X,busy:Q||eX,commitMessage:Z,amend:et,committing:ea,commitError:er,onRefresh:es,onDiff:eo,onPreview:ec,onStage:el,onUnstage:ei,onCommitMessageChange:ee,onAmendChange:en,onCommit:ed,onCommitAndPush:e0}),e3=(0,r.jsx)(ru,{commits:T,isLoading:D,commitError:B,commitListOpen:b,onToggleCommitList:v,onRefresh:q,selectedCommit:E,onCommitSelect:V,inlineDiffCommit:M,inlineFiles:L,inlineFilesLoading:A,inlineFilesError:R,onToggleInlineDiff:K,onInlineDiffFile:$,changedFiles:I,isLoadingFiles:z,detailError:_,selectedFile:P,onFileSelect:U,diffContent:F,isLoadingDiff:O}),e6=(0,r.jsxs)(a2,{open:y,onToggle:w,children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1.5 px-3 py-2 border-b border-border","data-testid":"git-advanced-fetch",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:f("git.remote")}),(0,r.jsx)("div",{children:(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>e$({}),disabled:"running"===eW,className:"px-2 py-1 text-xs rounded border border-input text-foreground hover:bg-muted disabled:opacity-50","data-testid":"git-fetch-button",children:f("git.network.fetch")})})]}),(0,r.jsx)(rx,{branches:em,include:eh,loading:ex,error:ef,busy:eg||eX,actionError:ep,onIncludeChange:ev,onRefresh:ey,onCreate:ej,onDelete:ek}),(0,r.jsx)(rf,{stashes:eN,loading:eC,error:eS,busy:eT||eX,actionError:eE,conflictNotice:eI,hasRunningSession:j,onRefresh:eM,onPush:eL,onPop:eA,onApply:eR,onDrop:eP}),(0,r.jsx)(rp,{selectedCommit:E,busy:eF||eX,actionError:eD,conflictNotice:ez,currentBranch:null!=(a=null==k?void 0:k.currentBranch)?a:null,aheadCount:null!=(s=null==k||null==(t=k.aheadBehind)?void 0:t.ahead)?s:null,hasRunningSession:j,onReset:eO,onRevert:eB,onForcePush:e=>eJ(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(a5,{value:e1,children:(0,r.jsx)(re,{activeTab:g,onTabChange:p,className:x,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),rv=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,onWorktreeUpdate:a}=e,[s,l]=(0,i.useState)(!1),o=(0,c.c)("worktree"),d=(0,i.useRef)(null==n?void 0:n.id),u=(0,i.useRef)(!1),m=rk(n,a,null==n?void 0:n.id,()=>{let e=(null==n?void 0:n.id)!==d.current;return d.current=null==n?void 0:n.id,e&&!u.current});return(u.current=m.isEditing,n)?(0,r.jsx)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:(0,r.jsx)(rN,{worktreeId:t,worktree:n,cardClassName:"bg-surface rounded-lg border border-border p-4",descriptionEditor:m,showLogs:s,onToggleLogs:()=>l(!s),onWorktreeUpdate:a})}):(0,r.jsx)("div",{className:"text-muted-foreground text-center py-8",children:o("detail.loadingInfo")})}),ry=(0,i.memo)(function(e){let{activeTab:t,worktreeId:n,worktree:a,messages:s,cliToolId:l,instanceId:i,onFilePathClick:o,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:h,onRename:x,onDelete:f,onUpload:g,onMove:p,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:w,selectedAgents:j,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:T,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:L,disableAutoFollow:A,historySubTab:R,onHistorySubTabChange:P,onDiffSelect:F,onInsertToMessage:D,showArchived:z,onShowArchivedChange:O,historyDisplayLimit:B,onHistoryDisplayLimitChange:_,historyUserOnly:W,onHistoryUserOnlyChange:H,useInstanceManagement:V,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q}=e,J=(0,c.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(S,{componentName:"TerminalDisplay",children:(0,r.jsx)(tN,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:A})});case"history":return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex border-b border-border shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:()=>P("message"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("message"===R?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"),children:J("detail.subTabMessage")}),(0,r.jsx)("button",{type:"button",onClick:()=>P("git"),className:"flex-1 min-h-[44px] px-3 py-1.5 text-xs font-medium transition-colors touch-manipulation ".concat("git"===R?"text-accent-600 dark:text-accent-400 border-b-2 border-accent-600 dark:border-accent-400 bg-accent-50 dark:bg-accent-900/30":"text-muted-foreground hover:text-foreground"),children:J("detail.subTabGit")})]}),"message"===R?(0,r.jsx)(S,{componentName:"HistoryPane",children:(0,r.jsx)(nr,{messages:s,worktreeId:n,onFilePathClick:o,className:"flex-1 min-h-0",showToast:w,onInsertToMessage:D,showArchived:z,onShowArchivedChange:O,historyDisplayLimit:B,onHistoryDisplayLimitChange:_,historyUserOnly:W,onHistoryUserOnlyChange:H})}):(0,r.jsx)(S,{componentName:"GitPane",children:(0,r.jsx)(rb,{worktreeId:n,onDiffSelect:F,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:D,className:"flex-1 min-h-0"})})]});case"files":var G;return(0,r.jsx)(S,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(nD,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(nA,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:h,onRename:x,onDelete:f,onUpload:g,onMove:p,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(G=y.results)?void 0:G.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(S,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(a$,{worktreeId:n,className:"h-full",selectedAgents:j,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:T,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:L,onInsertToMessage:D,useInstanceManagement:V,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q})});case"info":return(0,r.jsx)(rv,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),rw="v".concat("0.19.0"),rj=[{value:null,labelKey:"worktreeStatus.notSet"},{value:"ready",labelKey:"worktreeStatus.ready"},{value:"in_progress",labelKey:"worktreeStatus.inProgress"},{value:"in_review",labelKey:"worktreeStatus.inReview"},{value:"done",labelKey:"worktreeStatus.done"}];function rk(e,t,n,a){let[r,s]=(0,i.useState)(!1),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a()&&e&&(o(e.description||""),s(!1))},[n,e]);let u=(0,i.useCallback)(async()=>{if(e){d(!0);try{let n=await _.y.updateDescription(e.id,l);t(n),s(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,l,t]),m=(0,i.useCallback)(()=>{o((null==e?void 0:e.description)||""),s(!1)},[e]);return{isEditing:r,text:l,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,i.useCallback)(()=>{s(!0)},[])}}let rN=(0,i.memo)(function(e){var t,n;let{worktreeId:a,worktree:s,cardClassName:l,descriptionEditor:o,showLogs:d,onToggleLogs:u,onWorktreeUpdate:h}=e,{isEditing:x,text:f,setText:g,isSaving:p,handleSave:b,handleCancel:v,startEditing:y}=o,w=(0,c.c)("worktree"),j=(0,c.c)("common"),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),T=(0,i.useRef)(void 0),E=(0,i.useRef)(void 0);(0,i.useEffect)(()=>()=>{T.current&&clearTimeout(T.current),E.current&&clearTimeout(E.current)},[]);let I=(0,i.useCallback)(async()=>{try{await (0,ey.l)(s.path),N(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>N(!1),ea.pX)}catch(e){}},[s.path]),M=(0,i.useCallback)(async()=>{try{await (0,ey.l)(s.repositoryPath),S(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>S(!1),ea.pX)}catch(e){}},[s.repositoryPath]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:w("detail.worktree")}),(0,r.jsx)("p",{className:"text-lg font-semibold text-foreground",children:s.name})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:w("detail.repository")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:M,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":w("detail.copyRepositoryPath"),title:C?w("detail.copied"):w("detail.copyRepositoryPath"),children:C?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-base text-foreground",children:null!=(t=s.repositoryDisplayName)?t:s.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:s.repositoryPath})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:w("detail.path")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:I,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":w("detail.copyWorktreePath"),title:k?w("detail.copied"):w("detail.copyPath"),children:k?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:s.path})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:w("detail.status")}),(0,r.jsx)("select",{value:null!=(n=s.status)?n:"",onChange:async e=>{let t=e.target.value;try{let e=await fetch("/api/worktrees/".concat(s.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===t?null:t})});if(e.ok&&h){let t=await e.json();h(t)}}catch(e){}},className:"text-sm px-3 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent w-full","data-testid":"mobile-status-dropdown","aria-label":w("detail.worktreeStatusLabel"),children:rj.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:w(e.labelKey)},e.labelKey)})})]}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:w("detail.description")}),!x&&(0,r.jsx)("button",{type:"button",onClick:y,className:"text-sm text-accent-600 hover:text-accent-800 dark:text-accent-400 dark:hover:text-accent-300",children:w("actions.edit")})]}),x?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>g(e.target.value),placeholder:w("detail.addNotesPlaceholder"),className:"w-full min-h-[150px] p-3 border border-input dark:bg-surface dark:text-foreground rounded-lg resize-y focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:b,disabled:p,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:p?w("actions.saving"):w("actions.save")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:v,disabled:p,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:j("cancel")})]})]}):(0,r.jsx)("div",{className:"min-h-[50px]",children:s.description?(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.description}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:w("detail.noDescription")})})]}),s.link&&(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:w("detail.link")}),(0,r.jsx)("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:s.link})]}),s.updatedAt&&(0,r.jsxs)("div",{className:l,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:w("detail.lastUpdated")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:new Date(s.updatedAt).toLocaleString()})]}),(0,r.jsx)(e0,{version:rw,className:l}),(0,r.jsx)(e8,{className:l}),(0,r.jsxs)("div",{className:l,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:w("detail.logs")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"text-sm text-accent-600 hover:text-accent-800",children:d?w("detail.hide"):w("detail.show")})]}),d&&(0,r.jsx)(eY,{worktreeId:a})]})]})}),rC=(0,i.memo)(function(e){var t,n,a,s;let{worktreeName:l,repositoryName:o,description:d,status:u,gitStatus:f,onBackClick:g,onInfoClick:p,hasUpdate:b,worktreeStatus:v,onWorktreeStatusChange:y,sessionStatusByCli:w,sessionStatusByInstance:j,instances:N,activeInstanceId:C,onActiveInstanceChange:S,onAgentDragStart:T,onAgentDragEnd:E,onKillSession:I}=e,M=(0,c.c)("worktree"),L=(0,c.c)("common"),A=eK.sb[u],R=A?M(A):void 0,[P,F]=(0,i.useState)(null),D=null==N?void 0:N.find(e=>e.id===C),z=!!C&&null!=(s=null!=(a=null==j||null==(t=j[C])?void 0:t.isRunning)?a:D?null==w||null==(n=w[D.cliTool])?void 0:n.isRunning:void 0)&&s,O=(0,i.useCallback)((e,t)=>{e.dataTransfer.setData(tn,t),e.dataTransfer.effectAllowed="move",F(t),null==T||T(t)},[T]),B=(0,i.useCallback)(()=>{F(null),null==E||E()},[E]),_=d?(0,x.W5)(d,50):null;return(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-surface border-b border-border",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":M("detail.goBack"),"data-testid":"worktree-back-button",children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-4 0a1 1 0 01-1-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 01-1 1h-2z"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:M("detail.home")})]}),(0,r.jsx)("div",{className:"w-px h-6 bg-border","aria-hidden":"true"}),(0,r.jsx)(h.m,{"data-testid":"desktop-status-indicator",status:u,size:"lg",label:R}),(0,r.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:l}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"truncate max-w-[200px]",children:o}),f&&"(unknown)"!==f.currentBranch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"/"}),(0,r.jsx)("span",{className:"truncate max-w-[150px] font-mono",title:f.currentBranch,"data-testid":"desktop-branch-name",children:(0,x.W5)(f.currentBranch,30)}),f.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:M("git.uncommittedChanges"),children:"*"})]}),_&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,r.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:d,children:_})]})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[N&&N.length>0&&(()=>{var e,t,n,a;let s=(0,eJ.Uw)(N.map(e=>{var t;return{item:e,status:(0,e9.kA)(null!=(t=null==j?void 0:j[e.id])?t:null==w?void 0:w[e.cliTool]),isActive:e.id===C}}),4),l=s.filter(e=>"overflow"===e.slot),i=null!=(a=null!=(n=null==(e=l.find(e=>"running"===e.status||"generating"===e.status))?void 0:e.status)?n:null==(t=l.find(e=>"waiting"===e.status))?void 0:t.status)?a:null;return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[s.map(e=>{if("overflow"===e.slot)return null;let t=e.item,n=M("detail.statusPill",{label:(0,te.sw)(t),status:L("status.".concat(e.status))}),a=e.isActive,s={draggable:!0,onDragStart:e=>O(e,t.id),onDragEnd:B},l=P===t.id?" opacity-50 cursor-grabbing":"";return"pill"===e.slot?(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-".concat(t.id),onClick:()=>null==S?void 0:S(t.id),...s,"aria-label":n,"aria-pressed":a,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(a?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(l),children:[(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id):(0,r.jsx)(e$.m_,{content:n,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(t.id),onClick:()=>null==S?void 0:S(t.id),...s,"aria-label":n,"aria-pressed":a,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(a?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(l),children:(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0})})},t.id)}),l.length>0&&(0,r.jsxs)(eq.rI,{children:[(0,r.jsx)(eq.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":M("agentStatus.moreAgents",{count:l.length}),className:"flex items-center gap-1 px-2 py-1 rounded text-xs tabular-nums text-muted-foreground hover:bg-muted transition-colors",children:[i&&(0,r.jsx)(h.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(eq.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=M("detail.statusPill",{label:(0,te.sw)(t),status:L("status.".concat(e.status))});return(0,r.jsxs)(eq._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==S?void 0:S(t.id),children:[(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]})]})})(),I&&z&&(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:I,className:"flex items-center gap-1 px-2 py-1.5 text-xs font-medium rounded-lg text-danger-foreground hover:bg-danger-subtle transition-colors flex-shrink-0","aria-label":M("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),L("end")]}),y&&(0,r.jsx)("select",{value:null!=v?v:"",onChange:e=>{let t=e.target.value;y(""===t?null:t)},onClick:e=>e.stopPropagation(),className:"text-xs px-2 py-1.5 rounded-lg border border-input bg-surface text-foreground focus:ring-2 focus:ring-ring focus:border-transparent cursor-pointer","data-testid":"desktop-status-dropdown","aria-label":M("detail.worktreeStatusLabel"),children:rj.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:M(e.labelKey)},e.labelKey)})}),(0,r.jsx)(tr.g,{}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:p,className:"relative flex items-center gap-1.5 px-3 py-1.5 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":M("detail.viewInfo"),children:[(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("span",{className:"text-sm font-medium",children:M("detail.info")}),b&&(0,r.jsx)(k,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":M("tabs.updateAvailable")})]})]})]})}),rS=(0,i.memo)(function(e){let{worktreeId:t,worktree:n,isOpen:a,onClose:s,onWorktreeUpdate:l}=e,[o,d]=(0,i.useState)(!1),u=(0,c.c)("worktree"),m=(0,i.useRef)(a),h=rk(n,l,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(e7.a,{isOpen:a,onClose:s,title:u("detail.infoModalTitle"),size:"md",children:(0,r.jsx)("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto","data-testid":"worktree-info-modal",children:(0,r.jsx)(rN,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:h,showLogs:o,onToggleLogs:()=>d(!o),onWorktreeUpdate:l})})}):null}),rT=(0,i.memo)(function(){let e=(0,c.c)("worktree");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"status","aria-live":"polite",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)(m.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:e("detail.loading")})]})})}),rE=(0,i.memo)(function(e){let{message:t,onRetry:n}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common");return(0,r.jsx)("div",{className:"flex items-center justify-center h-full min-h-[200px]",role:"alert","aria-live":"assertive",children:(0,r.jsxs)("div",{className:"text-center p-6 bg-danger-subtle rounded-lg border border-danger-border max-w-md",children:[(0,r.jsx)("svg",{className:"mx-auto h-12 w-12 text-danger-foreground/70 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-danger-foreground font-medium",children:a("detail.errorLoading")}),(0,r.jsx)("p",{className:"text-danger-foreground/80 text-sm mt-2",children:t}),n&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:n,className:"mt-4 px-4 py-2 bg-danger-foreground text-danger-subtle rounded-lg hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-danger focus:ring-offset-2 ring-offset-background",children:s("retry")})]})})}),rI=(0,i.memo)(function(e){let{activityPane:t,rightPane:n,activityPaneWidth:a=18,minPaneWidth:s=10,maxPaneWidth:l=60,onActivityPaneResize:o,className:d=""}=e,u=(0,i.useRef)(null),m=(0,c.c)("worktree"),[h,x]=(0,i.useState)(a),f=o?a:h,g=(0,i.useCallback)(e=>{let t=u.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let r=Math.min(l,Math.max(s,(o?a:h)+e/n*100));o?o(r):x(r)},[a,h,s,l,o]),p=(0,i.useMemo)(()=>"flex h-full min-h-0 ".concat(d).trim(),[d]);return(0,r.jsx)("div",{ref:u,className:"h-full",children:(0,r.jsxs)("div",{"data-testid":"desktop-layout",role:"main",className:p,children:[null!==t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:"worktree-activity-pane","data-testid":"activity-pane-slot","aria-label":m("desktopLayout.activityPane"),style:{width:"".concat(f,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(S,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(t2.f,{onResize:g,orientation:"horizontal",ariaValueNow:f})]}),(0,r.jsx)("div",{id:"worktree-right-pane","data-testid":"right-pane-slot","aria-label":m("desktopLayout.terminalPane"),className:"flex-grow overflow-hidden min-w-0",children:(0,r.jsx)(S,{componentName:"TerminalPane",children:n})})]})})});var rM=n(9540),rL=n(92001),rA=n(39332),rR=n(11047),rP=n(16485),rF=n(78192),rD=n(39324),rz=n(80298);let rO=[{id:"files",labelKey:"activityBar.files",icon:rL.A},{id:"git",labelKey:"activityBar.git",icon:rA.A},{id:"notes",labelKey:"activityBar.notes",icon:rR.A},{id:"schedules",labelKey:"activityBar.schedules",icon:rP.A},{id:"agent",labelKey:"activityBar.agent",icon:rF.A},{id:"timer",labelKey:"activityBar.timer",icon:rD.A},{id:"todo",labelKey:"activityBar.todo",icon:rz.A},{id:"skills",labelKey:"activityBar.skills",icon:nG.A}],rB=new Set(rO.map(e=>e.id)),r_="files",rW="__closed__";function rH(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var rV=n(32916);let rU=(0,i.memo)(function(e){let{active:t,onToggle:n,className:a=""}=e,s=(0,c.c)("worktree"),l=(0,i.useRef)([]),{isOpen:o,toggle:d}=(0,rV.VF)(),u=(0,i.useCallback)((e,t,a)=>{var r,s,i,o;if("Enter"===e.key||" "===e.key){e.preventDefault(),n(a);return}if("ArrowDown"===e.key){e.preventDefault();let n=(t+1)%rO.length;null==(r=l.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+rO.length)%rO.length;null==(s=l.current[n])||s.focus();return}if("Home"===e.key){e.preventDefault(),null==(i=l.current[0])||i.focus();return}if("End"===e.key){e.preventDefault(),null==(o=l.current[rO.length-1])||o.focus();return}},[n]);return(0,r.jsxs)("div",{"data-testid":"activity-bar",className:"flex flex-col items-stretch w-12 flex-shrink-0 bg-muted border-r border-border ".concat(a).trim(),children:[(0,r.jsx)(e$.m_,{content:s("activityBar.toggleSidebar"),placement:"right",children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:d,"aria-label":s("activityBar.toggleSidebar"),"aria-expanded":o,className:"flex items-center justify-center h-12 w-12 text-muted-foreground transition-colors hover:text-surface-foreground hover:bg-muted-foreground/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,r.jsx)(rM.A,{size:20,"aria-hidden":"true"})})}),(0,r.jsx)("div",{className:"mx-2 my-1 border-b border-border","aria-hidden":"true"}),(0,r.jsx)("div",{id:"worktree-activity-bar",role:"tablist","aria-orientation":"vertical","aria-label":s("activityBar.label"),className:"flex flex-col items-stretch",children:rO.map((e,a)=>{let i=e.icon,o=t===e.id,c=s(e.labelKey);return(0,r.jsx)(e$.m_,{content:c,placement:"right",children:(0,r.jsx)("button",{ref:e=>{l.current[a]=e},type:"button",role:"tab","aria-selected":o,"aria-label":c,"aria-controls":"worktree-activity-pane",tabIndex:o||null===t&&0===a?0:-1,onClick:()=>n(e.id),onKeyDown:t=>u(t,a,e.id),"data-testid":"activity-bar-button-".concat(e.id),className:"group flex items-center justify-center h-12 w-12 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-inset",children:(0,r.jsx)("span",{"aria-hidden":"true",className:"flex items-center justify-center h-9 w-9 rounded-md transition-colors ".concat(o?"bg-accent-500/10 text-accent-600 dark:text-accent-400":"text-muted-foreground group-hover:text-surface-foreground group-hover:bg-muted-foreground/10"),children:(0,r.jsx)(i,{size:20,"aria-hidden":"true"})})})},e.id)})})]})}),rK="worktree-activity-pane",r$={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane"},rq=(0,i.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:rK,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=r$[t];return(0,r.jsx)("div",{id:rK,"data-testid":"activity-pane","data-active":t,role:"tabpanel","aria-labelledby":"activity-bar-button-".concat(t),className:"h-full flex flex-col min-h-0 ".concat(a).trim(),children:(0,r.jsx)(S,{componentName:l,children:null!=s?s:null})})}),rJ=(0,i.memo)(function(e){let{inputRef:t,searchQuery:n,onQueryChange:a,matchCount:s,currentIdx:l,onNextMatch:i,onPrevMatch:o,onClose:d}=e,u=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted border-b border-input flex-shrink-0",children:[(0,r.jsx)("input",{ref:t,type:"text",value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{"Escape"===e.key&&d(),"Enter"===e.key&&(e.shiftKey?o():i())},placeholder:u("fileSearch.placeholder"),className:"flex-1 min-w-0 px-2 py-0.5 text-sm bg-surface dark:text-foreground border border-input rounded outline-none focus:ring-1 focus:ring-ring",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground min-w-[3rem] text-right",children:s>0?"".concat(l+1,"/").concat(s):"0/0"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:o,disabled:0===s,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":u("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:i,disabled:0===s,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white disabled:text-muted-foreground/50","aria-label":u("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:d,className:"min-w-[32px] min-h-[32px] flex items-center justify-center text-muted-foreground hover:text-foreground dark:hover:text-white","aria-label":u("fileSearch.close"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})}),rG=[{extension:".png",maxFileSize:0x1400000,allowedMimeTypes:["image/png"],magicBytes:[{bytes:[137,80,78,71,13,10,26,10]}]},{extension:".jpg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".jpeg",maxFileSize:0x1400000,allowedMimeTypes:["image/jpeg"],magicBytes:[{bytes:[255,216,255]}]},{extension:".gif",maxFileSize:0x1400000,allowedMimeTypes:["image/gif"],magicBytes:[{bytes:[71,73,70,56,55,97]},{bytes:[71,73,70,56,57,97]}]},{extension:".webp",maxFileSize:0x1400000,allowedMimeTypes:["image/webp"],magicBytes:[{bytes:[82,73,70,70],offset:0}]},{extension:".mp4",maxFileSize:0x6400000,allowedMimeTypes:["video/mp4"],magicBytes:[{bytes:[102,116,121,112],offset:4}]},{extension:".txt",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".log",maxFileSize:0x1400000,allowedMimeTypes:["text/plain"]},{extension:".md",maxFileSize:0x1400000,allowedMimeTypes:["text/markdown","text/plain"]},{extension:".csv",maxFileSize:0x1400000,allowedMimeTypes:["text/csv"]},{extension:".json",maxFileSize:0x1400000,allowedMimeTypes:["application/json"]},{extension:".yaml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]},{extension:".yml",maxFileSize:0x1400000,allowedMimeTypes:["text/yaml","application/x-yaml"]}],rY=rG.map(e=>e.extension),rX=[".md",".html",".htm",".yaml",".yml"];ev.j6,ev.j6;var rQ=n(40051);function rZ(){return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,r.jsx)(u.y,{size:"xl",variant:"accent"})})}let r0=(0,o.default)(()=>n.e(530).then(n.bind(n,530)).then(e=>({default:e.HtmlPreview})),{loadableGenerated:{webpack:()=>[530]},ssr:!1,loading:()=>(0,r.jsx)(rZ,{})}),r1=(0,o.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(rZ,{})}),r2=(0,o.default)(()=>n.e(9263).then(n.bind(n,79263)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[79263]},ssr:!1,loading:()=>(0,r.jsx)(rZ,{})}),r4=/^---\s*\nmarp:\s*true/;function r5(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(u.y,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:e("fileViewer.loading")})]})}function r3(e){let{error:t}=e;return(0,r.jsx)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4 m-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-sm text-danger-foreground",children:t})]})})}function r6(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),x=(0,i.useRef)(null),f=(0,i.useRef)(null);(0,i.useEffect)(()=>()=>{x.current&&clearTimeout(x.current),f.current&&clearTimeout(f.current)},[]);let g=async()=>{try{await (0,ey.l)(t),u(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>u(!1),ea.pX)}catch(e){}},p=async()=>{if(s)try{await (0,ey.l)(s),h(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h(!1),ea.pX)}catch(e){}};return(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,r.jsx)("button",{type:"button",onClick:g,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFilePath"),title:o("actions.copyPath"),children:d?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ef.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",title:t,children:t})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l&&(0,r.jsx)("button",{type:"button",onClick:l,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.searchInFile"),title:o("actions.search"),children:(0,r.jsx)(z.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:p,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o("actions.copyFileContent"),title:o("actions.copyContent"),children:m?(0,r.jsx)(eh.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ex.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("button",{type:"button",onClick:a,className:"flex-shrink-0 p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":o(n?"actions.minimize":"actions.maximize"),title:o(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(ej.A,{className:"w-4 h-4"}):(0,r.jsx)(ek.A,{className:"w-4 h-4"})})]})]})}function r8(e){var t;let{content:n,extension:a,searchMatches:s,searchCurrentIdx:l,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,h=(0,i.useRef)(null),x=(0,i.useMemo)(()=>n.split("\n"),[n]),f=Math.max(1,null!=c?c:1),g=x.length,p=Math.max(null!=o?o:g,g),b=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{b.current.clear()},[n,a]);let v=(0,i.useCallback)(e=>{var t;let n=Math.floor(e/500),r=b.current,s=r.get(n);if(!s){let e=500*n,t=Math.min(e+500,x.length),l=x.slice(e,t).join("\n"),i="";try{i=eD.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=eD.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[x,a]),y=(0,i.useMemo)(()=>new Set(null!=s?s:[]),[s]),w=(null!=(t=null==s?void 0:s.length)?t:0)>0?s[null!=l?l:0]:-1,j=(0,tC.Te)({count:p,getScrollElement:()=>h.current,estimateSize:()=>24,overscan:100});(0,i.useEffect)(()=>{if(!s||0===s.length)return;let e=s[null!=l?l:0];if(!Number.isFinite(e))return;let t=Math.max(0,Math.min(p-1,e-1));j.scrollToIndex(t,{align:"center"})},[l,s,j,p]);let k=j.getVirtualItems();return!function(e){let{virtualItems:t,worktreeId:n,filePath:a,onLineRangeFetched:r,loadedStart:s,loadedLineCount:l}=e,o=(0,i.useRef)(new Set);(0,i.useEffect)(()=>{if(!n||!a||!r||0===t.length)return;let e=t[0].index+1,i=t[t.length-1].index+1,c=s+l-1;if(e>=s&&i<=c)return;let d=Math.max(1,500*Math.floor((e-1)/500)+1),u=d+500-1;o.current.has(d)||(o.current.add(d),fetch("/api/worktrees/".concat(n,"/files/").concat((0,eT.o)(a),"?startLine=").concat(d,"&endLine=").concat(u)).then(async e=>e.ok?e.json():null).then(e=>{o.current.delete(d),e&&!0===e.success&&r({content:e.content,range:e.range,totalLines:e.totalLines,totalBytes:e.totalBytes})}).catch(()=>{o.current.delete(d)}))},[t,n,a,r,s,l])}({virtualItems:k,worktreeId:d,filePath:u,onLineRangeFetched:m,loadedStart:f,loadedLineCount:g}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:h,"data-testid":"file-content-code",children:(0,r.jsx)("div",{style:{height:j.getTotalSize(),width:"100%",position:"relative"},children:k.map(e=>{let t=e.index+1,n=t-f,a=n>=0&&n<g,s=t===w,l=y.has(t),i=a?v(n):"";return(0,r.jsxs)("div",{"data-line":t,"data-index":e.index,ref:j.measureElement,className:"absolute left-0 right-0 flex font-mono text-sm ".concat(s?"bg-warning/30":l?"bg-warning/15":""),style:{top:0,transform:"translateY(".concat(e.start,"px)"),height:"".concat(24,"px"),lineHeight:"".concat(24,"px")},children:[(0,r.jsx)("div",{className:"px-3 text-right select-none border-r border-border bg-muted dark:bg-muted/50 whitespace-nowrap ".concat(s||l?"text-warning-foreground":"text-muted-foreground"),style:{minWidth:"4rem"},children:t}),(0,r.jsx)("div",{className:"px-4 text-foreground flex-1 min-w-0 overflow-hidden",children:a?(0,r.jsx)("code",{className:"hljs",style:{padding:0,background:"transparent",whiteSpace:"pre"},dangerouslySetInnerHTML:{__html:i}}):(0,r.jsx)(rQ.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function r7(e){let{slides:t,fileName:n}=e,a=(0,c.c)("worktree"),[s,l]=(0,i.useState)(0);return 0===t.length?(0,r.jsx)("div",{className:"p-4 text-muted-foreground",children:a("fileViewer.noSlides",{fileName:n})}):(0,r.jsxs)("div",{className:"h-full flex flex-col","data-testid":"marp-preview",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border bg-muted",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{l(e=>Math.max(0,e-1))},disabled:0===s,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[s+1," / ",t.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>{l(e=>Math.min(t.length-1,e+1))},disabled:s===t.length-1,className:"px-3 py-1 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors",children:a("actions.next")})]}),(0,r.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,r.jsx)("iframe",{srcDoc:t[s],sandbox:"",title:a("fileViewer.slideTitle",{name:n,number:s+1}),className:"w-full h-full border-0"})})]})}function r9(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:s,contentText:l,onFileSaved:o,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:h}=e,x=(0,c.c)("worktree"),[f,g]=(0,i.useState)("slides");return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-1 border-b border-border bg-muted",children:[(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>g("slides"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("slides"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:x("fileViewer.slides")}),(0,r.jsx)("button",{type:"button",onClick:()=>g("editor"),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat("editor"===f?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:x("fileViewer.editor")})]}),(0,r.jsx)(r6,{filePath:s,isMaximized:d,onToggleMaximize:u,copyableContent:l})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===f?(0,r.jsx)(r7,{slides:t,fileName:n}):(0,r.jsx)(r2,{worktreeId:a,filePath:s,onSave:o,initialViewMode:"split",onDirtyChange:m,onOpenFile:h})})]})}function se(e){let{children:t,isMaximized:n,onToggle:a,filePath:s}=e;return n?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eS.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(r6,{filePath:s,isMaximized:n,onToggleMaximize:a}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:t})]}):(0,r.jsx)(r.Fragment,{children:t})}function st(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=eF(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(r6,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(rJ,{inputRef:d.searchInputRef,searchQuery:d.searchQuery,onQueryChange:d.setSearchQuery,matchCount:d.searchMatches.length,currentIdx:d.searchCurrentIdx,onNextMatch:d.nextMatch,onPrevMatch:d.prevMatch,onClose:d.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:d.searchOpen&&d.searchQuery.length>=2?(0,r.jsx)(r8,{content:n.content,extension:"md",searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(r2,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function sn(e){var t,n;let{tab:a,content:s,worktreeId:l,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=eF(s.content),m=(0,i.useCallback)(e=>{var t;d&&d(a.path,{...s,content:e.content,totalLines:e.totalLines,totalBytes:null!=(t=e.totalBytes)?t:s.totalBytes,range:e.range})},[d,a.path,s]),h=void 0!==s.range&&(null!=(n=s.totalLines)?n:0)>s.range.end-s.range.start+1;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(r6,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:s.content,onSearch:u.openSearch}),u.searchOpen&&(0,r.jsx)(rJ,{inputRef:u.searchInputRef,searchQuery:u.searchQuery,onQueryChange:u.setSearchQuery,matchCount:u.searchMatches.length,currentIdx:u.searchCurrentIdx,onNextMatch:u.nextMatch,onPrevMatch:u.prevMatch,onClose:u.closeSearch}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(r8,{content:s.content,extension:s.extension,searchMatches:u.searchOpen?u.searchMatches:void 0,searchCurrentIdx:u.searchOpen?u.searchCurrentIdx:void 0,totalLines:s.totalLines,rangeStart:null==(t=s.range)?void 0:t.start,worktreeId:h?l:void 0,filePath:h?a.path:void 0,onLineRangeFetched:h?m:void 0})})]})}let sa=(0,i.memo)(function(e){var t,n,a,s;let{tab:l,worktreeId:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,onDirtyChange:x,onOpenFile:f}=e,g=(0,c.c)("worktree"),p=(0,i.useRef)(g);p.current=g;let b=(0,i.useRef)(!1),[v,y]=(0,i.useState)(null),[w,j]=(0,i.useState)(!1);!function(e){let{tab:t,worktreeId:n,onLoadContent:a}=e,r=(0,i.useRef)(null),s=(0,i.useRef)(a);s.current=a;let l=(0,i.useRef)(t.path);l.current=t.path,nE({intervalMs:5e3,enabled:function(e){if(null===e.content||e.loading||e.isDirty||e.content.isPdf)return!1;let{totalBytes:t}=e.content;return void 0===t||!(t>=1048576)}(t),onPoll:async()=>{let e="/api/worktrees/".concat(n,"/files/").concat((0,eT.o)(l.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await fetch(e,{headers:t});if(304===n.status||!n.ok)return;r.current=n.headers.get("Last-Modified");let a=await n.json();s.current(l.current,a)}catch(e){}}})}({tab:l,worktreeId:o,onLoadContent:d});let k=(0,i.useMemo)(()=>x?e=>x(l.path,e):void 0,[x,l.path]),N=(0,i.useCallback)(()=>{j(e=>!e)},[]);(0,i.useEffect)(()=>{if(!w)return;let e=e=>{"Escape"===e.key&&j(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w]),(0,i.useEffect)(()=>{null!==l.content||l.loading||null!==l.error||b.current||(b.current=!0,m(l.path,!0),(async()=>{try{let t=await fetch("/api/worktrees/".concat(o,"/files/").concat((0,eT.o)(l.path)));if(304===t.status)return;if(!t.ok){var e;let n=await t.json(),a="string"==typeof n.error?n.error:(null==(e=n.error)?void 0:e.message)||p.current("fileViewer.loadError");u(l.path,a);return}let n=await t.json();d(l.path,n)}catch(e){u(l.path,e instanceof Error?e.message:p.current("fileViewer.loadError"))}finally{b.current=!1}})())},[l.content,l.loading,l.error,l.path,o,d,u,m]);let C=null!=(a=null==(t=l.content)?void 0:t.content)?a:null,S=null!=(s=null==(n=l.content)?void 0:n.extension)?s:null;if((0,i.useEffect)(()=>{if(!C||"md"!==S||!r4.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await fetch("/api/worktrees/".concat(o,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:C})});if(t.ok){let n=await t.json();e||y(Array.isArray(n.slides)?n.slides:null)}}catch(e){}})(),()=>{e=!0}},[C,S,o]),l.loading)return(0,r.jsx)(r5,{});if(l.error)return(0,r.jsx)(r3,{error:l.error});if(!l.content)return null;let{content:T}=l;return T.isImage?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(r6,{filePath:l.path,isMaximized:w,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ec.a,{src:T.content,alt:T.path,mimeType:T.mimeType})})]})}):T.isVideo?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(r6,{filePath:l.path,isMaximized:w,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ed.u,{src:T.content,mimeType:T.mimeType})})]})}):T.isPdf?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(r6,{filePath:l.path,isMaximized:w,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(r1,{dataUri:T.content,filePath:l.path})})]})}):T.isHtml?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(r6,{filePath:l.path,isMaximized:w,onToggleMaximize:N,copyableContent:T.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(r0,{worktreeId:o,filePath:l.path,htmlContent:T.content,onFileSaved:h,onOpenFile:f})})]})}):"md"===T.extension?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(r9,{marpSlides:v,fileName:l.name,worktreeId:o,filePath:l.path,contentText:T.content,onFileSaved:h,isMaximized:w,onToggleMaximize:N,onDirtyChange:k,onOpenFile:f}):(0,r.jsx)(st,{tab:l,content:T,worktreeId:o,isMaximized:w,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})}):!function(e){if(!e)return!1;let t=e.toLowerCase();return rX.includes(t)}("."+T.extension)?(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsx)(sn,{tab:l,content:T,worktreeId:o,isMaximized:w,onToggleMaximize:N,onLoadContent:d})}):(0,r.jsx)(se,{isMaximized:w,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(st,{tab:l,content:T,worktreeId:o,isMaximized:w,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})})});function sr(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let ss=(0,i.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:s}=e,l=(0,c.c)("worktree"),o=(0,i.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),d=(0,i.useCallback)(e=>{e.stopPropagation(),s(t.path)},[s,t.path]),u=n?"border-accent-500 text-accent-600 dark:text-accent-400 bg-surface":"border-transparent text-muted-foreground hover:text-foreground";return(0,r.jsxs)("div",{"data-testid":"file-tab-".concat(t.path),"data-active":n,onClick:o,className:"flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ".concat(u),children:[(0,r.jsx)("span",{className:"truncate max-w-[120px]",title:t.path,children:t.name}),t.isDirty&&(0,r.jsx)("span",{"data-testid":"file-tab-dirty-".concat(t.path),className:"w-2 h-2 rounded-full bg-warning flex-shrink-0",title:l("fileTabs.unsavedChanges")}),(0,r.jsx)("button",{type:"button",onClick:d,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":l("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(ew.A,{className:"w-3 h-3"})})]})}),sl=(0,i.memo)(function(e){let{tabs:t,activeIndex:n,worktreeId:a,onClose:s,onActivate:l,onLoadContent:o,onLoadError:c,onSetLoading:d,onFileSaved:u,onDirtyChange:m,onMoveToFront:h,onOpenFile:x}=e,[f,g]=(0,i.useState)(!1),p=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,w]=(0,i.useState)({x:0,y:0}),j=null!==n&&n>=0&&n<t.length?t[n]:null,k=t.length>5?t.slice(0,5):t,N=t.length>5?t.slice(5):[];(0,i.useEffect)(()=>{if(!f)return;let e=e=>{p.current&&!p.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]),(0,i.useLayoutEffect)(()=>{let e=e=>{v.current=e,w(t=>t.x===e.x&&t.y===e.y?t:e)};if(!f)return void e({x:0,y:0});let t=b.current;if(!t)return;let n=t.getBoundingClientRect();e({x:sr(n.left-v.current.x,n.width,window.innerWidth),y:sr(n.top-v.current.y,n.height,window.innerHeight)})},[f]);let C=(0,i.useCallback)(e=>{g(!1),null==h||h(e)},[h]),S=(0,i.useCallback)(()=>{g(e=>!e)},[]);return(0,r.jsxs)("div",{className:"flex flex-col h-full",children:[(0,r.jsxs)("div",{className:"flex border-b border-border bg-surface dark:bg-surface-2 min-w-0",children:[(0,r.jsx)("div",{className:"flex min-w-0 overflow-hidden flex-1",children:k.map((e,t)=>(0,r.jsx)(ss,{tab:e,isActive:t===n,onActivate:l,onClose:s},e.path))}),N.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:p,children:[(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:S,className:"flex items-center gap-0.5 px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:[(0,r.jsx)(tt.A,{className:"w-3 h-3 transition-transform ".concat(f?"rotate-180":"")}),(0,r.jsxs)("span",{children:["+",N.length]})]}),f&&(0,r.jsx)("div",{ref:b,"data-testid":"tab-dropdown-menu",className:"absolute right-0 top-full mt-1 bg-surface border border-border rounded-md shadow-lg z-50 min-w-[200px] max-h-[300px] overflow-y-auto",style:0!==y.x||0!==y.y?{transform:"translate(".concat(y.x,"px, ").concat(y.y,"px)")}:void 0,children:N.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-item-".concat(e.path),onClick:()=>C(e.path),className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-muted truncate",title:e.path,children:[e.name,e.isDirty&&(0,r.jsx)("span",{className:"ml-1 w-2 h-2 inline-block rounded-full bg-warning"})]},e.path))})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:j&&(0,r.jsx)(sa,{tab:j,worktreeId:a,onLoadContent:o,onLoadError:c,onSetLoading:d,onFileSaved:u,onDirtyChange:m,onOpenFile:x},j.path)})]})}),si=(0,i.memo)(function(e){let{line:t}=e,n="whitespace-pre font-mono text-xs leading-5";return t.startsWith("+")&&!t.startsWith("+++")?n+=" text-success-foreground bg-success-subtle":t.startsWith("-")&&!t.startsWith("---")?n+=" text-danger-foreground bg-danger-subtle":t.startsWith("@@")?n+=" text-info bg-info/10":t.startsWith("diff --git")||t.startsWith("index ")||t.startsWith("---")||t.startsWith("+++")?n+=" text-muted-foreground":n+=" text-foreground",(0,r.jsx)("div",{className:n,children:t})}),so=(0,i.memo)(function(e){let{diff:t,filePath:n,onClose:a}=e,s=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"h-full flex flex-col bg-surface",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border bg-muted shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-accent-600 dark:text-accent-400 shrink-0",children:s("diffViewer.badge")}),(0,r.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:n})]}),(0,r.jsx)("button",{type:"button",onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded shrink-0","aria-label":s("diffViewer.close"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-2",children:(0,r.jsx)("pre",{className:"text-xs",children:(0,r.jsx)("code",{children:t.split("\n").map((e,t)=>(0,r.jsx)(si,{line:e},t))})})})]})}),sc="commandmate.worktree.filePanelCollapsed",sd="commandmate:filePanelStateChange";function su(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{let e=window.localStorage.getItem(sc);if("true"===e)return!0}catch(e){}return!1}())},[]),(0,i.useEffect)(()=>{let e=e=>{e.detail&&e.detail.collapsed!==n.current&&t(e.detail.collapsed)};return window.addEventListener(sd,e),()=>window.removeEventListener(sd,e)},[]);let a=(0,i.useCallback)(e=>{t(e);try{window.localStorage.setItem(sc,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(sd,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,i.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let sm=(0,i.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:s,onCloseTab:l,onActivateTab:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,diffContent:x,diffFilePath:f,onCloseDiff:g,onDirtyChange:p,onMoveToFront:b,onOpenFile:v}=e,y=(0,c.c)("worktree"),w=(0,i.useRef)(null),[j,k]=(0,i.useState)(50),{collapsed:N,toggle:C}=su(),S=(0,i.useCallback)(e=>{let t=w.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let a=e/n*100;k(e=>Math.min(80,Math.max(20,e+a)))},[]),T=(0,i.useMemo)(()=>({width:"".concat(j,"%")}),[j]),E=(0,i.useMemo)(()=>({width:"".concat(100-j,"%")}),[j]),I=(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[n,(0,r.jsx)("div",{className:"flex-1 min-h-0",children:t})]});return a.tabs.length>0||x&&f?N?(0,r.jsxs)("div",{ref:w,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:{width:"calc(100% - ".concat(36,"px)")},className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)("div",{"data-testid":"file-panel-expand-bar",style:{width:"".concat(36,"px")},className:"flex-shrink-0 flex items-start justify-center bg-muted border-l border-border",children:(0,r.jsxs)("button",{type:"button","aria-label":y("terminal.showFiles"),title:y("terminal.showFiles"),onClick:C,className:"flex flex-col items-center gap-2 w-full pt-2 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:y("terminal.filesLabel")})]})})]}):(0,r.jsxs)("div",{ref:w,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:T,className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)(t2.f,{onResize:S,orientation:"horizontal",ariaValueNow:j}),(0,r.jsxs)("div",{"data-testid":"file-panel-pane",style:E,className:"flex-grow overflow-hidden flex",children:[(0,r.jsx)("button",{type:"button","aria-label":y("terminal.hideFiles"),title:y("terminal.hideFiles"),onClick:C,className:"flex-shrink-0 flex items-center justify-center w-5 h-full bg-muted border-r border-border text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:x&&f&&g?(0,r.jsx)(so,{diff:x,filePath:f,onClose:g}):(0,r.jsx)(sl,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:s,onClose:l,onActivate:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,onDirtyChange:p,onMoveToFront:b,onOpenFile:v})})]})]}):(0,r.jsx)("div",{className:"h-full",children:I})});var sh=n(7125),sx=n(22509),sf=n(54485),sg=n(70198);let sp={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},sb=new Set(te.XH);function sv(e){return"".concat("commandmate:terminalSplits:").concat(e)}function sy(e){return"object"==typeof e&&null!==e}function sw(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:sp.splits.map(e=>({...e})),widths:[...sp.widths]}}function sj(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function sk(e,t){let n;if(0===t.length)return e;let a=new Map(t.map(e=>[e.id,e.cliTool])),r=new Set,s=Math.min(Math.max(e.splits.length,1),t.length,3),l=[];for(let t of e.splits){if(l.length>=s)break;let e=a.get(t.instanceId);e&&!r.has(t.instanceId)&&(r.add(t.instanceId),l.push({cliToolId:e,instanceId:t.instanceId}))}for(let e of t){if(l.length>=s)break;r.has(e.id)||(r.add(e.id),l.push({cliToolId:e.cliTool,instanceId:e.id}))}return(0===l.length&&l.push({cliToolId:t[0].cliTool,instanceId:t[0].id}),l.length===e.splits.length&&l.every((t,n)=>t.instanceId===e.splits[n].instanceId&&t.cliToolId===e.splits[n].cliToolId))?e:(n=l.length===e.widths.length?sj(e.widths):l.length<e.widths.length?sj(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),{splits:l,widths:n})}function sN(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(sv(e));if(!n)return sw(t);let a=JSON.parse(n),r=function(e){if(!sy(e))return null;let{splits:t,widths:n}=e;if(!Array.isArray(t)||!Array.isArray(n)||t.length<1||t.length>3||n.length!==t.length)return null;let a=[];for(let e of t){if(!sy(e))return null;let t=e.cliToolId;if("string"!=typeof t||!sb.has(t))return null;let n=e.instanceId,r="string"==typeof n&&(0,te.n6)(n)?n:t;a.push({cliToolId:t,instanceId:r})}for(let e of n)if("number"!=typeof e||!Number.isFinite(e)||e<=0)return null;return{splits:a,widths:n}}(a);if(r)return{...r,widths:sj(r.widths)};return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),sw(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),sw(t)}}(e,t);return n?sk(a,t):a}let sC=(0,i.memo)(function(e){let{worktreeId:t,instances:n,rosterReady:a=!0,renderPane:s,onFocusedSplitChange:l,showToast:o,onActiveInstanceChange:d,headerInstanceSelection:u}=e,{splits:m,widths:h,addSplit:x,removeSplit:f,setSplitInstance:g,setSplitWidth:p,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:y,setFocusedSplitIndex:w}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,i.useState)(()=>sN(e,t,n)),[s,l]=(0,i.useState)(0),o=(0,i.useRef)(a);o.current=a;let c=(0,i.useRef)(t);c.current=t;let d=(0,i.useRef)(n);d.current=n;let u=(0,i.useRef)(e);(0,i.useEffect)(()=>{u.current!==e&&(u.current=e,r(sN(e,c.current,d.current)),l(0))},[e]);let m=(0,i.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,i.useEffect)(()=>{n&&r(e=>sk(e,c.current))},[m,n]);let h=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(h.current!==e){h.current=e;return}try{window.localStorage.setItem(sv(e),JSON.stringify(a))}catch(e){}},[a,e]);let x=(0,i.useCallback)(()=>{r(e=>{if(e.splits.length>=3)return e;let t=new Set(e.splits.map(e=>e.instanceId)),n=function(e,t){for(let n of e)if(!t.has(n.id))return n;return null}(c.current,t);if(!n)return e;let a=e.widths.length-1,r=e.widths[a]/2,s=[...e.widths];return s[a]=r,s.push(r),{splits:[...e.splits,{cliToolId:n.cliTool,instanceId:n.id}],widths:s}})},[]),f=(0,i.useCallback)(()=>{r(e=>e.splits.length<=1?e:{splits:e.splits.slice(0,-1),widths:sj(e.widths.slice(0,-1))})},[]);(0,i.useEffect)(()=>{l(e=>{let t=a.splits.length-1;return e>t?t:e<0?0:e})},[a.splits.length]);let g=(0,i.useCallback)((e,t)=>{let n=o.current,a=c.current;if(e<0||e>=n.splits.length)return!1;let s=a.find(e=>e.id===t);if(!s||n.splits[e].instanceId===t)return!1;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return!1;return r(n=>{if(e<0||e>=n.splits.length||n.splits[e].instanceId===t)return n;for(let a=0;a<n.splits.length;a++)if(a!==e&&n.splits[a].instanceId===t)return n;let a=n.splits.map((n,a)=>a===e?{cliToolId:s.cliTool,instanceId:t}:n);return{...n,splits:a}}),!0},[]),p=(0,i.useCallback)(e=>{r(t=>e.length!==t.widths.length||!function(e){if(!Array.isArray(e))return!1;for(let t of e)if("number"!=typeof t||!Number.isFinite(t)||t<=0)return!1;return!0}(e)?t:{...t,widths:[...e]})},[]),b=(0,i.useCallback)(()=>{r(e=>{let t=e.splits.length;return 0===t?e:{...e,widths:Array.from({length:t},()=>1/t)}})},[]),v=(0,i.useCallback)(e=>{let n=new Set;for(let t=0;t<a.splits.length;t++)t!==e&&n.add(a.splits[t].instanceId);return t.filter(e=>!n.has(e.id)).map(e=>e.id)},[a.splits,t]),y=(0,i.useCallback)(e=>{l(e)},[]);return{splits:a.splits,widths:a.widths,addSplit:x,removeSplit:f,setSplitInstance:g,setSplitWidth:p,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:s,setFocusedSplitIndex:y}}(t,n,a),j=(0,i.useMemo)(()=>{let e=new Map;for(let t of n)e.set(t.id,t);return e},[n]),k=(0,c.c)("worktree"),{visible:N,toggle:C,setWidth:S}=t1(),{collapsed:T,toggle:E}=su(),I=!T,M=(0,i.useRef)(null),[L,A]=(0,i.useState)(!1),R=(0,i.useRef)(m.length),[P,F]=(0,i.useState)(null);(0,i.useEffect)(()=>{m.length>R.current&&F(m.length-1),R.current=m.length},[m.length]),(0,i.useEffect)(()=>{null==l||l(y)},[y,l]);let D=(0,i.useRef)(0),z=(0,i.useRef)(m);z.current=m,(0,i.useEffect)(()=>{if(!u||u.token===D.current)return;D.current=u.token;let{instanceId:e}=u,t=z.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void w(t);g(0,e)&&w(0)}},[u,g,w]),(0,i.useEffect)(()=>{if(null===P)return;let e=M.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(P,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),w(P),F(null)},[P,w]);let O=(0,i.useCallback)((e,t)=>{let n=M.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=h.reduce((e,t)=>e+t,0),s=t/a*r,l=[...h],i=l[e]+s,o=l[e+1]-s,c=.05*r;i<c||o<c||(l[e]=i,l[e+1]=o,p(l))},[h,p]),B=(0,i.useCallback)(()=>A(!0),[]),_=(0,i.useCallback)(()=>A(!1),[]),W=(0,i.useCallback)(()=>{b(),S(40)},[b,S]),H=m.length<3&&!L,V=m.length>1&&!L,U=m.length>1||N,K=(0,i.useMemo)(()=>m.map((e,t)=>()=>w(t)),[m,w]),$=(0,i.useMemo)(()=>m.map((e,t)=>e=>g(t,e)),[m,g]),q=(0,i.useMemo)(()=>m.map((e,t)=>e=>{var n,a;let r=(0,te.sw)(null!=(a=j.get(e))?a:{cliTool:"claude",alias:e});if((null==(n=m[t])?void 0:n.instanceId)===e)return;let s=m.findIndex((n,a)=>a!==t&&n.instanceId===e);if(-1!==s){null==o||o("".concat(r," is already in use by split ").concat(s+1),"warning");return}g(t,e)&&(null==d||d(e),null==o||o("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[m,g,o,d,j]);return(0,r.jsxs)("div",{role:"group","aria-label":"Terminal splits","data-testid":"terminal-split-container",className:"flex flex-col h-full min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1 bg-surface border-b border-border flex-shrink-0",children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground tabular-nums mr-1",children:[m.length," / ",3," splits"]}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:!H,"aria-disabled":!H,"aria-label":k("terminal.addSplit"),title:k("terminal.addSplit"),"data-testid":"add-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(ay.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:f,disabled:!V,"aria-disabled":!V,"aria-label":k("terminal.removeSplit"),title:k("terminal.removeSplit"),"data-testid":"remove-terminal-split",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(sh.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:W,disabled:!U,"aria-disabled":!U,"aria-label":k("terminal.equalizeWidthsHint"),title:k("terminal.equalizeWidthsHint"),"data-testid":"equalize-split-widths",className:"flex items-center justify-center h-7 w-7 rounded text-muted-foreground hover:text-surface-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",children:(0,r.jsx)(sx.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})}),(0,r.jsx)("div",{className:"ml-auto h-4 w-px bg-border","aria-hidden":"true"}),(0,r.jsxs)("button",{type:"button",onClick:C,"aria-pressed":N,"aria-label":k(N?"terminal.hideHistory":"terminal.showHistory"),title:k(N?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ".concat(N?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[(0,r.jsx)(sf.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("terminal.historyLabel")})]}),(0,r.jsxs)("button",{type:"button",onClick:E,"aria-pressed":I,"aria-label":k(I?"terminal.hideFiles":"terminal.showFiles"),title:k(I?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:"flex items-center gap-1 text-xs px-2 py-0.5 rounded border transition-colors ".concat(I?"border-accent-300 dark:border-accent-700 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),children:[(0,r.jsx)(sg.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("terminal.filesLabel")})]})]}),(0,r.jsx)("div",{ref:M,className:"flex flex-1 min-h-0 w-full",children:m.map((e,t)=>{var n;let a=t===m.length-1;return(0,r.jsxs)(i.Fragment,{children:[(0,r.jsx)("div",{style:{flexGrow:null!=(n=h[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0},className:"h-full",children:s({splitIndex:t,cliToolId:e.cliToolId,instanceId:e.instanceId,instance:j.get(e.instanceId),availableInstances:v(t).map(e=>j.get(e)).filter(e=>void 0!==e),onInstanceChange:$[t],onFocus:K[t],isFocused:y===t,onDropInstance:q[t]})}),a?null:(0,r.jsx)(sS,{resizerIdx:t,ariaValueNow:h.length?h[t]/h.reduce((e,t)=>e+t,0)*100:50,onResize:O,onStart:B,onEnd:_,onDoubleClick:b})]},"split-".concat(t))})})]})});function sS(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:s,onEnd:l,onDoubleClick:o}=e,c=(0,i.useCallback)(e=>a(t,e),[t,a]);return(0,r.jsx)("div",{"data-testid":"split-resizer-".concat(t),onMouseDownCapture:s,onTouchStartCapture:s,onMouseUpCapture:l,onTouchEndCapture:l,children:(0,r.jsx)(t2.f,{onResize:c,orientation:"horizontal",ariaValueNow:n,onDoubleClick:o})})}let sT="\n px-6 py-2 rounded-lg font-medium transition-all\n disabled:opacity-50 disabled:cursor-not-allowed\n focus:outline-none focus:ring-2 focus:ring-offset-2\n".trim(),sE="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring";function sI(e){let{promptData:t,answering:n,onRespond:a,onDismiss:s,labelId:l,cliToolName:o}=e,d=(0,c.c)("prompt"),[u,h]=(0,i.useState)(()=>{if("multiple_choice"===t.type){var e;let n=t.options.find(e=>e.isDefault);return null!=(e=null==n?void 0:n.number)?e:null}return null}),[x,f]=(0,i.useState)(""),[g,p]=(0,i.useState)(!1),b=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===u))?e:null},[t,u]),v=(null==b?void 0:b.requiresTextInput)===!0,y=n||g,w=(0,i.useCallback)(async e=>{if(!y){p(!0);try{await a(e)}catch(e){}finally{p(!1)}}},[y,a]),j=(0,i.useCallback)(async()=>{if(!y&&null!==u){p(!0);try{let e=v&&x.trim()?x.trim():u.toString();await a(e)}catch(e){}finally{p(!1)}}},[y,a,u,v,x]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("h3",{id:l,className:"text-lg font-semibold text-warning-foreground flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xl","aria-hidden":"true",children:"?"}),o?d("confirmationFrom",{toolName:o}):d("confirmationFromClaude")]}),s&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:s,"aria-label":"close",className:"p-1 rounded hover:bg-warning-border/50 transition-colors",children:(0,r.jsx)("svg",{className:"w-5 h-5 text-warning-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.instructionText&&(0,r.jsx)("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap text-sm text-muted-foreground bg-muted rounded p-2 border border-border",children:t.instructionText}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:t.question}),y&&(0,r.jsxs)("div",{"data-testid":"answering-indicator",className:"flex items-center gap-2 text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[(0,r.jsx)(m.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:d("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(sM,{promptData:t,disabled:y,onYes:()=>w("yes"),onNo:()=>w("no")}),"multiple_choice"===t.type&&(0,r.jsx)(sL,{promptData:t,disabled:y,selectedOption:u,onSelectOption:h,textInputValue:x,onTextInputChange:f,showTextInput:v,onSubmit:j})]})}function sM(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,c.c)("prompt"),i="yes"===t.defaultOption,o="no"===t.defaultOption,d="".concat(sT," ").concat(sE," ").concat(i?"primary default highlighted":""),u="".concat(sT," ").concat(o?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":"bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring");return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:a,disabled:n,className:d,children:l("yes")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:s,disabled:n,className:u,children:l("no")})]})}function sL(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:s,textInputValue:l,onTextInputChange:o,showTextInput:d,onSubmit:u}=e,h=(0,i.useId)(),x=(0,c.c)("prompt"),f=(0,i.useCallback)(e=>{let t=a===e,r=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(t?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(r)},[a,n]);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:x("selectAnOption")}),(0,r.jsx)(m.z6,{name:h,value:null!=a?String(a):"",onValueChange:e=>s(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:f(e.number),children:[(0,r.jsx)(m.CU,{value:String(e.number),className:"mt-1","aria-describedby":e.isDefault?"default-".concat(e.number):void 0}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),e.isDefault&&(0,r.jsx)("span",{id:"default-".concat(e.number),className:"ml-2 text-xs text-accent-600 dark:text-accent-400 bg-accent-100 dark:bg-accent-900/30 px-2 py-0.5 rounded",children:x("default")})]})]},e.number))})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(h),className:"sr-only",children:x("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(h),type:"text",value:l,onChange:e=>o(e.target.value),disabled:n,placeholder:x("enterValuePlaceholder"),className:"w-full px-4 py-2 border-2 border-input dark:bg-muted dark:text-foreground rounded-lg focus:outline-none focus:border-accent-500 disabled:opacity-50"})]}),(0,r.jsx)("button",{type:"button",onClick:u,disabled:n||null===a,className:"w-full ".concat(sT," ").concat(sE),children:x("submit")})]})}let sA=(0,i.memo)(function(e){let t,{promptData:n,messageId:a,visible:s,answering:l,onRespond:o,onDismiss:c,cliToolName:d}=e,{shouldRender:u,animationClass:m}=I({visible:s&&null!==n,duration:200}),h=(0,i.useId)();if(!u||!n)return null;let x=(t="opacity-100","animate-fade-in"===m?t="opacity-100 transform translate-y-0":"animate-fade-out"===m&&(t="opacity-0 transform translate-y-2"),"".concat("bg-warning-subtle border-2 border-warning-border rounded-lg p-4 shadow-lg transition-all duration-200 ease-in-out"," ").concat(m," ").concat(t));return(0,r.jsx)(S,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":h,"aria-modal":"true",className:x,children:(0,r.jsx)(sI,{promptData:n,answering:l,onRespond:o,onDismiss:c,labelId:h,cliToolName:d})})})});var sR=n(91758);function sP(e){let{isOpen:t,onConfirm:n,onCancel:a,cliToolName:s}=e,l=(0,c.c)("autoYes"),o=(0,c.c)("common"),[d,u]=(0,i.useState)(36e5),[m,h]=(0,i.useState)(""),[x,f]=(0,i.useState)(null),[g,p]=(0,i.useState)(!1),b=(0,i.useRef)(null),v=e=>l(aT[e].replace("autoYes.",""));return(0,i.useEffect)(()=>{t&&(h(""),f(null),p(!1))},[t]),(0,i.useEffect)(()=>{if(!g)return;let e=e=>{b.current&&!b.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[g]),(0,i.useEffect)(()=>{if(!m.trim())return void f(null);let e=aE(m.trim());if(e.valid)f(null);else{var t;f(null!=(t=e.error)?t:l("invalidRegexPattern"))}},[m,l]),(0,r.jsx)(e7.a,{isOpen:t,onClose:a,title:s?l("enableTitleWithTool",{toolName:s}):l("enableTitle"),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("featureDescription")}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1",children:[(0,r.jsx)("li",{children:l("yesNoAutoResponse")}),(0,r.jsx)("li",{children:l("multipleChoiceAutoSelect")})]}),(0,r.jsx)("p",{className:"mt-1",children:l("autoDisableAfter",{duration:v(d)})}),s&&(0,r.jsx)("p",{className:"mt-2 text-muted-foreground",children:l("appliesOnlyToCurrent",{toolName:s})})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("duration")}),(0,r.jsx)("div",{className:"flex gap-2",children:aS.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>u(e),className:"flex-1 py-2 px-3 text-sm font-medium rounded-md border-2 transition-colors ".concat(d===e?"border-accent-600 bg-accent-50 dark:bg-accent-900/30 text-accent-700 dark:text-accent-400":"border-border bg-surface dark:bg-surface-2 text-foreground hover:border-muted-foreground"),style:{minHeight:"44px"},children:v(e)},e))})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("label",{htmlFor:"stop-pattern-input",className:"font-medium",children:l("stopPatternLabel")}),(0,r.jsxs)("div",{className:"relative",ref:b,children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!g),className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-muted text-muted-foreground text-[10px] font-bold hover:bg-muted/80 focus:outline-none","aria-label":l("regexTipsLabel"),"data-testid":"regex-tips-button",children:"?"}),g&&(0,r.jsxs)("div",{className:"absolute left-0 top-6 z-50 w-72 rounded-md border border-border bg-surface p-3 shadow-lg text-xs text-foreground","data-testid":"regex-tips-tooltip",children:[(0,r.jsx)("p",{className:"font-medium mb-1.5",children:l("regexTipsTitle")}),(0,r.jsxs)("ul",{className:"space-y-1",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"\\bcat\\b"})," ",l("regexTipWordBoundary")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"error|fatal"})," ",l("regexTipOr")]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{className:"bg-muted px-1 rounded",children:"(?i)error"})," ",l("regexTipCaseNote")]})]})]})]})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:l("stopPatternDescription")}),(0,r.jsx)("input",{id:"stop-pattern-input",type:"text",value:m,onChange:e=>h(e.target.value),placeholder:l("stopPatternPlaceholder"),className:"w-full px-3 py-2 border rounded-md text-sm font-mono bg-surface dark:bg-surface-2 text-foreground ".concat(x?"border-danger focus:ring-danger focus:border-danger":"border-input focus:ring-ring focus:border-accent-500"," focus:outline-none focus:ring-1"),"data-testid":"stop-pattern-input"}),x&&(0,r.jsx)("p",{className:"mt-1 text-xs text-danger","data-testid":"stop-pattern-error",children:x})]}),(0,r.jsxs)("div",{className:"text-sm text-foreground",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:l("aboutRisks")}),(0,r.jsx)("p",{children:l("riskWarning")})]}),(0,r.jsx)("div",{className:"bg-warning-subtle border-l-4 border-warning p-3",children:(0,r.jsxs)("p",{className:"text-sm text-warning-foreground",children:[(0,r.jsx)("span",{className:"font-medium",children:l("disclaimer")}),l("disclaimerText")]})}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:a,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:o("cancel")}),(0,r.jsx)("button",{type:"button",onClick:()=>{n(d,m.trim()||void 0)},disabled:!!x,className:"px-4 py-2 text-sm font-medium rounded-md text-white ".concat(x?"bg-muted-foreground cursor-not-allowed":"bg-warning hover:bg-warning/90"),"data-testid":"confirm-button",children:l("agreeAndEnable")})]})]})})}let sF=(0,i.memo)(function(e){let{enabled:t,expiresAt:n,onToggle:a,lastAutoResponse:s,cliToolName:l,inline:o=!1,showToolName:d=!0,onExpire:u}=e,m=(0,c.c)("autoYes"),[h,x]=(0,i.useState)(""),[f,g]=(0,i.useState)(null),[p,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[w,j]=(0,i.useState)(!1);(0,i.useEffect)(()=>{if(!t||!n){x(""),j(!1);return}j(!1);let e=!1,a=()=>(x(aI(n)),n-Date.now()<=0&&!e&&(e=!0,j(!0),null==u||u(),!0));if(a())return;let r=setInterval(()=>{a()&&clearInterval(r)},1e3);return()=>clearInterval(r)},[t,n,u]),(0,i.useEffect)(()=>{if(!s)return;g('Auto responded: "'.concat(s,'"'));let e=setTimeout(()=>g(null),ea.I2);return()=>clearTimeout(e)},[s]);let k=t&&!w,N=(0,i.useCallback)(()=>{k?(b(!0),a({enabled:!1}).finally(()=>b(!1))):y(!0)},[k,a]),C=(0,i.useCallback)((e,t)=>{y(!1),b(!0),a({enabled:!0,duration:e,stopPattern:t}).finally(()=>b(!1))},[a]),S=(0,i.useCallback)(()=>{y(!1)},[]);return(0,r.jsxs)("div",{className:o?"flex items-center gap-2":"flex items-center gap-3 px-4 py-2 bg-surface-2 border-b border-border",children:[(0,r.jsx)(sR.d,{checked:k,onCheckedChange:N,disabled:p,"aria-label":m("toggleLabel")}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:m("label")}),d&&l&&(0,r.jsxs)("span",{className:"text-xs text-accent-600 dark:text-accent-400 font-medium","aria-label":m("targetLabel"),children:["(",(0,te.f_)(l,""),")"]}),k&&h&&(0,r.jsx)("span",{className:"text-sm text-muted-foreground","aria-label":m("timeRemaining"),children:h}),f&&(0,r.jsx)("span",{className:"text-sm text-success animate-pulse",children:f}),(0,r.jsx)(sP,{isOpen:v,onConfirm:C,onCancel:S,cliToolName:(0,te.f_)(l,"")})]})});function sD(e){let t=new Set;for(let n of e)"user"===n.role&&t.add(n.id);return t}function sz(e,t,n){let a=new Set,r=new Set,s=e.filter(e=>"sending"===e.status);if(0===s.length)return{reconciledTempIds:a,consumedServerIds:r};let l=t.filter(e=>"user"===e.role&&!n.has(e.id)).sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()),i=new Set;for(let e of[...s].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime())){let t=l.find(t=>!i.has(t.id)&&!e.baselineUserIds.has(t.id)&&t.content===e.content);t&&(i.add(t.id),a.add(e.tempId),r.add(t.id))}return{reconciledTempIds:a,consumedServerIds:r}}function sO(e,t,n,a){let r={answer:e,cliTool:t};if(a&&a!==t&&(r.instanceId=a),n&&(r.promptType=n.type,"multiple_choice"===n.type)){let e=n.options.find(e=>e.isDefault);e&&(r.defaultOptionNumber=e.number),n.submitMode&&(r.submitMode=n.submitMode)}return r}let sB=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,splitIndex:d,cliToolId:u,instanceId:m,instance:h,availableInstances:x,onInstanceChange:f,onFocus:g,disabled:p=!1,pendingInsertText:b,onInsertConsumed:v,onMessageSent:y,cliStatus:w="idle",autoYes:j,history:k,onDropInstance:N,draggedInstanceId:C,onRequestSessionEnd:S}=e,T=null!=m?m:u,E=null!=(t=j.enabled)&&t,I=null!=(n=j.expiresAt)?n:null,M=null!=(a=j.lastAutoResponse)?a:null,L=j.onToggle,A=null!=(s=null==k?void 0:k.showArchived)&&s,R=null==k?void 0:k.onShowArchivedChange,P=null==k?void 0:k.historyDisplayLimit,F=null==k?void 0:k.onHistoryDisplayLimitChange,D=null!=(l=null==k?void 0:k.historyUserOnly)&&l,z=null==k?void 0:k.onHistoryUserOnlyChange,O=null==k?void 0:k.onInsertToMessage,B=null==k?void 0:k.onFilePathClick,W=null==k?void 0:k.showToast,H=(0,c.c)("worktree"),{terminal:V,prompt:U,setAutoScroll:K,setPromptAnswering:$,clearPrompt:q,refresh:J}=tk({worktreeId:o,cliToolId:u,instanceId:T,enabled:!p}),{messages:G,isLoading:Y,refresh:X}=function(e){let{worktreeId:t,cliToolId:n,instanceId:a,limit:r,includeArchived:s=!1,enabled:l=!0}=e,[o,c]=(0,i.useState)([]),[d,u]=(0,i.useState)(!0),{subscribe:m,unsubscribe:h,addListener:x}=(0,tj.xM)(),f=null!=a?a:n,g=(0,i.useRef)(0),p=(0,i.useRef)(n);p.current=n;let b=(0,i.useRef)(f);b.current=f;let v=(0,i.useCallback)(async()=>{let e=++g.current;try{let a=new URLSearchParams({cliTool:n,instance:f,unit:"pairs"});void 0!==r&&a.set("limit",String(r)),s&&a.set("includeArchived","true");let l=await fetch("/api/worktrees/".concat(t,"/messages?").concat(a.toString()));if(!l.ok)return;let i=await l.json();if(g.current!==e||p.current!==n||b.current!==f)return;c(i.map(e=>({...e,timestamp:new Date(e.timestamp)}))),u(!1)}catch(t){if(g.current!==e||p.current!==n||b.current!==f)return;console.error("[useSplitMessages] fetch error:",t),u(!1)}},[t,n,f,r,s]),y="".concat(t,"::").concat(n,"::").concat(f),w=(0,i.useRef)(y);return(0,i.useEffect)(()=>{w.current!==y&&(w.current=y,g.current+=1,c([]),u(!0))},[y]),(0,i.useEffect)(()=>{if(!l)return;let e=!1,t=setInterval(()=>{"hidden"!==document.visibilityState&&v()},5e3);"undefined"!=typeof document&&"hidden"!==document.visibilityState&&v();let n=()=>{"visible"!==document.visibilityState||e||v()};return document.addEventListener("visibilitychange",n),()=>{e=!0,clearInterval(t),document.removeEventListener("visibilitychange",n)}},[l,v]),(0,i.useEffect)(()=>{if(l)return m(t),()=>h(t)},[l,t,m,h]),(0,i.useEffect)(()=>{if(l)return x(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===b.current)&&(null==e.cliTool||e.cliTool===p.current)&&v()})},[l,t,x,v]),{messages:o,isLoading:d,refresh:(0,i.useCallback)(()=>v(),[v])}}({worktreeId:o,cliToolId:u,instanceId:T,limit:P,includeArchived:A,enabled:!p}),Q=(0,i.useCallback)((e,t)=>_.y.sendMessage(o,e,t),[o]),{messages:Z,sendOptimistic:ee,retry:et,discard:ea}=function(e){let{worktreeId:t,serverMessages:n,sendFn:a,onSent:r,timeoutMs:s=3e4}=e,[l,o]=(0,i.useState)([]),c=(0,i.useRef)(n);c.current=n;let d=(0,i.useRef)(l);d.current=l;let u=(0,i.useRef)(r);u.current=r;let m=(0,i.useRef)(a);m.current=a;let h=(0,i.useRef)(0),x=(0,i.useRef)(new Map),f=(0,i.useRef)(new Set),g=(0,i.useCallback)(e=>{let t=x.current.get(e);void 0!==t&&(clearTimeout(t),x.current.delete(e))},[]),p=(0,i.useCallback)(e=>{g(e);let t=setTimeout(()=>{x.current.delete(e),o(t=>t.map(t=>t.tempId===e&&"sending"===t.status?{...t,status:"error"}:t))},s);x.current.set(e,t)},[g,s]),b=(0,i.useCallback)(async e=>{p(e.tempId);try{var t;await m.current(e.content,e.options),null==(t=u.current)||t.call(u)}catch(t){g(e.tempId),o(t=>t.map(t=>t.tempId===e.tempId?{...t,status:"error"}:t))}},[p,g]),v=(0,i.useCallback)((e,t)=>{let n={tempId:"pending-".concat(h.current++),content:e,options:t,timestamp:new Date,status:"sending",baselineUserIds:sD(c.current)};o(e=>[...e,n]),b(n)},[b]),y=(0,i.useCallback)(e=>{let t=d.current.find(t=>t.tempId===e);if(!t)return;let n={...t,status:"sending",timestamp:new Date,baselineUserIds:sD(c.current)};o(t=>t.map(t=>t.tempId===e?n:t)),b(n)},[b]),w=(0,i.useCallback)(e=>{let t=d.current.find(t=>t.tempId===e);return g(e),o(t=>t.filter(t=>t.tempId!==e)),null==t?void 0:t.content},[g]);return(0,i.useEffect)(()=>{let{reconciledTempIds:e,consumedServerIds:t}=sz(d.current,n,f.current),a=new Set(n.map(e=>e.id)),r=new Set;f.current.forEach(e=>{a.has(e)&&r.add(e)}),t.forEach(e=>r.add(e)),f.current=r,0!==e.size&&(e.forEach(g),o(t=>t.filter(t=>!e.has(t.tempId))))},[n,g]),(0,i.useEffect)(()=>{let e=x.current;return()=>{e.forEach(e=>clearTimeout(e)),e.clear()}},[]),{messages:(0,i.useMemo)(()=>{if(0===l.length)return n;let{reconciledTempIds:e}=sz(l,n,f.current),a=l.filter(t=>!e.has(t.tempId)).map(e=>({id:e.tempId,worktreeId:t,role:"user",content:e.content,timestamp:e.timestamp,messageType:"normal",archived:!1,cliToolId:e.options.cliToolId,instanceId:e.options.instanceId,optimisticState:e.status}));return 0===a.length?n:[...n,...a]},[n,l,t]),pending:l,sendOptimistic:v,retry:y,discard:w}}({worktreeId:o,serverMessages:G,sendFn:Q,onSent:X}),{visible:er,width:es,toggle:el,setWidth:eo}=t1(),ec=i.useRef(null),ed=(0,i.useCallback)(e=>{let t=ec.current;if(!t)return;let n=t.offsetWidth;0!==n&&eo(es+e/n*100)},[es,eo]),eu="opencode"===u||"copilot"===u,em="claude"===u||"codex"===u,eh=(0,i.useCallback)(e=>K(e),[K]),ex=(0,i.useCallback)(e=>{J(),X(),null==y||y(e)},[J,X,y]),ef=(0,i.useCallback)(e=>{let t=ea(e);t&&(null==O||O(t))},[ea,O]),eg=(0,i.useCallback)(async e=>{$(!0);try{let t=sO(e,u,U.data,T),n=await fetch("/api/worktrees/".concat(o,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error("Failed to send prompt response: ".concat(n.status));q(),await J()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{$(!1)}},[o,u,T,U.data,$,q,J]),ep=(0,i.useCallback)(()=>{q()},[q]),eb=V.isSelectionListActive,ev=U.visible&&!E,ey=V.isUnclassifiedActive&&!eb&&!U.visible,ej=(0,i.useMemo)(()=>(0,r.jsx)(nr,{messages:Z,worktreeId:o,onFilePathClick:null!=B?B:()=>{},isLoading:Y,className:"h-full",showToast:W,onInsertToMessage:O,onRetryPending:et,onDiscardPending:ef,showArchived:A,onShowArchivedChange:R,historyDisplayLimit:P,onHistoryDisplayLimitChange:F,historyUserOnly:D,onHistoryUserOnlyChange:z,onCollapse:el,splitIndex:d,cliToolId:u}),[Z,et,ef,o,B,Y,W,O,A,R,P,F,D,z,el,d,u]),ek=(0,i.useMemo)(()=>(0,r.jsx)(tp,{output:V.output,isActive:V.isRunning,attaching:V.attaching,isThinking:V.isThinking,autoScroll:V.autoScroll,onScrollChange:eh,disableAutoFollow:eu,compactTuiLayoutPadding:em}),[V.output,V.isRunning,V.attaching,V.isThinking,V.autoScroll,eh,eu,em]),eN=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:ec,className:"flex h-full min-h-0 w-full",children:[er?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:ne(d),"data-testid":"split-history-slot-".concat(d),"aria-label":"History pane",style:{width:"".concat(es,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:ej}),(0,r.jsx)(t2.f,{onResize:ed,orientation:"horizontal",ariaValueNow:es})]}):(0,r.jsx)("div",{"data-testid":"split-history-expand-bar-".concat(d),className:"flex-shrink-0 flex items-start justify-center w-9 bg-gray-50 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700",children:(0,r.jsxs)("button",{type:"button","data-testid":"split-history-expand-".concat(d),"aria-label":H("terminal.showHistory"),title:H("terminal.showHistory"),"aria-expanded":"false",onClick:el,className:"flex flex-col items-center gap-2 w-full pt-2 text-gray-500 dark:text-gray-400 hover:text-accent-600 dark:hover:text-accent-400 focus:outline-none focus:ring-2 focus:ring-ring",children:[(0,r.jsx)("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-medium tracking-wide select-none",style:{writingMode:"vertical-rl"},"aria-hidden":"true",children:H("terminal.historyLabel")})]})}),(0,r.jsx)("div",{className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:ek})]}),[er,es,ej,ed,el,ek,d,H]),eC=(0,i.useMemo)(()=>(0,r.jsxs)("div",{className:"space-y-2",children:[eb?(0,r.jsx)(ei,{worktreeId:o,cliToolId:u,instanceId:T,onKeysSent:J,showPagerKeys:V.isPagerActive}):null,ey?(0,r.jsx)(tw,{worktreeId:o,cliToolId:u,instanceId:T,onKeysSent:J}):null,ev?(0,r.jsx)(sA,{promptData:U.data,messageId:U.messageId,visible:U.visible,answering:U.answering,onRespond:eg,onDismiss:ep,cliToolName:(0,te.oo)(u)}):null,(0,r.jsx)(en,{worktreeId:o,onMessageSent:ex,onOptimisticSend:ee,cliToolId:u,instanceId:T,isSessionRunning:V.isRunning,pendingInsertText:null!=b?b:null,onInsertConsumed:v,splitIndex:d,onFocus:g,isProcessing:V.isRunning,showToast:W,autoYesSlot:(0,r.jsx)(sF,{enabled:E,expiresAt:null!=I?I:null,onToggle:L,lastAutoResponse:null!=M?M:null,cliToolName:u,inline:!0})})]}),[eb,ev,ey,V.isPagerActive,o,u,T,J,U.data,U.messageId,U.visible,U.answering,eg,ep,ex,ee,V.isRunning,b,v,d,g,E,I,M,L,W]),eS=(0,te.sw)(null!=h?h:{cliTool:u}),eT=(0,i.useCallback)(()=>{null==S||S({cliToolId:u,instanceId:T,label:eS})},[S,u,T,eS]),eE=(0,i.useMemo)(()=>{if(!S||!V.isRunning)return null;let e=H("terminal.endSessionFor",{name:eS});return(0,r.jsx)("button",{type:"button",onClick:eT,"aria-label":e,title:e,"data-testid":"terminal-end-session-button-".concat(d),className:"flex items-center justify-center p-0.5 rounded text-muted-foreground hover:text-danger focus:text-danger hover:bg-danger/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-danger/50 transition-colors",children:(0,r.jsx)(ew.A,{size:14,"aria-hidden":"true"})})},[S,V.isRunning,H,eS,eT,d]);return(0,r.jsx)(ta,{worktreeId:o,splitIndex:d,cliToolId:u,instanceId:T,instance:h,availableInstances:x,onInstanceChange:f,headerExtras:eE,status:w,onFocus:g,attaching:V.attaching,terminal:eN,footer:eC,onDropInstance:N,draggedInstanceId:C})});var s_=n(52056);let sW=(0,i.memo)(function(e){let{isBranchMismatch:t,currentBranch:n,initialBranch:a}=e,s=(0,c.c)("worktree"),[l,o]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{o(!1)},[n]),!t||l||null===a)?null:(0,r.jsxs)("div",{"data-testid":"branch-mismatch-alert",role:"alert",className:"flex items-center gap-3 px-4 py-2 bg-warning-subtle border border-warning-border text-warning-foreground rounded-lg",children:[(0,r.jsx)(s_.A,{className:"w-5 h-5 text-warning flex-shrink-0"}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("span",{className:"text-sm",children:[s("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:a})," ",s("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>o(!0),className:"p-1 rounded hover:bg-warning-subtle transition-colors","aria-label":s("branchMismatch.dismiss"),children:(0,r.jsx)(ew.A,{className:"w-4 h-4"})})]})});var sH=n(58734);let sV=(0,i.memo)(function(e){let{isOpen:t,onClose:n,onConfirm:a,worktreeId:s,sourcePath:l,sourceType:o}=e,d=(0,c.c)("worktree"),u=(0,c.c)("common"),[h,x]=(0,i.useState)(""),[f,g]=(0,i.useState)(new Set([""])),[p,b]=(0,i.useState)([]),[v,w]=(0,i.useState)(!1),[j,k]=(0,i.useState)(new Set),N=l.includes("/")?l.substring(0,l.lastIndexOf("/")):"";(0,i.useEffect)(()=>{t&&(x(N),g(new Set([""])),b([]),C())},[t,s]);let C=(0,i.useCallback)(async()=>{w(!0);try{let e=await fetch("/api/worktrees/".concat(s,"/tree"));if(!e.ok)return;let t=(await e.json()).items.filter(e=>"directory"===e.type).map(e=>({name:e.name,path:e.name,loaded:!1}));b(t)}catch(e){}finally{w(!1)}},[s]),S=(0,i.useCallback)(async e=>{k(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(s,"/tree/").concat(e));if(!t.ok)return;let n=(await t.json()).items.filter(e=>"directory"===e.type).map(t=>({name:t.name,path:"".concat(e,"/").concat(t.name),loaded:!1}));b(t=>(function e(t,n,a){return t.map(t=>t.path===n?{...t,children:a,loaded:!0}:t.children?{...t,children:e(t.children,n,a)}:t)})(t,e,n))}catch(e){}finally{k(t=>{let n=new Set(t);return n.delete(e),n})}},[s]),T=(0,i.useCallback)(async e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});let t=function e(t,n){for(let a of t){if(a.path===n)return a;if(a.children){let t=e(a.children,n);if(t)return t}}return null}(p,e);t&&!t.loaded&&await S(e)},[p,S]),E=(0,i.useCallback)(e=>!(e===N||"directory"===o&&(e===l||e.startsWith(l+"/")))&&!0,[N,l,o]),I=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=f.has(e.path),a=h===e.path,s=j.has(e.path),l=E(e.path);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(a?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(l?"":"opacity-40 cursor-not-allowed"),style:{paddingLeft:"".concat(.5+1.25*t,"rem")},onClick:()=>{l&&x(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),T(e.path)},children:s?(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(tE.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(sH.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(y.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.name})]}),n&&e.children&&(0,r.jsx)("div",{children:e.children.map(e=>I(e,t+1))})]},e.path)},M=E(h);return(0,r.jsx)(e7.a,{isOpen:t,onClose:n,title:d("fileTree.moveDialogTitle"),size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"text-sm text-muted-foreground",children:[d("fileTree.moveTo"),": ",(0,r.jsx)("span",{className:"font-mono text-foreground",children:l})]}),(0,r.jsxs)("div",{className:"border border-border rounded-lg max-h-64 overflow-y-auto p-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer rounded text-sm transition-colors ".concat(""===h?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(E("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{E("")&&x("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(y.A,{className:"w-4 h-4 text-warning flex-shrink-0"}),(0,r.jsx)("span",{children:d("fileTree.rootDirectory")})]}),v?(0,r.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,r.jsx)(m.y$,{size:"md",variant:"muted"})}):p.map(e=>I(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(m.$n,{variant:"ghost",onClick:n,className:"px-4 py-2 text-sm text-foreground bg-white border border-border rounded-md hover:bg-muted transition-colors",children:u("cancel")}),(0,r.jsx)(m.$n,{variant:"ghost",onClick:()=>a(h),disabled:!M,className:"px-4 py-2 text-sm text-white bg-accent-600 rounded-md hover:bg-accent-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:d("fileTree.moveConfirm")})]})]})})});function sU(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let sK=(0,i.memo)(function(e){let{isOpen:t,parentPath:n,onConfirm:a,onCancel:s}=e,l=(0,c.c)("worktree"),o=(0,c.c)("common"),[d,u]=(0,i.useState)(""),[m,h]=(0,i.useState)(".md"),x=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(t){u(""),h(".md");let e=setTimeout(()=>{var e;null==(e=x.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let f=(0,i.useCallback)(()=>{let e=sU(d,m);e&&a(e)},[d,m,a]),g=(0,i.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),f())},[f]),p=sU(d,m),b=n?"".concat(n,"/").concat(p):p;return(0,r.jsx)(e7.a,{isOpen:t,onClose:s,title:l("newFileDialog.title"),size:"sm",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"new-file-name",className:"block text-sm font-medium text-foreground mb-1",children:l("newFileDialog.fileNameLabel")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:x,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:g,placeholder:l("newFileDialog.placeholder"),className:"flex-1 px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,r.jsx)("select",{"data-testid":"new-file-ext-select",value:m,onChange:e=>h(e.target.value),className:"px-3 py-2 border border-input rounded-lg bg-surface text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",children:rX.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),p&&(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-mono bg-muted rounded px-2 py-1",children:b}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:s,className:"px-4 py-2 text-sm font-medium text-foreground bg-muted hover:bg-muted/80 rounded-lg transition-colors",children:o("cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"new-file-confirm-button",onClick:f,disabled:!p,className:"px-4 py-2 text-sm font-medium text-white bg-accent-600 hover:bg-accent-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:l("newFileDialog.create")})]})]})})}),s$=(0,i.memo)(function(e){var t,n,a,s;let{worktreeId:l,worktree:o,worktreeName:d,worktreeStatus:u,instances:m,rosterReady:h,activeInstanceId:x,setActiveInstanceId:f,hasUpdate:g,lastAutoResponse:p,activeActivity:b,onActivityToggle:v,onBackClick:y,onInfoClick:w,onWorktreeStatusChange:j,pendingInsertTextMap:k,setFocusedSplitIndex:N,handleInsertToSplit:C,handleInsertConsumed:T,handleInsertToMessage:E,autoYesStateMap:I,makeAutoYesToggleHandler:M,showArchived:L,onShowArchivedChange:A,historyDisplayLimit:R,onHistoryDisplayLimitChange:P,historyUserOnly:F,onHistoryUserOnlyChange:D,onMessageSent:z,onFilePathClick:O,showToast:B,tabsState:_,tabsActions:W,onLoadContent:H,onLoadError:V,onSetLoading:U,onFilePanelSave:K,onDirtyChange:$,onOpenFile:q,diffContent:J,diffFilePath:G,onCloseDiff:Y,fileSearch:X,fileTreeRefresh:Q,onFileSelect:Z,onNewFile:ee,onNewDirectory:et,onRename:en,onDelete:ea,onUpload:er,onMove:es,onFileTreeReset:el,onDiffSelect:ei,onAgentInstancesChange:eo,vibeLocalModel:ec,onVibeLocalModelChange:ed,vibeLocalContextWindow:eu,onVibeLocalContextWindowChange:em,isInfoModalOpen:eh,onInfoModalClose:ex,onWorktreeUpdate:ef,fileInputRef:eg,onFileInputChange:ep,onKillSession:eb,onRequestSessionEnd:ev,killTarget:ey,isKillPending:ew,onKillCancel:ej,onKillConfirm:ek,moveTarget:eN,isMoveDialogOpen:eC,onMoveCancel:eS,onMoveConfirm:eT,showNewFileDialog:eE,newFileParentPath:eI,onNewFileConfirm:eM,onNewFileCancel:eL,killDialogTitle:eA,killDialogWarning:eR,cancelLabel:eP,endLabel:eF}=e,eD=(0,c.c)("worktree"),[ez,eO]=i.useState(null),eB=(0,i.useCallback)(e=>eO(e),[]),e_=(0,i.useCallback)(()=>eO(null),[]),[eW,eH]=i.useState(null),eV=i.useRef(0),eU=(0,i.useCallback)(e=>{f(e),eV.current+=1,eH({instanceId:e,token:eV.current})},[f]),eK=(0,i.useCallback)(e=>{var t,n,a,s,i,c;let{splitIndex:d,cliToolId:u,instanceId:m,instance:h,availableInstances:x,onInstanceChange:g,onFocus:b,onDropInstance:v}=e,y=null!=(a=k.get(d))?a:null,w=I.get(m),j=null!=(s=null==w?void 0:w.enabled)&&s,N=null!=(i=null==w?void 0:w.expiresAt)?i:null,S=(0,e9.kA)(null!=(c=null==o||null==(t=o.sessionStatusByInstance)?void 0:t[m])?c:null==o||null==(n=o.sessionStatusByCli)?void 0:n[u]);return(0,r.jsx)(sB,{worktreeId:l,splitIndex:d,cliToolId:u,instanceId:m,instance:h,availableInstances:x,onInstanceChange:e=>{g(e),0===d&&f(e)},onFocus:b,pendingInsertText:y,onInsertConsumed:()=>T(d),onMessageSent:z,cliStatus:S,autoYes:{enabled:j,expiresAt:N,lastAutoResponse:p,onToggle:M(u,m)},history:{showArchived:L,onShowArchivedChange:A,historyDisplayLimit:R,onHistoryDisplayLimitChange:P,historyUserOnly:F,onHistoryUserOnlyChange:D,onInsertToMessage:e=>C(d,e),onFilePathClick:O,showToast:B},onDropInstance:v,draggedInstanceId:ez,onRequestSessionEnd:ev})},[l,k,I,T,z,f,p,M,null==o?void 0:o.sessionStatusByCli,null==o?void 0:o.sessionStatusByInstance,O,B,C,L,A,R,P,F,D,ez,ev]),e$=(0,i.useMemo)(()=>(0,r.jsx)(sC,{worktreeId:l,instances:m,rosterReady:h,renderPane:eK,onFocusedSplitChange:N,showToast:B,onActiveInstanceChange:f,headerInstanceSelection:eW}),[l,m,h,eK,N,B,f,eW]),eq=(0,i.useMemo)(()=>(0,r.jsx)(sm,{terminal:e$,terminalHeader:null,fileTabs:_,worktreeId:l,onCloseTab:W.closeTab,onActivateTab:W.activateTab,onLoadContent:H,onLoadError:V,onSetLoading:U,onFileSaved:K,diffContent:J,diffFilePath:G,onCloseDiff:Y,onDirtyChange:$,onMoveToFront:W.moveToFront,onOpenFile:q}),[e$,_,l,W.closeTab,W.activateTab,H,V,U,K,J,G,Y,$,W.moveToFront,q]),eJ=(0,i.useMemo)(()=>(0,r.jsx)(rU,{active:b,onToggle:v}),[b,v]),eG=(0,i.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(nD,{query:X.query,mode:X.mode,isSearching:X.isSearching,error:X.error,onQueryChange:X.setQuery,onModeChange:X.setMode,onClear:X.clearSearch}),(0,r.jsx)(nA,{worktreeId:l,onFileSelect:Z,onNewFile:ee,onNewDirectory:et,onRename:en,onDelete:ea,onUpload:er,onMove:es,onResetView:el,refreshTrigger:Q,pollingEnabled:"files"===b,searchQuery:X.query,searchMode:X.mode,searchResults:null==(e=X.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(rb,{worktreeId:l,onDiffSelect:ei,isMobile:!1,worktree:null!=o?o:void 0,onInsertToMessage:E,className:"h-full"}),notes:(0,r.jsx)(nV,{worktreeId:l,className:"h-full",onInsertToMessage:E}),schedules:(0,r.jsx)(ah,{worktreeId:l,className:"h-full",onInsertToMessage:E,instances:m}),agent:(0,r.jsx)(aw,{worktreeId:l,instances:m,onInstancesChange:eo,vibeLocalModel:ec,onVibeLocalModelChange:ed,vibeLocalContextWindow:eu,onVibeLocalContextWindowChange:em}),timer:(0,r.jsx)(aF,{worktreeId:l,instances:m}),todo:(0,r.jsx)(nJ,{worktreeId:l,className:"h-full"}),skills:(0,r.jsx)(aU,{worktreeId:l,className:"h-full"})}},[l,o,b,X.query,X.mode,X.isSearching,X.error,X.setQuery,X.setMode,X.clearSearch,null==(t=X.results)?void 0:t.results,Z,ee,et,en,ea,er,es,el,Q,ei,E,m,eo,ec,ed,eu,em]),eY=(0,i.useMemo)(()=>null===b?null:(0,r.jsx)(rq,{active:b,activities:eG}),[b,eG]);return(0,r.jsx)(S,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[eJ,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(rC,{worktreeName:d,repositoryName:null!=(a=null!=(n=null==o?void 0:o.repositoryDisplayName)?n:null==o?void 0:o.repositoryName)?a:eD("detail.unknownRepository"),description:null==o?void 0:o.description,status:u,gitStatus:null==o?void 0:o.gitStatus,onBackClick:y,onInfoClick:w,hasUpdate:g,worktreeStatus:null!=(s=null==o?void 0:o.status)?s:null,onWorktreeStatusChange:j,sessionStatusByCli:null==o?void 0:o.sessionStatusByCli,sessionStatusByInstance:null==o?void 0:o.sessionStatusByInstance,instances:m,activeInstanceId:x,onActiveInstanceChange:eU,onAgentDragStart:eB,onAgentDragEnd:e_,onKillSession:eb}),(null==o?void 0:o.gitStatus)&&(0,r.jsx)(sW,{isBranchMismatch:o.gitStatus.isBranchMismatch,currentBranch:o.gitStatus.currentBranch,initialBranch:o.gitStatus.initialBranch}),(0,r.jsx)("div",{className:"flex-1 min-h-0 min-w-0",children:(0,r.jsx)(rI,{activityPane:eY,rightPane:(0,r.jsx)(t3,{terminal:eq})})})]}),(0,r.jsx)(rS,{worktreeId:l,worktree:o,isOpen:eh,onClose:ex,onWorktreeUpdate:ef}),(0,r.jsx)("input",{ref:eg,type:"file",accept:rY.join(","),onChange:ep,className:"hidden","aria-label":eD("detail.uploadFile")}),(0,r.jsx)(e7.a,{isOpen:null!==ey,onClose:ej,title:eA,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eR}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ej,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:eP}),(0,r.jsx)("button",{type:"button",onClick:ek,disabled:ew,"data-testid":"kill-session-confirm-button",className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:eF})]})]})}),eN&&(0,r.jsx)(sV,{isOpen:eC,onClose:eS,onConfirm:eT,worktreeId:l,sourcePath:eN.path,sourceType:eN.type}),(0,r.jsx)(sK,{isOpen:eE,parentPath:eI,onConfirm:eM,onCancel:eL})]})})});te.oo;var sq=n(51434);let sJ={data:null,messageId:null,visible:!1,answering:!1},sG={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5,leftPaneCollapsed:!1,activityBar:{active:"files"},historyPane:{visible:!0,width:25,collapsed:!1}},sY={type:null,message:null,retryable:!1,retryCount:0};function sX(){return{phase:"idle",prompt:{...sJ},layout:{...sG},error:{...sY},messages:[],wsConnected:!1}}function sQ(e,t){switch(t.type){case"SET_PHASE":return{...e,phase:t.phase};case"SHOW_PROMPT":return{...e,phase:"prompt",prompt:{data:t.data,messageId:t.messageId,visible:!0,answering:!1}};case"CLEAR_PROMPT":return{...e,prompt:{...sJ}};case"SET_PROMPT_ANSWERING":return{...e,prompt:{...e.prompt,answering:t.answering}};case"SET_LAYOUT_MODE":return{...e,layout:{...e.layout,mode:t.mode}};case"SET_MOBILE_ACTIVE_PANE":return{...e,layout:{...e.layout,mobileActivePane:t.pane}};case"SET_SPLIT_RATIO":return{...e,layout:{...e.layout,splitRatio:t.ratio}};case"SET_LEFT_PANE_TAB":return{...e,layout:{...e.layout,leftPaneTab:t.tab}};case"TOGGLE_LEFT_PANE":return{...e,layout:{...e.layout,leftPaneCollapsed:!e.layout.leftPaneCollapsed}};case"SET_LEFT_PANE_COLLAPSED":return{...e,layout:{...e.layout,leftPaneCollapsed:t.collapsed}};case"SET_ACTIVE_ACTIVITY":return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:t.activity}}};case"TOGGLE_ACTIVITY":{let n=e.layout.activityBar.active===t.activity?null:t.activity;return{...e,layout:{...e.layout,activityBar:{...e.layout.activityBar,active:n}}}}case"TOGGLE_HISTORY_PANE":{let t=!e.layout.historyPane.visible;return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t,collapsed:!t}}}}case"SET_HISTORY_PANE_VISIBLE":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,visible:t.visible,collapsed:!t.visible}}};case"SET_HISTORY_WIDTH":return{...e,layout:{...e.layout,historyPane:{...e.layout.historyPane,width:t.width}}};case"SET_ERROR":return{...e,error:t.error};case"CLEAR_ERROR":return{...e,error:{...sY}};case"INCREMENT_RETRY_COUNT":return{...e,error:{...e.error,retryCount:e.error.retryCount+1}};case"SET_MESSAGES":return{...e,messages:t.messages};case"ADD_MESSAGE":return{...e,messages:[...e.messages,t.message]};case"UPDATE_MESSAGE":return{...e,messages:e.messages.map(e=>e.id===t.id?{...e,...t.updates}:e)};case"CLEAR_MESSAGES":return{...e,messages:[]};case"SET_WS_CONNECTED":return{...e,wsConnected:t.connected};default:return e}}var sZ=n(66966);function s0(e,t){try{window.localStorage.setItem(rH(e),null!=t?t:rW)}catch(e){}}let s1="commandmate:file-tabs:";function s2(e){let t=e.split("/");return t[t.length-1]||e}function s4(e,t,n){let a=e.findIndex(e=>e.path===t);if(-1===a)return null;let r=[...e];return r[a]=n(r[a]),r}let s5={tabs:[],activeIndex:null};var s3=n(63001);let s6="commandmate:showArchived",s8="activeCliTab-",s7="activeInstanceId-";function s9(){let e=(0,c.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center h-full bg-surface text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}let le=(0,o.default)(()=>n.e(9263).then(n.bind(n,79263)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[79263]},ssr:!1,loading:()=>(0,r.jsx)(s9,{})}),lt=()=>{},ln=["terminal","history","files","memo","info"],la=(0,i.memo)(function(e){var t,n,a,l,o,u;let{worktreeId:m}=e,{activeActivity:f,activeCliTab:g,activeInstanceId:b,activeTab:v,agentInstances:y,autoYesEnabled:w,autoYesExpiresAt:j,autoYesStateMap:k,diffContent:N,diffFilePath:T,disableAutoFollow:E,displayedInstances:I,editorFilePath:M,error:A,fetchCurrentOutput:P,fileInputRef:F,fileSearch:D,fileTreeRefresh:z,handleActivityToggle:O,handleAgentInstancesChange:W,handleAutoYesToggle:H,handleBackClick:V,handleCloseDiff:U,handleDelete:K,handleDiffSelect:$,handleDirtyChange:q,handleEditorClose:J,handleEditorSave:G,handleFileInputChange:Y,handleFilePanelSave:Q,handleFilePathClick:Z,handleFileSelect:ee,handleHistoryDisplayLimitChange:et,handleHistoryUserOnlyChange:ea,handleInfoClick:er,handleInfoModalClose:es,handleInsertConsumed:el,handleInsertConsumedSingle:ec,handleInsertToMessage:ed,handleInsertToSplit:eu,handleKillCancel:em,handleKillConfirm:eh,openKillConfirm:ex,openActiveKillConfirm:ef,killTarget:eg,isKillPending:ep,handleLoadContent:eb,handleLoadError:ev,handleMessageSent:ey,handleMobileFileViewerClose:ew,handleMobileTabChange:ej,handleMove:ek,handleMoveCancel:eN,handleMoveConfirm:eC,handleNewDirectory:eS,handleNewFile:eE,handleNewFileCancel:eI,handleNewFileConfirm:eM,handleOpenFile:eL,handlePromptDismiss:eA,handlePromptRespond:eR,handleRename:eP,handleRetry:eF,handleSetLoading:eD,handleShowArchivedChange:ez,handleUpload:eO,handleVibeLocalContextWindowChange:eB,handleVibeLocalModelChange:e_,handleWorktreeStatusChange:eW,hasUpdate:eH,historyDisplayLimit:eV,historySubTab:eK,historyUserOnly:e$,isEditorMaximized:eq,isInfoModalOpen:eJ,isMobile:eY,isMoveDialogOpen:eQ,isSelectionListActive:eZ,isPagerActive:e0,lastAutoResponse:e1,loading:e2,makeAutoYesToggleHandler:e4,mobileFileViewerPath:e5,mobileSelectedAgents:e3,moveTarget:e6,newFileParentPath:e8,openMobileDrawer:tt,pendingInsertText:tn,pendingInsertTextMap:ta,rosterReady:tr,setActiveInstanceId:ts,setFocusedSplitIndex:tl,setHistorySubTab:ti,setIsEditorMaximized:to,setWorktree:tc,showArchived:td,showNewFileDialog:tu,showToast:tm,state:th,tCommon:tx,tWorktree:tf,tabsActions:tg,tabsState:tp,resetFileTreeView:tb,toggleInstanceVisible:tv,vibeLocalContextWindow:ty,vibeLocalModel:tw,visibleInstanceIds:tk,worktree:tN,worktreeName:tC,worktreeStatus:tS}=function(e){var t,n,a,r,l,o,d,u,m,h;let{worktreeId:f}=e,g=(0,s.useRouter)(),p=(0,X.a)(),b=(0,i.useRef)(p);b.current=p;let{openMobileDrawer:v}=(0,rV.VF)(),{state:y,actions:w}=function(){let[e,t]=(0,i.useReducer)(sQ,void 0,sX),{value:n,setValue:a}=(0,aq.V)({key:"commandmate.worktree.leftPaneCollapsed",defaultValue:!1,validate:e=>"boolean"==typeof e}),r=(0,i.useRef)(e.layout.leftPaneCollapsed);r.current=e.layout.leftPaneCollapsed;let s=(0,i.useRef)(!1);(0,i.useEffect)(()=>{s.current||(s.current=!0,n!==r.current&&t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:n}))},[n]);let l=(0,i.useMemo)(()=>({setPhase:e=>t({type:"SET_PHASE",phase:e}),showPrompt:(e,n)=>t({type:"SHOW_PROMPT",data:e,messageId:n}),clearPrompt:()=>t({type:"CLEAR_PROMPT"}),setPromptAnswering:e=>t({type:"SET_PROMPT_ANSWERING",answering:e}),setError:e=>t({type:"SET_ERROR",error:e}),clearError:()=>t({type:"CLEAR_ERROR"}),setMessages:e=>t({type:"SET_MESSAGES",messages:e}),addMessage:e=>t({type:"ADD_MESSAGE",message:e}),updateMessage:(e,n)=>t({type:"UPDATE_MESSAGE",id:e,updates:n}),clearMessages:()=>t({type:"CLEAR_MESSAGES"}),setMobileActivePane:e=>t({type:"SET_MOBILE_ACTIVE_PANE",pane:e}),setLeftPaneTab:e=>t({type:"SET_LEFT_PANE_TAB",tab:e}),setLayoutMode:e=>t({type:"SET_LAYOUT_MODE",mode:e}),setSplitRatio:e=>t({type:"SET_SPLIT_RATIO",ratio:e}),setWsConnected:e=>t({type:"SET_WS_CONNECTED",connected:e}),toggleLeftPane:()=>{let e=!r.current;t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:e}),a(e)},setActiveActivity:e=>t({type:"SET_ACTIVE_ACTIVITY",activity:e}),toggleActivity:e=>t({type:"TOGGLE_ACTIVITY",activity:e}),toggleHistoryPane:()=>t({type:"TOGGLE_HISTORY_PANE"}),setHistoryPaneVisible:e=>t({type:"SET_HISTORY_PANE_VISIBLE",visible:e}),setHistoryWidth:e=>t({type:"SET_HISTORY_WIDTH",width:e})}),[a]);return{state:e,dispatch:t,actions:l}}(),j=(0,c.c)("worktree"),k=(0,c.c)("error"),N=(0,c.c)("common"),C=(0,c.c)("autoYes"),S=(0,eo.SC)(),T=(0,sZ.rC)(),E=null!=(l=null==T?void 0:T.worktrees.find(e=>e.id===f))?l:null,[I,M]=(0,i.useState)(E),[L,A]=(0,i.useState)(null===E),[R,P]=(0,i.useState)(null),F=(0,i.useRef)(null!==E),[D,z]=(0,i.useState)(!1),[O,B]=function(e){let[t,n]=(0,i.useReducer)(function e(t,n){switch(n.type){case"OPEN_FILE":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1!==e){if(t.activeIndex===e)return t;return{...t,activeIndex:e}}if(t.tabs.length>=30)return t;let a={path:n.path,name:s2(n.path),content:null,loading:!1,error:null,isDirty:!1},r=[...t.tabs,a];return{tabs:r,activeIndex:r.length-1}}case"CLOSE_TAB":{var a,r;let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e)return t;let s=t.tabs.filter((t,n)=>n!==e),l=(a=t.activeIndex,0===(r=s.length)||null===a?null:e<a?a-1:e===a?Math.min(e,r-1):a);return{tabs:s,activeIndex:l}}case"ACTIVATE_TAB":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||t.activeIndex===e)return t;return{...t,activeIndex:e}}case"SET_CONTENT":{let e=s4(t.tabs,n.path,e=>({...e,content:n.content,loading:!1,error:null,isDirty:!1}));if(!e)return t;return{...t,tabs:e}}case"SET_LOADING":{let e=s4(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=s4(t.tabs,n.path,e=>({...e,error:n.error,loading:!1}));if(!e)return t;return{...t,tabs:e}}case"RENAME_FILE":{let e=t.tabs.findIndex(e=>e.path===n.oldPath);if(-1===e)return t;let a=[...t.tabs];return a[e]={...a[e],path:n.newPath,name:s2(n.newPath)},{...t,tabs:a}}case"DELETE_FILE":return e(t,{type:"CLOSE_TAB",path:n.path});case"RESTORE":{let e=n.paths.slice(0,30).map(e=>({path:e,name:s2(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return s5;let t=n.activePath?Math.max(0,e.findIndex(e=>e.path===n.activePath)):0;return{tabs:e,activeIndex:t}}case"SET_DIRTY":{let e=t.tabs.find(e=>e.path===n.path);if(e&&e.isDirty===n.isDirty)return t;let a=s4(t.tabs,n.path,e=>({...e,isDirty:n.isDirty}));if(!a)return t;return{...t,tabs:a}}case"MOVE_TO_FRONT":{let e=t.tabs.findIndex(e=>e.path===n.path);if(-1===e||0===e)return t;return{tabs:[t.tabs[e],...t.tabs.filter((t,n)=>n!==e)],activeIndex:0}}case"CLOSE_ALL":if(0===t.tabs.length)return t;return s5;default:return t}},s5),a=(0,i.useRef)(!1),r=(0,i.useRef)(e);(0,i.useEffect)(()=>{if(r.current!==e&&(r.current=e,a.current=!1),a.current)return;a.current=!0;let t=function(e){try{let t=window.localStorage.getItem(s1+e);if(!t)return null;let n=JSON.parse(t);if("object"==typeof n&&null!==n&&Array.isArray(n.paths)&&n.paths.every(e=>"string"==typeof e)&&(null===n.activePath||"string"==typeof n.activePath))return n}catch(e){}return null}(e);t&&t.paths.length>0&&n({type:"RESTORE",paths:t.paths,activePath:t.activePath})},[e]),(0,i.useEffect)(()=>{if(a.current){var n,r;try{let a={paths:t.tabs.map(e=>e.path),activePath:null!==t.activeIndex&&null!=(r=null==(n=t.tabs[t.activeIndex])?void 0:n.path)?r:null};window.localStorage.setItem(s1+e,JSON.stringify(a))}catch(e){}}},[e,t]);let s=(0,i.useRef)(t);s.current=t;let l=(0,i.useCallback)(e=>{let t=s.current.tabs;return -1!==t.findIndex(t=>t.path===e)?(n({type:"OPEN_FILE",path:e}),"activated"):t.length>=30?"limit_reached":(n({type:"OPEN_FILE",path:e}),"opened")},[]),o=(0,i.useCallback)(e=>{n({type:"CLOSE_TAB",path:e})},[]),c=(0,i.useCallback)(e=>{n({type:"ACTIVATE_TAB",path:e})},[]),d=(0,i.useCallback)((e,t)=>{n({type:"RENAME_FILE",oldPath:e,newPath:t})},[]),u=(0,i.useCallback)(e=>{n({type:"DELETE_FILE",path:e})},[]),m=(0,i.useCallback)(e=>{n({type:"MOVE_TO_FRONT",path:e})},[]),h=(0,i.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),x=(0,i.useMemo)(()=>({dispatch:n,openFile:l,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:h}),[n,l,o,c,d,u,m,h]);return[t,x]}(f),[W,H]=(0,i.useState)(null),[V,U]=(0,i.useState)(null),[K,$]=(0,i.useState)(!1),[q,J]=(0,i.useState)(new Map),[G,Y]=(0,i.useState)(null),[Q,Z]=(0,i.useState)(!1),[ee,et]=(0,i.useState)(!1),[en,ea]=(0,i.useState)(!1),er=(0,i.useRef)(!1),[es,el]=(0,i.useState)(null),[ei,ec]=(0,i.useState)(s3.fJ),ed=(0,i.useRef)(ei);ed.current=ei;let[eu,em]=(0,i.useState)(()=>(0,te.lu)(s3.fJ)),eh=(0,i.useRef)(eu);eh.current=eu;let[ex,ef]=(0,i.useState)(null),eg=ex===f,[ep,eb]=(0,i.useState)(null),[ev,ey]=(0,i.useState)(null),[ew,ej]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(s8+f);if(e&&(0,te.hR)(e))return e}catch(e){}return s3.fJ[0]}),ek=(0,i.useCallback)(e=>{ej(e);try{window.localStorage.setItem(s8+f,e)}catch(e){}},[f]),eN=(0,i.useRef)(ew);eN.current=ew;let[eC,eS]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(s7+f);if(e&&(0,te.n6)(e))return e;let t=window.localStorage.getItem(s8+f);if(t&&(0,te.hR)(t))return t}catch(e){}return s3.fJ[0]}),eE=(0,i.useCallback)(e=>{eS(e);try{window.localStorage.setItem(s7+f,e)}catch(e){}let t=eh.current.find(t=>t.id===e);t&&ek(t.cliTool)},[f,ek]),eI=(0,i.useRef)(eC);eI.current=eC;let eM=(0,i.useRef)(0),eL=(0,i.useRef)(0),eA=(0,i.useRef)(0),eR=null!=(o=null==(t=q.get(eC))?void 0:t.enabled)&&o,eP=null!=(d=null==(n=q.get(eC))?void 0:n.expiresAt)?d:null,[eF,eD]=(0,i.useState)(0),[ez,eO]=(0,i.useState)(!1),[eB,e_]=(0,i.useState)(""),{active:eW,toggle:eH}=function(e){let[t,n]=(0,i.useState)(r_),a=(0,i.useRef)(t);a.current=t;let r=(0,i.useRef)(e);return r.current=e,(0,i.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(rH(e));if(t===rW)return null;if(t&&"string"==typeof t&&rB.has(t))return t}catch(e){}return r_}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,i.useCallback)(e=>{n(e),s0(r.current,e)},[]),toggle:(0,i.useCallback)(e=>{if(a.current===e){n(null),s0(r.current,null);return}n(e),s0(r.current,e)},[])}}(f),{historySubTab:eV,setHistorySubTab:eU,showArchived:eK,handleShowArchivedChange:e$,historyUserOnly:eq,handleHistoryUserOnlyChange:eJ,historyDisplayLimit:eY,handleHistoryDisplayLimitChange:eQ}=function(){let[e,t]=(0,i.useState)("message"),[n,a]=(0,i.useState)(()=>"true"===localStorage.getItem(s6)),r=(0,i.useCallback)(e=>{a(e),localStorage.setItem(s6,String(e))},[]),[s,l]=(0,i.useState)(()=>{try{return"true"===localStorage.getItem(t9)}catch(e){return!1}}),o=(0,i.useCallback)(e=>{l(e);try{localStorage.setItem(t9,String(e))}catch(e){}},[]),[c,d]=(0,i.useState)(()=>{try{let e=localStorage.getItem(t8);if(null===e)return 50;let t=parseInt(e,10);return t7(t)?t:50}catch(e){return 50}});return{historySubTab:e,setHistorySubTab:t,showArchived:n,handleShowArchivedChange:r,historyUserOnly:s,handleHistoryUserOnlyChange:o,historyDisplayLimit:c,handleHistoryDisplayLimitChange:(0,i.useCallback)(e=>{d(e);try{localStorage.setItem(t8,String(e))}catch(e){}},[])}}(),eZ=(0,i.useRef)(eK);(0,i.useEffect)(()=>{eZ.current=eK},[eK]);let e0=(0,i.useRef)(eY);(0,i.useEffect)(()=>{e0.current=eY},[eY]);let{pendingInsertTextMap:e1,pendingInsertText:e2,setFocusedSplitIndex:e4,handleInsertToMessage:e5,handleInsertToSplit:e3,handleInsertConsumed:e6,handleInsertConsumedSingle:e8}=function(){var e;let[t,n]=(0,i.useState)(()=>new Map),[a,r]=(0,i.useState)(0),s=(0,i.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(a,e),n})},[a]),l=(0,i.useCallback)((e,t)=>{n(n=>{let a=new Map(n);return a.set(e,t),a})},[]),o=(0,i.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),c=null!=(e=t.get(0))?e:null,d=(0,i.useCallback)(()=>o(0),[o]);return{pendingInsertTextMap:t,pendingInsertText:c,focusedSplitIndex:a,setFocusedSplitIndex:r,handleInsertToMessage:s,handleInsertToSplit:l,handleInsertConsumed:o,handleInsertConsumedSingle:d}}(),{diffContent:e7,diffFilePath:e9,handleDiffSelect:tt,handleCloseDiff:tn}=function(e){let[t,n]=(0,i.useState)(null),[a,r]=(0,i.useState)(null);return{diffContent:t,diffFilePath:a,handleDiffSelect:(0,i.useCallback)((t,a)=>{e||(n(t),r(a))},[e]),handleCloseDiff:(0,i.useCallback)(()=>{n(null),r(null)},[])}}(p),ta=function(e){let{worktreeId:t,initialMode:n="name",debounceMs:a=300}=e,[r,s]=(0,i.useState)(""),[l,o]=(0,i.useState)(""),[c,d]=(0,i.useState)(n),[u,m]=(0,i.useState)(!1),[h,f]=(0,i.useState)(null),[g,p]=(0,i.useState)(null),b=(0,i.useRef)(null),v=(0,i.useMemo)(()=>(0,x.sg)(e=>{o(e)},a),[a]),y=(0,i.useCallback)(e=>{s(e),v(e),p(null)},[v]),w=(0,i.useCallback)(()=>{s(""),o(""),f(null),p(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),j=(0,i.useCallback)(e=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[l]),k=(0,i.useCallback)(()=>h&&0!==h.results.length?(0,x.q3)(h.results.map(e=>e.filePath)):new Set,[h]);return(0,i.useEffect)(()=>{if("content"!==c||!l.trim())return void f(null);b.current&&b.current.abort();let e=new AbortController;return b.current=e,(async()=>{m(!0),p(null);try{var n,a;let r=await fetch("/api/worktrees/".concat(encodeURIComponent(t),"/search?q=").concat(encodeURIComponent(l),"&mode=content"),{signal:e.signal});if(!r.ok){let e=await r.json();throw Error((null==(n=e.error)?void 0:n.message)||"Search failed: ".concat(r.status))}let s=await r.json();if(s.success)f({mode:"content",query:l,results:s.results,totalMatches:s.totalMatches,truncated:s.truncated,executionTimeMs:s.executionTimeMs});else throw Error((null==(a=s.error)?void 0:a.message)||"Search failed")}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;p(e instanceof Error?e.message:"An error occurred while searching"),f(null)}finally{m(!1)}})(),()=>{e.abort()}},[c,l,t]),(0,i.useEffect)(()=>{"name"===c&&(f(null),m(!1),p(null))},[c]),{query:r,mode:c,isSearching:u,results:h,error:g,setQuery:y,setMode:d,clearSearch:w,filterByName:j,getMatchedPaths:k}}({worktreeId:f}),tr=(0,i.useRef)(!1),ts=(0,i.useRef)(f);(0,i.useEffect)(()=>{ts.current!==f&&(w.clearMessages(),tr.current=!1,J(new Map),ts.current=f)},[f,w]);let tl=(0,i.useCallback)(async()=>{try{var e,t;let n=await fetch("/api/worktrees/".concat(f));if(!n.ok)throw Error("Failed to fetch worktree: ".concat(n.status));let a=await n.json();if(M(a),a.selectedAgents){let e=ed.current;a.selectedAgents.length===e.length&&a.selectedAgents.every((t,n)=>t===e[n])||ec(a.selectedAgents)}if(a.agentInstances){let e=eh.current,t=a.agentInstances;t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.cliTool===e[n].cliTool&&t.alias===e[n].alias)||em(t),ef(f)}return"vibeLocalModel"in a&&eb(null!=(e=a.vibeLocalModel)?e:null),"vibeLocalContextWindow"in a&&ey(null!=(t=a.vibeLocalContextWindow)?t:null),a}catch(e){return P(e instanceof Error?e.message:"Unknown error"),null}},[f]),ti=(0,i.useCallback)(async()=>{let e=eN.current,t=b.current,n=eI.current,a=++eM.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),eZ.current&&r.set("includeArchived","true"),r.set("limit",String(e0.current));let s=await fetch("/api/worktrees/".concat(f,"/messages?").concat(r.toString()));if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(eM.current!==a||eN.current!==e||t&&eI.current!==n)return;w.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(eM.current!==a||eN.current!==e||t&&eI.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[f,w]),to=(0,i.useCallback)(async()=>{let e=eN.current,t=b.current,n=eI.current,a=++eL.current;try{var r,s,l,i;let o=t?"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e),c=await fetch(o);if(!c.ok)return;let d=await c.json();if(eL.current!==a||eN.current!==e||t&&eI.current!==n||d.cliToolId&&d.cliToolId!==e)return;if(d.isPromptWaiting&&d.promptData?w.showPrompt(d.promptData,"prompt-".concat(Date.now())):!d.isPromptWaiting&&y.prompt.visible&&w.clearPrompt(),et(null!=(r=d.isSelectionListActive)&&r),ea(null!=(s=d.isPagerActive)&&s),Y(null!=(l=d.lastServerResponseTimestamp)?l:null),Z(null!=(i=d.serverPollerActive)&&i),d.autoYes){let a=er.current,r=d.autoYes,s=t?n:e;J(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),er.current=r.enabled,a&&!d.autoYes.enabled&&("stop_pattern_matched"===d.autoYes.stopReason||"consecutive_errors"===d.autoYes.stopReason)&&el(d.autoYes.stopReason)}}catch(r){if(eL.current!==a||eN.current!==e||t&&eI.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[f,w,y.prompt.visible]),tc=(0,i.useCallback)(async()=>{let e=++eA.current;try{let a=await fetch("/api/worktrees/".concat(f,"/auto-yes"));if(!a.ok)return;let r=await a.json();if(eA.current!==e)return;let s=null==r?void 0:r.instances;if(!s||"object"!=typeof s)return;let l=new Map;for(let[e,a]of Object.entries(s))if(a&&"object"==typeof a){var t,n;l.set(e,{enabled:null!=(t=a.enabled)&&t,expiresAt:null!=(n=a.expiresAt)?n:null})}J(l)}catch(t){if(eA.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[f]),{visibleInstances:td,visibleInstanceIds:tu,toggleInstanceVisible:tm}=function(e){let{worktreeId:t,roster:n}=e,[a,r]=(0,i.useState)(null);(0,i.useEffect)(()=>{r(function(e){try{let t=window.localStorage.getItem(ag(e));if(null===t)return null;let n=JSON.parse(t);if(!Array.isArray(n))return null;let a=n.filter(e=>"string"==typeof e);return a.length>0?a:null}catch(e){return null}}(t))},[t]);let s=(0,i.useMemo)(()=>ap(a,n),[a,n]),l=(0,i.useMemo)(()=>s.map(e=>e.id),[s]),o=(0,i.useMemo)(()=>null!==a&&n.some(e=>a.includes(e.id)),[a,n]),c=(0,i.useCallback)(e=>{let a=new Set(e),s=n.filter(e=>a.has(e.id)).map(e=>e.id);if(!(s.length<1)){r(s);try{window.localStorage.setItem(ag(t),JSON.stringify(s))}catch(e){}}},[n,t]),d=(0,i.useCallback)(e=>c(e),[c]);return{visibleInstances:s,visibleInstanceIds:l,hasStoredPreference:o,toggleInstanceVisible:(0,i.useCallback)(e=>{let t=ap(a,n).map(e=>e.id);if(t.includes(e)){if(t.length<=1)return;c(t.filter(t=>t!==e))}else c([...t,e])},[a,n,c]),setVisibleInstanceIds:d,showInstances:(0,i.useCallback)(e=>{null!==a&&c([...ap(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:f,roster:eu}),th=p?td:eu,tx=(0,i.useMemo)(()=>Array.from(new Set(td.map(e=>e.cliTool))),[td]),tf=p?tx:ei;(0,i.useEffect)(()=>{0!==th.length&&(th.some(e=>e.id===eC)||eE(th[0].id))},[th,eC,eE]),(0,i.useEffect)(()=>{let e=th.find(e=>e.id===eC);e&&e.cliTool!==ew&&ek(e.cliTool)},[th,eC,ew,ek]);let tg="opencode"===ew||"copilot"===ew,tp=(0,i.useCallback)(e=>{ec(e)},[]),tb=(0,i.useCallback)(e=>{em(e),ef(f)},[f]),tv=(0,i.useCallback)(e=>{eb(e)},[]),ty=(0,i.useCallback)(e=>{ey(e)},[]),tw=(0,i.useRef)(ew);(0,i.useEffect)(()=>{tw.current!==ew&&(tw.current=ew,w.clearMessages(),w.clearPrompt(),et(!1),ti(),to())},[ew,w,ti,to]),(0,i.useEffect)(()=>{ti()},[eK,ti]),(0,i.useEffect)(()=>{ti()},[eY,ti]);let{showToast:tj}=(0,eG.dj)(),tk=(0,i.useCallback)(()=>{tj("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[tj]),tN=(0,i.useCallback)(e=>{p?H(e):"limit_reached"===B.openFile(e)&&tk()},[p,B,tk]),tC=(0,i.useCallback)(e=>{p?H(e):"limit_reached"===B.openFile(e)&&tk()},[p,B,tk]),tS=(0,i.useCallback)(e=>{"limit_reached"===B.openFile(e)&&tk()},[B,tk]),tT=(0,i.useCallback)(()=>{H(null)},[]),tE=(0,i.useCallback)(e=>{eD(e=>e+1)},[]),tI=(0,i.useCallback)(()=>{U(null)},[]),tM=(0,i.useCallback)(()=>{ta.clearSearch(),B.closeAllTabs(),H(null),U(null)},[ta,B]),tL=(0,i.useCallback)(e=>{eD(e=>e+1)},[]),tA=(0,i.useCallback)(e=>{eH(e)},[eH]),tR=(0,i.useCallback)(()=>{g.push("/")},[g]),tP=(0,i.useCallback)(async e=>{try{let t=await fetch("/api/worktrees/".concat(f),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:e})});if(t.ok){let e=await t.json();M(e)}}catch(e){}},[f]),tF=(0,i.useCallback)(()=>{z(!0)},[]),tD=(0,i.useCallback)(()=>{z(!1)},[]),tz=(0,i.useCallback)(async e=>{w.setPromptAnswering(!0);try{let t=sO(e,ew,y.prompt.data,b.current?eI.current:void 0),n=await fetch("/api/worktrees/".concat(f,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw Error("Failed to send prompt response: ".concat(n.status));w.clearPrompt(),await to()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{w.setPromptAnswering(!1)}},[f,w,to,ew,y.prompt.data]),tO=(0,i.useCallback)(()=>{w.clearPrompt()},[w]),tB=(0,i.useCallback)(e=>{w.setMobileActivePane(e)},[w]),t_=(0,i.useCallback)(()=>{ti(),to()},[ti,to]),tW=(0,i.useCallback)((e,t)=>async n=>{let a=null!=t?t:e;try{let t=await fetch("/api/worktrees/".concat(f,"/auto-yes"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:n.enabled,cliToolId:e,instanceId:a,duration:n.duration,stopPattern:n.stopPattern})});if(t.ok){let e=await t.json();J(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===eI.current&&(er.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[f]),tH=(0,i.useCallback)(e=>tW(ew,eC)(e),[tW,ew,eC]),[tV,tU]=(0,i.useState)(null),[tK,t$]=(0,i.useState)(!1),tq=(0,i.useRef)(!1),tJ=(0,i.useCallback)(e=>{tU(e)},[]),tG=(0,i.useCallback)(()=>{let e=eI.current,t=eN.current,n=(0,te.O6)(eh.current,e,t);tU({cliToolId:t,instanceId:e,label:n})},[]),tY=(0,i.useCallback)(async()=>{if(!tV||tq.current)return;tq.current=!0,t$(!0);let e=()=>{tV.instanceId===eI.current&&(w.clearMessages(),w.clearPrompt())};try{await _.y.killSession(f,tV.cliToolId,tV.instanceId),e(),await tl(),tU(null)}catch(t){t instanceof _.hD&&404===t.status?(e(),await tl(),tU(null)):tj(j("session.failedToKill"),"error")}finally{tq.current=!1,t$(!1)}},[tV,f,w,tl,tj,j]),tX=(0,i.useCallback)(()=>{tq.current||tU(null)},[]),tQ=(0,i.useCallback)(e=>{e_(e),eO(!0)},[]),tZ=(0,i.useCallback)(async e=>{eO(!1);let t=eB?"".concat(eB,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eT.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");eD(e=>e+1)}catch(e){window.alert(k("fileOps.failedToCreateFile"))}},[f,eB,k]),t0=(0,i.useCallback)(()=>{eO(!1)},[]),t1=(0,i.useCallback)(async e=>{let t=window.prompt("Enter directory name:");if(!t)return;let n=e?"".concat(e,"/").concat(t):t;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eT.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");eD(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(k("fileOps.failedToCreateDirectory"))}},[f,k]),t2=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||"",n=window.prompt("Enter new name:",t);if(n&&n!==t)try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eT.o)(e)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"rename",newName:n})})).ok)throw Error("Failed to rename");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")+1):"";B.onFileRenamed(e,"".concat(t).concat(n)),eD(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(k("fileOps.failedToRename"))}},[f,B,k]),t4=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await S({description:N("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eT.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(V===e||(null==V?void 0:V.startsWith("".concat(e,"/"))))&&U(null),B.onFileDeleted(e),eD(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(k("fileOps.failedToDelete"))}},[f,V,B,N,k,S]);(0,i.useEffect)(()=>{"stop_pattern_matched"===es?(tj(C("stopPatternMatched"),"info"),el(null)):"consecutive_errors"===es&&(tj(C("consecutiveErrorsStopped"),"warning"),el(null))},[es,tj,C]);let{moveTarget:t5,isMoveDialogOpen:t3,handleMove:t6,handleMoveConfirm:ne,handleMoveCancel:nt}=function(e,t,n,a){let[r,s]=(0,i.useState)(null),[l,o]=(0,i.useState)(!1),c=(0,i.useCallback)((e,t)=>{s({path:e,type:t}),o(!0)},[]),d=(0,i.useCallback)(async l=>{if(r)try{let s=await fetch("/api/worktrees/".concat(e,"/files/").concat(r.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:l})}),o=await s.json();if(!s.ok||!o.success){var i;let e=(null==(i=o.error)?void 0:i.message)||"Failed to move";null==a||a(e);return}null==n||n("Moved successfully"),t()}catch(e){null==a||a("Failed to move")}finally{s(null),o(!1)}},[r,e,t,n,a]);return{moveTarget:r,isMoveDialogOpen:l,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,i.useCallback)(()=>{s(null),o(!1)},[])}}(f,()=>eD(e=>e+1),e=>tj(e,"success"),e=>tj(e,"error")),nn=(0,i.useRef)(null),na=(0,i.useRef)(""),nr=(0,i.useCallback)(e=>{var t;na.current=e,null==(t=nn.current)||t.click()},[]),ns=(0,i.useCallback)(async e=>{var t,n,a;let r=null==(t=e.target.files)?void 0:t[0];if(!r)return;e.target.value="";let s=na.current,l=".".concat(null==(n=r.name.split(".").pop())?void 0:n.toLowerCase());if(!function(e){if(!e)return!1;let t=e.toLowerCase();return rY.includes(t)}(l))return void tj("Unsupported file type: ".concat(l,". Allowed: ").concat(rY.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return rG.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void tj("File too large. Maximum size: ".concat((i/1024/1024).toFixed(1),"MB"),"error");let o=new FormData;o.append("file",r);try{let e=await fetch("/api/worktrees/".concat(f,"/upload/").concat((0,eT.o)(s||".")),{method:"POST",body:o});if(!e.ok){let t=await e.json().catch(()=>({})),n=(null==t||null==(a=t.error)?void 0:a.message)||"Failed to upload file";tj(n,"error");return}let t=await e.json();tj("Uploaded: ".concat(t.filename),"success"),eD(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),tj("Upload failed. Please try again.","error")}},[f,tj]),{data:nl}=eX(),ni=null!=(u=null==nl?void 0:nl.hasUpdate)&&u,{lastAutoResponse:no}=function(e){let{worktreeId:t,cliTool:n,isPromptWaiting:a,promptData:r,autoYesEnabled:s,lastServerResponseTimestamp:l,serverPollerActive:o}=e,c=(0,i.useRef)(null),[d,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{var e;if(!a){c.current=null;return}if(!r||!s||o||l&&Date.now()-l<3e3)return;let i=(e={type:r.type,question:r.question},"".concat(e.type,":").concat(e.question));if(c.current===i)return;let d=function(e,t){let n=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){let t=e.options.find(e=>e.isDefault),n=null!=t?t:e.options[0];return!n||n.requiresTextInput?null:n.number.toString()}return null}(e);if(null===n)return{answer:null,suppressedBy:null};let a=function(e,t){if(!t)return null;if("off"===t.mode)return{reason:"mode-off"};let n=function(e,t){if(0===t.length)return{outcome:"no-match"};let n=function(e){let t=[e.question];if(e.instructionText&&t.push(e.instructionText),"multiple_choice"===e.type)for(let n of e.options)t.push(n.label);else t.push(...e.options);return t.map(e=>e.length>2e4?e.slice(0,2e4):e)}(e);for(let e of t){if(e.length>200||!aE(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=function(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2];try{return e.test(t)}catch(e){return null}}(t,a);if(null===n)return{outcome:"unusable",pattern:e};if(n)return{outcome:"match",pattern:e}}}return{outcome:"no-match"}}(e,t.denyPatterns);return"match"===n.outcome?{reason:"deny-pattern",pattern:n.pattern}:"unusable"===n.outcome?{reason:"deny-pattern-unusable",pattern:n.pattern}:"safe"===t.mode?"yes_no"===e.type?null:{reason:"type-not-allowed"}:"allow-listed"===t.mode?t.allowPromptTypes.includes(e.type)?null:{reason:"type-not-allowed"}:null}(e,t);return a?{answer:null,suppressedBy:a.reason,pattern:a.pattern}:{answer:n,suppressedBy:null}}(r,void 0).answer;if(null===d)return;c.current=i,u(d);let m=sO(d,n,r);fetch("/api/worktrees/".concat(t,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}).catch(e=>{console.error("[useAutoYes] Failed to send auto-response:",e)})},[a,r,s,t,n,l,o]),{lastAutoResponse:d}}({worktreeId:f,cliTool:ew,isPromptWaiting:y.prompt.visible,promptData:y.prompt.data,autoYesEnabled:eR,lastServerResponseTimestamp:G,serverPollerActive:Q}),nc=(0,i.useCallback)(async()=>{P(null),A(!0),await tl()&&await Promise.all([ti(),to()]),A(!1)},[tl,ti,to]);!function(e){let{error:t,handleRetry:n,fetchWorktree:a,fetchMessages:r,fetchCurrentOutput:s,setError:l}=e,o=(0,i.useRef)(0),c=(0,i.useCallback)(async()=>{if("visible"!==document.visibilityState)return;let e=Date.now();if(!(e-o.current<5e3)){if(o.current=e,t)return void n();try{await Promise.all([a(),r(),s()])}finally{l(null)}}},[t,n,a,r,s,l]);(0,i.useEffect)(()=>(document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}),[c])}({error:R,handleRetry:nc,fetchWorktree:tl,fetchMessages:ti,fetchCurrentOutput:to,setError:P}),(0,i.useEffect)(()=>{if(tr.current)return;let e=!0;return(async()=>{F.current||A(!0),await Promise.all([tl(),ti(),to()]),e&&(A(!1),tr.current=!0)})(),()=>{e=!1}},[tl,ti,to]);let nd=null!=(m=null==I||null==(r=I.sessionStatusByCli)||null==(a=r[ew])?void 0:a.isRunning)&&m;(0,i.useEffect)(()=>{if(L||R)return;let e=setInterval(async()=>{let e=[to(),tl()];p&&e.push(ti()),await Promise.all(e)},nd?2e3:5e3);return()=>clearInterval(e)},[L,R,to,tl,ti,nd,p]),(0,i.useEffect)(()=>{tc()},[f,eg,tc]),(0,i.useEffect)(()=>{w.setLayoutMode(p?"tabs":"split")},[p,w]);let nu=(0,i.useMemo)(()=>(function(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"claude";if(t)return"error";if(!e)return"idle";let r=null==(n=e.sessionStatusByCli)?void 0:n[a];if(r){if(r.isWaitingForResponse)return"waiting";if(r.isProcessing)return"running";if(r.isRunning)return"ready"}if("claude"===a){if(e.isWaitingForResponse)return"waiting";if(e.isProcessing)return"running";if(e.isSessionRunning)return"ready"}return"idle"})(I,null!==y.error.type,ew),[I,y.error.type,ew]),nm=(0,i.useMemo)(()=>y.layout.mobileActivePane,[y.layout.mobileActivePane]),nh=null!=(h=null==I?void 0:I.name)?h:"Unknown",nx=(0,i.useCallback)((e,t)=>{B.dispatch({type:"SET_CONTENT",path:e,content:t})},[B]),nf=(0,i.useCallback)((e,t)=>{B.dispatch({type:"SET_ERROR",path:e,error:t})},[B]),ng=(0,i.useCallback)((e,t)=>{B.dispatch({type:"SET_LOADING",path:e,loading:t})},[B]);return{activeActivity:eW,activeCliTab:ew,activeInstanceId:eC,activeTab:nm,agentInstances:eu,autoYesEnabled:eR,autoYesExpiresAt:eP,autoYesStateMap:q,diffContent:e7,diffFilePath:e9,disableAutoFollow:tg,displayedAgents:tf,displayedInstances:th,editorFilePath:V,error:R,fetchCurrentOutput:to,fileInputRef:nn,fileSearch:ta,fileTreeRefresh:eF,handleActivityToggle:tA,handleAgentInstancesChange:tb,handleAutoYesToggle:tH,handleBackClick:tR,handleCloseDiff:tn,handleDelete:t4,handleDiffSelect:tt,handleDirtyChange:(0,i.useCallback)((e,t)=>{B.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[B]),handleEditorClose:tI,handleEditorSave:tL,handleFileInputChange:ns,handleFilePanelSave:tE,handleFilePathClick:tN,handleFileSelect:tC,handleHistoryDisplayLimitChange:eQ,handleHistoryUserOnlyChange:eJ,handleInfoClick:tF,handleInfoModalClose:tD,handleInsertConsumed:e6,handleInsertConsumedSingle:e8,handleInsertToMessage:e5,handleInsertToSplit:e3,handleKillCancel:tX,handleKillConfirm:tY,openKillConfirm:tJ,openActiveKillConfirm:tG,killTarget:tV,isKillPending:tK,handleLoadContent:nx,handleLoadError:nf,handleMessageSent:t_,handleMobileFileViewerClose:tT,handleMobileTabChange:tB,handleMove:t6,resetFileTreeView:tM,handleMoveCancel:nt,handleMoveConfirm:ne,handleNewDirectory:t1,handleNewFile:tQ,handleNewFileCancel:t0,handleNewFileConfirm:tZ,handleOpenFile:tS,handlePromptDismiss:tO,handlePromptRespond:tz,handleRename:t2,handleRetry:nc,handleSelectedAgentsChange:tp,handleSetLoading:ng,handleShowArchivedChange:e$,handleUpload:nr,handleVibeLocalContextWindowChange:ty,rosterReady:eg,handleVibeLocalModelChange:tv,handleWorktreeStatusChange:tP,hasUpdate:ni,historyDisplayLimit:eY,historySubTab:eV,historyUserOnly:eq,isEditorMaximized:K,isInfoModalOpen:D,isMobile:p,isMoveDialogOpen:t3,isSelectionListActive:ee,isPagerActive:en,lastAutoResponse:no,loading:L,makeAutoYesToggleHandler:tW,mobileFileViewerPath:W,mobileSelectedAgents:tx,moveTarget:t5,newFileParentPath:eB,openMobileDrawer:v,pendingInsertText:e2,pendingInsertTextMap:e1,selectedAgents:ei,setActiveCliTab:ek,setActiveInstanceId:eE,setEditorFilePath:U,setFocusedSplitIndex:e4,setHistorySubTab:eU,setIsEditorMaximized:$,setWorktree:M,showArchived:eK,showNewFileDialog:ez,showToast:tj,state:y,tCommon:N,tWorktree:j,tabsActions:B,tabsState:O,toggleInstanceVisible:tm,vibeLocalContextWindow:ev,vibeLocalModel:ep,visibleInstanceIds:tu,worktree:I,worktreeName:nh,worktreeStatus:nu}}({worktreeId:m}),[tT,tE]=(0,i.useState)(!1),tI=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,tj.xM)(),[r,s]=(0,i.useState)(!1),l=(0,i.useRef)(n);return l.current=n,(0,i.useEffect)(()=>{n&&s(!1)},[n]),(0,i.useEffect)(()=>a(e=>{e.worktreeId===t&&("terminal_snapshot"===e.type||"message"===e.type)&&(l.current||s(!0))}),[a,t]),!n&&r}({worktreeId:m,active:"terminal"===v}),{viewportHeight:tM}=(0,sq.C)(),tL=(0,i.useCallback)(e=>{let t=ln.indexOf(v);if(-1===t)return;let n=t+e;n<0||n>=ln.length||ej(ln[n])},[v,ej]),{ref:tA}=(0,L.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===v),onSwipeLeft:()=>tL(1),onSwipeRight:()=>tL(-1)});if(e2)return(0,r.jsx)(rT,{});if(A)return(0,r.jsx)(rE,{message:A,onRetry:eF});let tR=(0,te.O6)(y,b,g),tP=null!=(l=null==eg?void 0:eg.label)?l:tR,tF=null!=(u=null==(t=null!=(o=null==tN||null==(n=tN.sessionStatusByInstance)?void 0:n[b])?o:null==tN||null==(a=tN.sessionStatusByCli)?void 0:a[g])?void 0:t.isRunning)&&u;return eY?(0,r.jsx)(S,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=tM?"".concat(tM,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(p,{worktreeName:tC,repositoryName:null==tN?void 0:tN.repositoryName,status:tS,gitStatus:null==tN?void 0:tN.gitStatus,onBackClick:V,onMenuClick:tt})}),(null==tN?void 0:tN.gitStatus)&&tN.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(sW,{isBranchMismatch:tN.gitStatus.isBranchMismatch,currentBranch:tN.gitStatus.currentBranch,initialBranch:tN.gitStatus.initialBranch})}),(0,r.jsxs)("div",{className:"flex-shrink-0 z-30 flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-border",children:[(0,r.jsx)("nav",{className:"flex gap-1 flex-1 min-w-0 overflow-x-auto scrollbar-hide","aria-label":tf("detail.agentInstanceSelection"),children:I.map(e=>{var t,n,a;let s=(0,e9.kA)(null!=(a=null==tN||null==(t=tN.sessionStatusByInstance)?void 0:t[e.id])?a:null==tN||null==(n=tN.sessionStatusByCli)?void 0:n[e.cliTool]),l=tx("status.".concat(s)),i=b===e.id;return(0,r.jsxs)("button",{onClick:()=>ts(e.id),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] px-1.5 py-1 font-medium text-xs transition-colors flex items-center gap-1 border-b-2 touch-manipulation ".concat(i?"text-accent-600 dark:text-accent-400 border-accent-500":"text-muted-foreground hover:text-foreground border-transparent"),"aria-current":i?"page":void 0,children:[(0,r.jsx)(h.m,{status:s,size:"sm",label:tf("detail.statusPill",{label:(0,te.sw)(e),status:l})}),(0,te.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tE(!0),className:"flex-shrink-0 flex items-center justify-center min-h-[44px] min-w-[44px] rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors touch-manipulation","aria-label":tf("terminal.moreActions"),"data-testid":"mobile-more-actions-button",children:(0,r.jsx)(d.A,{size:18,"aria-hidden":"true"})})]}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-y-auto",ref:tA,children:(0,r.jsx)(ry,{activeTab:v,worktreeId:m,worktree:tN,messages:th.messages,cliToolId:g,instanceId:b,onFilePathClick:Z,onFileSelect:ee,onWorktreeUpdate:tc,onNewFile:eE,onNewDirectory:eS,onRename:eP,onDelete:K,onUpload:eO,onMove:ek,onFileTreeReset:tb,refreshTrigger:z,fileSearch:D,showToast:tm,selectedAgents:e3,onSelectedAgentsChange:lt,useInstanceManagement:!0,instances:y,onInstancesChange:W,visibleInstanceIds:tk,onToggleInstanceVisible:tv,vibeLocalModel:tw,onVibeLocalModelChange:e_,vibeLocalContextWindow:ty,onVibeLocalContextWindowChange:eB,disableAutoFollow:E,historySubTab:eK,onHistorySubTabChange:ti,onDiffSelect:$,onInsertToMessage:ed,showArchived:td,onShowArchivedChange:ez,historyDisplayLimit:eV,onHistoryDisplayLimitChange:et,historyUserOnly:e$,onHistoryUserOnlyChange:ea})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[eZ&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(ei,{worktreeId:m,cliToolId:g,instanceId:b,onKeysSent:P,showPagerKeys:e0})}),(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(en,{worktreeId:m,onMessageSent:ey,cliToolId:g,instanceId:b,isSessionRunning:tF,pendingInsertText:tn,onInsertConsumed:ec,autoYesSlot:(0,r.jsx)(sF,{enabled:w,expiresAt:j,onToggle:H,lastAutoResponse:e1,cliToolName:g,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(C,{activeTab:v,onTabChange:ej,hasNewOutput:tI,hasPrompt:th.prompt.visible,hasUpdate:eH,inFlow:!0}),!w&&(0,r.jsx)(R,{promptData:th.prompt.data,visible:th.prompt.visible,answering:th.prompt.answering,onRespond:eR,onDismiss:eA,cliToolName:(0,te.oo)(g)}),(0,r.jsx)(B,{open:tT,onClose:()=>tE(!1),onSearch:()=>window.dispatchEvent(new CustomEvent("terminal-search-open")),onEnd:ef,endDisabled:!tF}),(0,r.jsx)(eU,{isOpen:null!==e5,onClose:ew,worktreeId:m,filePath:null!=e5?e5:"",onFileSaved:G,onOpenFile:Z}),(0,r.jsx)("input",{ref:F,type:"file",accept:rY.join(","),onChange:Y,className:"hidden","aria-label":tf("detail.uploadFile")}),(0,r.jsx)(e7.a,{isOpen:null!==eg,onClose:em,title:tf("session.confirmEnd",{tool:tP}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tf("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:em,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tx("cancel")}),(0,r.jsx)("button",{type:"button",onClick:eh,disabled:ep,className:"px-4 py-2 text-sm font-medium rounded-md bg-danger hover:bg-danger/90 text-white disabled:opacity-60 disabled:cursor-not-allowed",children:tx("end")})]})]})}),e6&&(0,r.jsx)(sV,{isOpen:eQ,onClose:eN,onConfirm:eC,worktreeId:m,sourcePath:e6.path,sourceType:e6.type}),(0,r.jsx)(sK,{isOpen:tu,parentPath:e8,onConfirm:eM,onCancel:eI})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s$,{worktreeId:m,worktree:tN,worktreeName:tC,worktreeStatus:tS,instances:y,rosterReady:tr,activeInstanceId:b,setActiveInstanceId:ts,hasUpdate:eH,lastAutoResponse:e1,activeActivity:f,onActivityToggle:O,onBackClick:V,onInfoClick:er,onWorktreeStatusChange:eW,pendingInsertTextMap:ta,setFocusedSplitIndex:tl,handleInsertToSplit:eu,handleInsertConsumed:el,handleInsertToMessage:ed,autoYesStateMap:k,makeAutoYesToggleHandler:e4,showArchived:td,onShowArchivedChange:ez,historyDisplayLimit:eV,onHistoryDisplayLimitChange:et,historyUserOnly:e$,onHistoryUserOnlyChange:ea,onMessageSent:ey,onFilePathClick:Z,showToast:tm,tabsState:tp,tabsActions:tg,onLoadContent:eb,onLoadError:ev,onSetLoading:eD,onFilePanelSave:Q,onDirtyChange:q,onOpenFile:eL,diffContent:N,diffFilePath:T,onCloseDiff:U,fileSearch:D,fileTreeRefresh:z,onFileSelect:ee,onNewFile:eE,onNewDirectory:eS,onRename:eP,onDelete:K,onUpload:eO,onMove:ek,onFileTreeReset:tb,onDiffSelect:$,onAgentInstancesChange:W,vibeLocalModel:tw,onVibeLocalModelChange:e_,vibeLocalContextWindow:ty,onVibeLocalContextWindowChange:eB,isInfoModalOpen:eJ,onInfoModalClose:es,onWorktreeUpdate:tc,fileInputRef:F,onFileInputChange:Y,onKillSession:ef,onRequestSessionEnd:ex,killTarget:eg,isKillPending:ep,onKillCancel:em,onKillConfirm:eh,moveTarget:e6,isMoveDialogOpen:eQ,onMoveCancel:eN,onMoveConfirm:eC,showNewFileDialog:tu,newFileParentPath:e8,onNewFileConfirm:eM,onNewFileCancel:eI,killDialogTitle:tf("session.confirmEnd",{tool:tP}),killDialogWarning:tf("session.endWarning"),cancelLabel:tx("cancel"),endLabel:tx("end")}),M&&(0,r.jsx)(e7.a,{isOpen:!0,onClose:J,title:M.split("/").pop()||tf("fileViewer.editor"),size:"full",disableClose:eq,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(le,{worktreeId:m,filePath:M,onClose:J,onSave:G,onMaximizedChange:to})})})]})});function lr(){let e=(0,s.useParams)().id;return(0,r.jsx)(l.GV,{children:(0,r.jsx)(la,{worktreeId:e})})}}},e=>{e.O(0,[6481,6809,4909,2770,790,4974,8566,9948,1191,5542,9599,6402,744,6488,4560,2751,8562,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);
|