commandmate 0.27.1 → 0.29.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/.env.example +28 -0
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +441 -404
- package/.next/app-path-routes-manifest.json +34 -29
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +9 -9
- package/.next/react-loadable-manifest.json +0 -6
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +32 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route.js +1 -1
- 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_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 +32 -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 +34 -3
- 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_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_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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/capabilities/route.js +1 -1
- package/.next/server/app/api/capabilities/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 +1 -1
- 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 +1 -1
- 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 +2 -2
- 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/hooks/permission-request/route.js +1 -1
- package/.next/server/app/api/hooks/permission-request/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/metrics/vibe/route.js +1 -1
- 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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/escalation/route.js +1 -1
- package/.next/server/app/api/push/escalation/route.js.nft.json +1 -1
- package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route.js +7 -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/remote/pair/route.js +2 -0
- package/.next/server/app/api/remote/pair/route.js.nft.json +1 -0
- package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -0
- 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 +1 -1
- 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.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 +1 -1
- 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.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.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 +1 -1
- 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 +1 -1
- 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]/clear-composer/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/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 +2 -2
- 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]/env/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/env/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/env/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]/instances/opencode/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -0
- 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 +4 -4
- 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]/opencode/diff/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/diff/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/session/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/session/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/share/route.js +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/share/route.js.nft.json +1 -0
- package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -0
- 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]/resolve-target/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/resolve-target/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/resolve-target/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 +5 -1
- 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 +6 -2
- 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 +7 -3
- 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/[skillId]/update/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route.js +1 -1
- 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 +1 -1
- 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 -3
- 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 +1 -1
- 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/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page.js +2 -2
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page.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_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page.js +1 -1
- package/.next/server/app/review/page.js.nft.json +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 +1 -1
- 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 +15 -10
- 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 +2 -2
- 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 +34 -29
- package/.next/server/chunks/1058.js +1 -0
- package/.next/server/chunks/1068.js +1 -3
- package/.next/server/chunks/1162.js +1 -1
- package/.next/server/chunks/1191.js +13 -0
- package/.next/server/chunks/1296.js +1 -1
- package/.next/server/chunks/1601.js +2 -2
- package/.next/server/chunks/1714.js +7 -0
- package/.next/server/chunks/1886.js +5 -0
- package/.next/server/chunks/1944.js +1 -0
- package/.next/server/chunks/2119.js +1 -1
- package/.next/server/chunks/221.js +19 -0
- package/.next/server/chunks/222.js +1 -0
- package/.next/server/chunks/2328.js +1 -1
- package/.next/server/chunks/2366.js +1 -0
- package/.next/server/chunks/2404.js +1 -1
- package/.next/server/chunks/243.js +1 -0
- package/.next/server/chunks/2445.js +1 -1
- package/.next/server/chunks/2759.js +1 -1
- package/.next/server/chunks/3346.js +1 -1
- package/.next/server/chunks/3440.js +1 -1
- package/.next/server/chunks/3480.js +17 -1
- package/.next/server/chunks/3543.js +1 -1
- package/.next/server/chunks/3558.js +1 -0
- package/.next/server/chunks/3945.js +1 -1
- package/.next/server/chunks/4299.js +1 -0
- package/.next/server/chunks/4393.js +1 -1
- package/.next/server/chunks/5017.js +1 -1
- package/.next/server/chunks/5089.js +1 -1
- package/.next/server/chunks/5354.js +1 -1
- package/.next/server/chunks/5571.js +1 -1
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/6274.js +11 -10
- package/.next/server/chunks/6285.js +1 -1
- package/.next/server/chunks/6337.js +1 -0
- package/.next/server/chunks/6401.js +1 -1
- package/.next/server/chunks/663.js +78 -0
- package/.next/server/chunks/7472.js +1 -1
- package/.next/server/chunks/7824.js +1 -0
- package/.next/server/chunks/7905.js +1 -0
- package/.next/server/chunks/880.js +6 -6
- package/.next/server/chunks/8807.js +84 -18
- package/.next/server/chunks/9123.js +2 -2
- package/.next/server/chunks/9130.js +5 -0
- package/.next/server/chunks/9328.js +1 -1
- package/.next/server/chunks/9358.js +1 -1
- package/.next/server/chunks/9508.js +1 -1
- package/.next/server/chunks/9584.js +1 -0
- package/.next/server/chunks/9627.js +274 -0
- package/.next/server/chunks/9798.js +2 -0
- package/.next/server/chunks/9938.js +1 -1
- package/.next/server/functions-config-manifest.json +3 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- 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/1188-8567ee5ecfef02ee.js +1 -0
- package/.next/static/chunks/3361-aa1b6e7c1d7eeeb4.js +1 -0
- package/.next/static/chunks/3968-8d8ca15657748bfb.js +1 -0
- package/.next/static/chunks/5229-580b581fce5aeb52.js +1 -0
- package/.next/static/chunks/6381-c8d93ec301dbc380.js +1 -0
- package/.next/static/chunks/app/api/app/update/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/app/update-check/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/conversation/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/current-output/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/messages/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/session/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/start/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/terminal/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/assistant/tools/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/auth/login/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/auth/logout/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/auth/status/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/capabilities/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/daily-summary/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/daily-summary/status/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/external-apps/[id]/health/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/external-apps/[id]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/external-apps/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/fs/browse/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/fs/recent-paths/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/hooks/agent-event/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/hooks/claude-done/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/hooks/permission-request/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/metrics/vibe/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/ollama/models/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/push/escalation/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/push/subscriptions/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/push/vapid/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/remote/pair/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/[id]/todos/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/clone/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/excluded/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/restore/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/scan/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/sync/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/repositories/validate-path/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/sidebar/group-order/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/skills/[id]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/skills/installations/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/skills/operations/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/skills/reindex/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/skills/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/slash-commands/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/tasks/[taskId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/templates/[id]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/templates/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/todos/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/verification/runs/[runId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/verification/runs/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/capture/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/clear-composer/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/env/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/instances/opencode/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/logs/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/memos/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/messages/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/opencode/diff/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/opencode/session/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/opencode/share/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/resolve-target/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/respond/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/search/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/send/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update-plan/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/skills/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/timers/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/todos/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/tree/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/api/worktrees/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/login/page-03659dded846ef1d.js +1 -0
- package/.next/static/chunks/app/manifest.webmanifest/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/more/page-03867ab635d197c7.js +1 -0
- package/.next/static/chunks/app/proxy/[...path]/route-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/review/page-9a6d18ddcccbb63c.js +1 -0
- package/.next/static/chunks/app/worktrees/[id]/layout-e3626364434d521b.js +1 -0
- package/.next/static/chunks/app/worktrees/[id]/page-c07b23b6ca58091c.js +1 -0
- package/.next/static/chunks/app/worktrees/[id]/terminal/page-00ad5d9a62a71cab.js +1 -0
- package/.next/static/chunks/webpack-7e79064bfce988d7.js +1 -0
- package/.next/static/css/b6990f889f4f9515.css +1 -0
- package/.next/static/uulKcSOgyxChTo4SipUSF/_buildManifest.js +1 -0
- package/.next/trace +13 -13
- package/.next/types/app/api/remote/pair/route.ts +347 -0
- package/.next/types/app/api/worktrees/[id]/instances/opencode/route.ts +347 -0
- package/.next/types/app/api/worktrees/[id]/opencode/diff/route.ts +347 -0
- package/.next/types/app/api/worktrees/[id]/opencode/session/route.ts +347 -0
- package/.next/types/app/api/worktrees/[id]/opencode/share/route.ts +347 -0
- package/.next/types/routes.d.ts +6 -1
- package/.next/types/validator.ts +45 -0
- package/README.md +24 -4
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +66 -0
- package/dist/cli/commands/instances.d.ts.map +1 -1
- package/dist/cli/commands/instances.js +46 -1
- package/dist/cli/commands/interrupt.d.ts +25 -0
- package/dist/cli/commands/interrupt.d.ts.map +1 -0
- package/dist/cli/commands/interrupt.js +146 -0
- package/dist/cli/commands/remote.d.ts +248 -0
- package/dist/cli/commands/remote.d.ts.map +1 -0
- package/dist/cli/commands/remote.js +849 -0
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +11 -4
- package/dist/cli/commands/respond.d.ts.map +1 -1
- package/dist/cli/commands/respond.js +146 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +104 -0
- package/dist/cli/commands/wait.d.ts.map +1 -1
- package/dist/cli/commands/wait.js +39 -1
- package/dist/cli/config/agent-target-options.d.ts +12 -0
- package/dist/cli/config/agent-target-options.d.ts.map +1 -1
- package/dist/cli/config/agent-target-options.js +15 -1
- package/dist/cli/config/security-messages.d.ts +25 -0
- package/dist/cli/config/security-messages.d.ts.map +1 -1
- package/dist/cli/config/security-messages.js +43 -1
- package/dist/cli/docs/agent-operations.d.ts +1 -1
- package/dist/cli/docs/agent-operations.d.ts.map +1 -1
- package/dist/cli/docs/agent-operations.js +34 -0
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +12 -0
- package/dist/cli/types/api-responses.d.ts +375 -0
- package/dist/cli/types/api-responses.d.ts.map +1 -1
- package/dist/cli/types/index.d.ts +83 -0
- package/dist/cli/types/index.d.ts.map +1 -1
- package/dist/cli/types/index.js +31 -1
- package/dist/cli/utils/daemon.d.ts.map +1 -1
- package/dist/cli/utils/daemon.js +3 -0
- package/dist/cli/utils/env-setup.d.ts +24 -0
- package/dist/cli/utils/env-setup.d.ts.map +1 -1
- package/dist/cli/utils/env-setup.js +70 -0
- package/dist/cli/utils/qr-terminal.d.ts +54 -0
- package/dist/cli/utils/qr-terminal.d.ts.map +1 -0
- package/dist/cli/utils/qr-terminal.js +181 -0
- package/dist/cli/utils/remote-state.d.ts +123 -0
- package/dist/cli/utils/remote-state.d.ts.map +1 -0
- package/dist/cli/utils/remote-state.js +193 -0
- package/dist/cli/utils/vapid-keygen.d.ts +74 -0
- package/dist/cli/utils/vapid-keygen.d.ts.map +1 -0
- package/dist/cli/utils/vapid-keygen.js +111 -0
- package/dist/config/auth-config.d.ts +1 -1
- package/dist/config/auth-config.d.ts.map +1 -1
- package/dist/config/auth-config.js +5 -0
- package/dist/lib/cli-tools/types.d.ts +11 -1
- package/dist/lib/cli-tools/types.d.ts.map +1 -1
- package/dist/lib/detection/tools/verified-against.d.ts +14 -3
- package/dist/lib/detection/tools/verified-against.d.ts.map +1 -1
- package/dist/lib/detection/tools/verified-against.js +14 -3
- package/dist/lib/push/vapid.d.ts +178 -0
- package/dist/lib/push/vapid.d.ts.map +1 -0
- package/dist/lib/push/vapid.js +293 -0
- package/dist/lib/remote/cloudflare.d.ts +285 -0
- package/dist/lib/remote/cloudflare.d.ts.map +1 -0
- package/dist/lib/remote/cloudflare.js +619 -0
- package/dist/lib/remote/index.d.ts +17 -0
- package/dist/lib/remote/index.d.ts.map +1 -0
- package/dist/lib/remote/index.js +64 -0
- package/dist/lib/remote/provider-registry.d.ts +29 -0
- package/dist/lib/remote/provider-registry.d.ts.map +1 -0
- package/dist/lib/remote/provider-registry.js +73 -0
- package/dist/lib/remote/tailscale.d.ts +268 -0
- package/dist/lib/remote/tailscale.d.ts.map +1 -0
- package/dist/lib/remote/tailscale.js +546 -0
- package/dist/lib/remote/types.d.ts +127 -0
- package/dist/lib/remote/types.d.ts.map +1 -0
- package/dist/lib/remote/types.js +53 -0
- package/dist/lib/security/pairing-code.d.ts +182 -0
- package/dist/lib/security/pairing-code.d.ts.map +1 -0
- package/dist/lib/security/pairing-code.js +265 -0
- package/dist/lib/server/localhost-self-check.d.ts +203 -0
- package/dist/lib/server/localhost-self-check.d.ts.map +1 -0
- package/dist/lib/server/localhost-self-check.js +333 -0
- package/dist/server/locales/en/notifications.json +23 -1
- package/dist/server/locales/ja/notifications.json +23 -1
- package/dist/server/server.js +103 -0
- package/dist/server/src/config/auth-config.js +5 -0
- package/dist/server/src/config/image-extensions.js +244 -0
- package/dist/server/src/config/opencode-constants.js +69 -0
- package/dist/server/src/config/tmux-pane-config.js +100 -1
- package/dist/server/src/lib/cli-tools/base.js +33 -48
- package/dist/server/src/lib/cli-tools/opencode-config.js +12 -0
- package/dist/server/src/lib/cli-tools/opencode.js +435 -7
- package/dist/server/src/lib/cli-tools/start-availability.js +160 -0
- package/dist/server/src/lib/cmate-cli-tool-parser.js +328 -7
- package/dist/server/src/lib/cmate-parser.js +12 -0
- package/dist/server/src/lib/db/agent-instances-db.js +129 -0
- package/dist/server/src/lib/db/agent-session-cost-db.js +204 -0
- package/dist/server/src/lib/db/agent-session-cost-sampler.js +194 -0
- package/dist/server/src/lib/db/chat-db.js +33 -0
- package/dist/server/src/lib/db/db-instance.js +11 -0
- package/dist/server/src/lib/db/db.js +8 -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/v57-push-subscription-defaults-notice.js +54 -0
- package/dist/server/src/lib/db/migrations/v58-agent-session-costs.js +100 -0
- package/dist/server/src/lib/db/migrations/v59-opencode-instance-settings.js +71 -0
- package/dist/server/src/lib/db/push-subscriptions-db.js +56 -5
- package/dist/server/src/lib/detection/cli-patterns.js +17 -6
- package/dist/server/src/lib/detection/excerpt.js +48 -0
- package/dist/server/src/lib/detection/model-info-extractor.js +26 -3
- package/dist/server/src/lib/detection/opencode-modal-overlay.js +400 -0
- package/dist/server/src/lib/detection/opencode-pane-obstruction.js +181 -0
- package/dist/server/src/lib/detection/status-detector.js +7 -0
- package/dist/server/src/lib/detection/status-reason.js +20 -0
- package/dist/server/src/lib/detection/terminal-columns.js +94 -0
- package/dist/server/src/lib/detection/tools/opencode/detect.js +43 -0
- package/dist/server/src/lib/detection/tools/opencode/prompt.js +20 -0
- package/dist/server/src/lib/detection/tools/verified-against.js +14 -3
- package/dist/server/src/lib/detection/upstream-faults.js +7 -22
- package/dist/server/src/lib/hooks/agent-session-telemetry.js +324 -0
- package/dist/server/src/lib/hooks/pending-decision-kind.js +72 -0
- package/dist/server/src/lib/hooks/sources/define-source.js +88 -0
- package/dist/server/src/lib/hooks/sources/opencode/client.js +907 -2
- package/dist/server/src/lib/hooks/sources/opencode/diff.js +336 -0
- package/dist/server/src/lib/hooks/sources/opencode/history.js +480 -0
- package/dist/server/src/lib/hooks/sources/opencode/ingest.js +76 -7
- package/dist/server/src/lib/hooks/sources/opencode/launch-settings.js +222 -0
- package/dist/server/src/lib/hooks/sources/opencode/mappers.js +31 -0
- package/dist/server/src/lib/hooks/sources/opencode/payloads.js +45 -0
- package/dist/server/src/lib/hooks/sources/opencode/ports.js +16 -0
- package/dist/server/src/lib/hooks/sources/opencode/push.js +307 -0
- package/dist/server/src/lib/hooks/sources/opencode/reattach.js +284 -0
- package/dist/server/src/lib/hooks/sources/opencode/runtime.js +165 -2
- package/dist/server/src/lib/hooks/sources/opencode/source.js +46 -2
- package/dist/server/src/lib/hooks/sources/opencode/subscription.js +407 -4
- package/dist/server/src/lib/hooks/sources/opencode/transcript.js +383 -0
- package/dist/server/src/lib/hooks/structured-decision-response.js +460 -0
- package/dist/server/src/lib/job-executor.js +43 -20
- package/dist/server/src/lib/polling/response-checker.js +43 -16
- package/dist/server/src/lib/polling/structured-history-gate.js +75 -0
- package/dist/server/src/lib/prompt-answer-sender.js +153 -2
- package/dist/server/src/lib/push/delivery-health.js +237 -0
- package/dist/server/src/lib/push/failure-push-notifier.js +109 -7
- package/dist/server/src/lib/push/index.js +25 -1
- package/dist/server/src/lib/push/prompt-card-state.js +254 -14
- package/dist/server/src/lib/push/push-sender.js +63 -12
- package/dist/server/src/lib/push/resolution-push-notifier.js +15 -3
- package/dist/server/src/lib/push/vapid.js +264 -5
- package/dist/server/src/lib/push/waiting-push-notifier.js +7 -0
- package/dist/server/src/lib/server/localhost-self-check.js +333 -0
- package/dist/server/src/lib/session/agent-event-state.js +169 -4
- package/dist/server/src/lib/session/claude-executor.js +152 -15
- package/dist/server/src/lib/session/current-output-builder.js +182 -15
- package/dist/server/src/lib/session/opencode-session-api.js +214 -0
- package/dist/server/src/lib/session/opencode-session-recall.js +168 -0
- package/dist/server/src/lib/session/opencode-session-store.js +274 -0
- package/dist/server/src/lib/session/provisional-turn.js +54 -1
- package/dist/server/src/lib/session/send-user-message.js +6 -5
- package/dist/server/src/lib/session/structured-prompt.js +53 -2
- package/dist/server/src/lib/skills/compatibility-matrix.js +50 -1
- package/dist/server/src/lib/tmux/tmux.js +74 -4
- package/dist/server/src/lib/verification/gate-runner.js +71 -8
- package/dist/server/src/types/agent-session.js +63 -0
- package/dist/server/src/types/agent-transcript.js +80 -0
- package/dist/server/src/types/opencode-export.js +228 -0
- package/dist/server/src/types/opencode-instance-settings.js +140 -0
- package/dist/server/src/types/opencode-share.js +111 -0
- package/dist/server/src/types/terminal-keys.js +69 -1
- package/dist/types/cli-tool-contracts.d.ts +48 -0
- package/dist/types/cli-tool-contracts.d.ts.map +1 -1
- package/dist/types/terminal-keys.d.ts +89 -0
- package/dist/types/terminal-keys.d.ts.map +1 -0
- package/dist/types/terminal-keys.js +105 -0
- package/package.json +2 -1
- package/.next/server/chunks/1029.js +0 -1
- package/.next/server/chunks/1239.js +0 -1
- package/.next/server/chunks/1538.js +0 -7
- package/.next/server/chunks/2546.js +0 -1
- package/.next/server/chunks/2689.js +0 -13
- package/.next/server/chunks/3292.js +0 -1
- package/.next/server/chunks/3417.js +0 -1
- package/.next/server/chunks/3736.js +0 -1
- package/.next/server/chunks/4423.js +0 -1
- package/.next/server/chunks/4444.js +0 -32
- package/.next/server/chunks/4565.js +0 -3
- package/.next/server/chunks/467.js +0 -1
- package/.next/server/chunks/4905.js +0 -5
- package/.next/server/chunks/552.js +0 -19
- package/.next/server/chunks/5998.js +0 -74
- package/.next/server/chunks/6919.js +0 -1
- package/.next/server/chunks/7970.js +0 -229
- package/.next/server/chunks/8536.js +0 -1
- package/.next/server/chunks/9284.js +0 -1
- package/.next/static/9IXgWfBUtnEnRqnbmErTp/_buildManifest.js +0 -1
- package/.next/static/chunks/3361-5d6e93fba8a92bc1.js +0 -1
- package/.next/static/chunks/5229-1f5f19740a8d6c11.js +0 -1
- package/.next/static/chunks/6271.295ced91b6335f18.js +0 -1
- package/.next/static/chunks/6381-8cfe50a5ca5425b1.js +0 -1
- package/.next/static/chunks/8521-c43994fb58501d13.js +0 -1
- package/.next/static/chunks/app/api/app/update/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/app/update-check/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/conversation/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/current-output/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/messages/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/session/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/start/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/terminal/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/assistant/tools/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/auth/login/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/auth/logout/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/auth/status/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/capabilities/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/daily-summary/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/daily-summary/status/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/external-apps/[id]/health/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/external-apps/[id]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/external-apps/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/fs/browse/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/fs/recent-paths/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/hooks/agent-event/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/hooks/claude-done/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/hooks/permission-request/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/metrics/vibe/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/ollama/models/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/push/escalation/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/push/subscriptions/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/push/vapid/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/todos/[todoId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/[id]/todos/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/clone/[jobId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/clone/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/excluded/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/restore/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/scan/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/sync/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/repositories/validate-path/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/sidebar/group-order/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/skills/[id]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/skills/installations/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/skills/operations/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/skills/reindex/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/skills/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/slash-commands/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/tasks/[taskId]/cancel/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/tasks/[taskId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/templates/[id]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/templates/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/todos/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/verification/runs/[runId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/verification/runs/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/auto-yes/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/capture/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/clear-composer/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/cli-tool/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/cmate/schedules/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/current-output/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/env/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/[logId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/execution-logs/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/files/[...path]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/create/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branch/delete/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/branches/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/checkout/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/commit/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/diff/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/fetch/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/log/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/pull/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/push/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/reset/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/revert/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/show/[commitHash]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stage/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/staged/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/[index]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/apply/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/pop/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/push/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/stash/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/status/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/unstage/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/git/working-diff/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/interrupt/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/kill-session/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/logs/[filename]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/logs/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/marp-render/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/memos/[memoId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/memos/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/messages/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/prompt-response/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/resolve-target/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/respond/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/[scheduleId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/active/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/schedules/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/search/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/send/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/install/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/plan/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/[skillId]/update-plan/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/skills/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/slash-commands/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/special-keys/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/start-polling/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tasks/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/terminal/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/timers/history/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/timers/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/todos/[todoId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/todos/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tree/[...path]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/tree/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/upload/[...path]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/[runId]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/verify/runs/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/[id]/viewed/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/api/worktrees/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/login/page-adc51f0f7cbb7ac6.js +0 -1
- package/.next/static/chunks/app/manifest.webmanifest/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/more/page-3266dfa945972649.js +0 -1
- package/.next/static/chunks/app/proxy/[...path]/route-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/review/page-8f63aff862fee421.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/layout-6add0d88e2828c23.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-f7b3dfbe757dc6b8.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/terminal/page-a75fe180a7233b2b.js +0 -1
- package/.next/static/chunks/webpack-6a9668cf54a26eba.js +0 -1
- package/.next/static/css/928e5a8830fbf997.css +0 -1
- /package/.next/static/{9IXgWfBUtnEnRqnbmErTp → uulKcSOgyxChTo4SipUSF}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
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,p="horizontal"===o?"horizontal":"vertical",g="both"===o||"horizontal"===o,b="both"===o||"vertical"===o,v=(0,a.useRef)(null),[y,j]=(0,a.useState)(!1),[w,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,p)){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},j(!0)},[i,u,p,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}}g&&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,g,b,h]),I=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void j(!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?g&&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,j(!1),null==x||x()},[i,l,f,g,b,t,n,r,s,x]),M=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!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:w,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,23441))},23441:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>of});var a,r=n(95155),s=n(20063),l=n(15229),i=n(12115),o=n(67909),c=n(18955),d=n(37772),u=n(3005),m=n(43361),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})})}),p={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 g(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:p.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:p.menu})})})]})})}var b=n(22479),v=n(26983),y=n(59847),j=n(53842),w=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)(j.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(w.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]),p=(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&&p,"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))})}function S(e){return null!=e&&"unclassified"!==e.type}class T 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)(E,{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 E(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 I={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function M(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 I.fadeIn;case"fade-out":return I.fadeOut;default:return I.none}},[a]),isAnimating:c}}var A=n(92539),L=n(8269);let R={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"},P=(0,i.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:s,onDismiss:l,cliToolName:o}=e,{shouldRender:c,animationClass:d}=M({visible:n&&null!==t,duration:300}),u=(0,i.useId)(),m=n&&null!==t,h=(0,A.r)({active:m}),[x,f]=(0,i.useState)(0);(0,i.useEffect)(()=>{n||f(0)},[n]);let p=(0,i.useCallback)(e=>{let{deltaY:t}=e;f(t>0?t:0)},[]),g=(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:p,onSwipeDown:g,onSwipeEnd:b}),y=(0,i.useCallback)(e=>{h.current=e,v.current=e},[h,v]),j=(0,i.useCallback)(()=>{l&&l()},[l]),w=(0,i.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let k="animate-fade-out"===d;return(0,r.jsxs)(T,{componentName:"MobilePromptSheet",children:[(0,r.jsx)("div",{"data-testid":"prompt-overlay",onClick:j,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:w,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)(D,{promptData:t,answering:a,onRespond:s,labelId:u,cliToolName:o})})]})]})});function D(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,p]=(0,i.useState)(!1),g=(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==g?void 0:g.requiresTextInput)===!0,v=n||f,y=(0,i.useCallback)(async e=>{if(!v){p(!0);try{await a(e)}catch(e){}finally{p(!1)}}},[v,a]),j=(0,i.useCallback)(async()=>{if(!v&&null!==d){p(!0);try{let e=b&&h.trim()?h.trim():d.toString();await a(e)}catch(e){}finally{p(!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")}),S(t)&&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)(O,{promptData:t,disabled:v,selectedOption:d,onSelectOption:u,textInputValue:h,onTextInputChange:x,showTextInput:b,onSubmit:j})]})}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(R.base," ").concat(R.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(R.base," ").concat(o?R.defaultSelected:R.secondary),children:l("no")})]})}),O=(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(R.base," ").concat(R.primary),children:x("submit")})]})});var z=n(86651),_=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,A.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)(_.A,{size:18,"aria-hidden":"true"}),o("terminal.endSession")]})]})]})]}):null}var V=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 U(e,t){return"codex-skill"===e.source?"antigravity"===t?"/".concat(e.name):"$".concat(e.name):"/".concat(e.name)}function K(e,t){var n;return e.descriptionKey?t(e.descriptionKey):null!=(n=e.description)?n:""}function $(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:U(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:K(e,i)})]},e.name)})})]},e.category))})}function q(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 G=(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,p]=(0,i.useState)(0),g=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,j]=(0,i.useState)({x:0,y:0}),w=(0,c.c)("worktree"),k=(0,c.c)("common"),N=(0,i.useMemo)(()=>H(n,h,e=>K(e,w)),[n,h,w]),C=(0,i.useMemo)(()=>N.flatMap(e=>e.commands),[N]);(0,i.useEffect)(()=>{t&&(x(""),p(0),setTimeout(()=>{var e;null==(e=g.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(),p(e=>Math.min(e+1,C.length-1));break;case"ArrowUp":e.preventDefault(),p(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,j(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:q(a.left-v.current.x,a.width,window.innerWidth),y:q(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:w("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:w("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:g,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:w("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:w("slashCommands.enterCustomCommand")})]}),(0,r.jsx)($,{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:g,type:"text",value:h,onChange:e=>x(e.target.value),placeholder:w("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:w("slashCommands.enterCustomCommand")})]}),(0,r.jsx)($,{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"})," ",w("slashCommands.selectHint")]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded",children:"Esc"})," ",w("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)(Y,{})})});function Y(){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 Q=n(44309),X=n(50386),Z=n(62512),ee=n(4788),et=n(5917),en=n(75426),ea=n(77588);let er=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disabled:s=!1,onActionComplete:l,showToast:o}=e,d=(0,c.c)("worktree.opencodeSession"),u=(0,m.SC)(),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(null),k="opencode"===n,N=null!=a?a:n,C=(0,i.useCallback)(e=>{if(o){w(null),o(e,"error");return}w(e)},[o]),S=(0,i.useCallback)((e,t,n)=>"NO_OPENCODE_PORT"===e.code?d("errorNoPort"):"NO_OPENCODE_SESSION"===e.code?d(n):e.error||t||d("errorUnknown"),[d]),T=(0,i.useCallback)(async()=>{if(k)try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share?instance=").concat(encodeURIComponent(N)));if(!e.ok)return void p(null);p(await e.json())}catch(e){p(null)}},[k,t,N]);(0,i.useEffect)(()=>{T()},[T]);let E=(0,i.useCallback)(async e=>{x(e),w(null);try{let n=await fetch("/api/worktrees/".concat(t,"/opencode/session"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:N})});if(!n.ok){let t=await n.json().catch(()=>({}));console.error("[OpencodeSessionControls] action failed:",e,t.error||n.statusText),C(S(t,n.statusText,"errorNoSessionFork"));return}null==l||l(e),"list"!==e&&(b(null),T())}catch(e){console.error("[OpencodeSessionControls] request error:",e),C(d("errorRequestFailed"))}finally{x(null)}},[t,N,l,T,C,S,d]),I=(0,i.useCallback)(async()=>{if(await u({title:d("shareConfirmTitle"),description:d("shareConfirmBody"),confirmLabel:d("shareConfirmLabel"),variant:"danger"})){x("share"),w(null);try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:N})}),n=await e.json().catch(()=>({}));if(!e.ok||"string"!=typeof n.url){console.error("[OpencodeSessionControls] share failed:",n.error||e.statusText),C(S(n,e.statusText,"errorNoSessionShare")),T();return}b(n.url),y(!1),T()}catch(e){console.error("[OpencodeSessionControls] share request error:",e),C(d("errorRequestFailed"))}finally{x(null)}}},[u,d,t,N,T,C,S]),M=(0,i.useCallback)(async()=>{x("unshare"),w(null);try{let e=await fetch("/api/worktrees/".concat(t,"/opencode/share?instance=").concat(encodeURIComponent(N)),{method:"DELETE"});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[OpencodeSessionControls] unshare failed:",t.error||e.statusText),C(S(t,e.statusText,"errorNoSessionShare"));return}b(null),y(!1),T()}catch(e){console.error("[OpencodeSessionControls] unshare request error:",e),C(d("errorRequestFailed"))}finally{x(null)}},[t,N,T,C,S,d]),A=(0,i.useCallback)(async()=>{if(null!==g)try{await navigator.clipboard.writeText(g),y(!0),w(null)}catch(e){console.error("[OpencodeSessionControls] clipboard write failed:",e),C(d("errorCopyFailed"))}},[g,C,d]);if(!k)return null;let L=[{action:"new",icon:(0,r.jsx)(Q.A,{className:"h-5 w-5","aria-hidden":"true"})},{action:"list",icon:(0,r.jsx)(X.A,{className:"h-5 w-5","aria-hidden":"true"})},{action:"fork",icon:(0,r.jsx)(Z.A,{className:"h-5 w-5","aria-hidden":"true"})}],R="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";return(0,r.jsxs)("div",{className:"flex items-center gap-1","data-testid":"opencode-session-controls",children:[L.map(e=>{let{action:t,icon:n}=e;return(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void E(t),disabled:s||null!==h,className:R,"aria-label":d(t),title:d(t),"data-testid":"opencode-session-".concat(t),children:h===t?(0,r.jsx)(m.y$,{size:"md"}):n},t)}),(null==f?void 0:f.canShare)?(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void I(),disabled:s||null!==h,className:R,"aria-label":d("share"),title:d("share"),"data-testid":"opencode-session-share",children:"share"===h?(0,r.jsx)(m.y$,{size:"md"}):(0,r.jsx)(ee.A,{className:"h-5 w-5","aria-hidden":"true"})}):null,null!==g?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 rounded-full border border-warning-border bg-warning-subtle px-2 py-0.5 text-xs text-warning-foreground","data-testid":"opencode-share-result",children:[(0,r.jsx)("span",{className:"sr-only",children:d("sharePublicNotice")}),(0,r.jsx)("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"truncate text-accent-600 underline dark:text-accent-400",title:g,"data-testid":"opencode-share-url",children:g}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void A(),className:"flex-shrink-0 rounded-full p-1 text-muted-foreground hover:text-accent-600","aria-label":d("shareCopy"),title:d("shareCopy"),"data-testid":"opencode-share-copy",children:v?(0,r.jsx)(et.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}):(0,r.jsx)(en.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:()=>void M(),disabled:null!==h,className:"flex-shrink-0 rounded-full p-1 text-muted-foreground hover:text-danger-foreground","aria-label":d("unshare"),title:d("unshare"),"data-testid":"opencode-session-unshare",children:"unshare"===h?(0,r.jsx)(m.y$,{size:"sm"}):(0,r.jsx)(ea.A,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}):null,null!==j?(0,r.jsx)("span",{role:"alert",className:"flex min-w-0 items-center rounded-full border border-danger-border bg-danger-subtle px-2 py-0.5 text-xs text-danger-foreground",title:j,"data-testid":"opencode-session-error",children:(0,r.jsx)("span",{className:"truncate",children:j})}):null]})});var es=n(74385),el=n(38218),ei=n(19985);let eo="commandmate:draft-message:",ec="Queued (session busy) — your message will run after the current task finishes.";function ed(e,t){return"".concat(eo).concat(e,":").concat(t)}let eu=(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:p,onOptimisticSend:g}=e,b=(0,c.c)("worktree"),[v,y]=(0,i.useState)(""),[j,w]=(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),A=(0,i.useRef)(null),L=(0,i.useRef)(null),R=(0,i.useRef)(!1),P=(0,i.useRef)(null),D=(0,i.useRef)(null),F=(0,el.a)(),{groups:O,isCatalogStale:z}=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,V.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(es.I,t),()=>window.removeEventListener(es.I,t)},[e,f]);let p=(0,i.useMemo)(()=>n.flatMap(e=>e.commands),[n]),g=(0,i.useMemo)(()=>H(n,c),[n,c]),b=(0,i.useMemo)(()=>Object.values(h).some(e=>e.stale),[h]);return{groups:n,filteredGroups:g,allCommands:p,loading:r,error:l,filter:c,setFilter:d,refresh:(0,i.useCallback)(()=>{f()},[f]),cliTool:u,isCatalogStale:b}}(t,a),{attachedImage:_,fileInputRef:B,isUploading:K,error:$,acceptAttribute:q,openFileDialog:Y,handleFileSelect:Q,removeAttachment:X,resetAfterSend:Z}=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,ei.HB)(e.name.substring(t));if(!ei.Hv.includes(n))return"Unsupported file format: ".concat(n);if(e.size>ei.Fg){let e=ei.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:ei.F5,openFileDialog:d,handleFileSelect:u,removeAttachment:m,resetAfterSend:h}}(t,(0,i.useCallback)((e,t)=>V.y.uploadImageFile(e,t),[]));(0,i.useEffect)(()=>{try{0===u&&function(e){try{let t="".concat(eo).concat(e),n=window.localStorage.getItem(t);if(null===n)return;let a=ed(e,0);null===window.localStorage.getItem(a)&&window.localStorage.setItem(a,n),window.localStorage.removeItem(t)}catch(e){}}(t);let e=window.localStorage.getItem(ed(t,u));e?y(e):y("")}catch(e){}return()=>{D.current&&clearTimeout(D.current)}},[t,u]),(0,i.useEffect)(()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{try{let e=ed(t,u);v?window.localStorage.setItem(e,v):window.localStorage.removeItem(e)}catch(e){}},500)},[v,t,u]),(0,i.useEffect)(()=>{let e=A.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 ee=(0,i.useCallback)(async()=>{if(C||!v.trim()&&!_||j)return;let e=v.trim(),r=a||"claude",l={cliToolId:r};if(s&&s!==r&&(l.instanceId=s),_&&(l.imagePath=_.path),g){N(null),g(e,l),y(""),M(!1),Z();try{window.localStorage.removeItem(ed(t,u))}catch(e){}x&&(null==f||f(ec,"warning")),null==n||n(r);return}try{w(!0),N(null),await V.y.sendMessage(t,e,l),y(""),M(!1),Z();try{window.localStorage.removeItem(ed(t,u))}catch(e){}x&&(null==f||f(ec,"warning")),null==n||n(r)}catch(e){N((0,V.hS)(e))}finally{w(!1)}},[C,v,_,j,t,a,s,n,Z,u,x,f,g]),et=(0,i.useCallback)(async e=>{e.preventDefault(),await ee()},[ee]),en=(0,i.useCallback)(()=>{S(!0),R.current=!1,L.current&&clearTimeout(L.current)},[]),ea=(0,i.useCallback)(()=>{S(!1),R.current=!0,L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{R.current=!1},300)},[]),eu=(0,i.useCallback)(e=>{var t;y("".concat(U(e,a)," ")),E(!1),null==(t=A.current)||t.focus()},[a]),em=(0,i.useCallback)(()=>{var e;E(!1),M(!1),null==(e=A.current)||e.focus()},[]),eh=(0,i.useCallback)(e=>{E(!1),M(!0),y(e?"/".concat(e):"/"),setTimeout(()=>{var e;null==(e=A.current)||e.focus()},50)},[]),ex=(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]),ef=(0,i.useCallback)(e=>{let{keyCode:t}=e.nativeEvent;if(229!==t){if("Escape"===e.key&&T){e.preventDefault(),em();return}if(R.current&&"Enter"===e.key){R.current=!1;return}if("Enter"===e.key&&!C&&(!T||I)){if(F)return;e.shiftKey||(e.preventDefault(),ee())}}},[T,I,C,F,ee,em]);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||$}),_&&(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:_.file.name}),(0,r.jsx)("button",{type:"button",onClick:X,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:B,type:"file",accept:q,onChange:Q,className:"hidden","data-testid":"image-file-input"}),(0,r.jsxs)("form",{onSubmit:et,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:F?"flex flex-col gap-1":"flex items-center gap-2",children:[F&&(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:Y,disabled:K||j,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)(er,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l,showToast:f}),(0,r.jsx)(J,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l})]}),!F&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:Y,disabled:K||j,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:A,"data-testid":"message-input-textarea",value:v,onChange:ex,onKeyDown:ef,onCompositionStart:en,onCompositionEnd:ea,onFocus:h,placeholder:b("composer.placeholder"),disabled:j,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"}}),!F&&(0,r.jsx)(er,{worktreeId:t,cliToolId:a||"claude",instanceId:s,disabled:!l,showToast:f}),!F&&(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()||!!_)&&!j),disabled:!v.trim()&&!_||j,className:"flex-shrink-0 p-2 rounded-full transition-colors disabled:hover:bg-transparent ".concat((v.trim()||_)&&!j?"bg-accent-600 text-white hover:bg-accent-700 shadow-sm":"text-muted-foreground/50"),"aria-label":b("composer.sendMessage"),children:j?(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"})})})]})]}),(p||!F)&&(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:p}),!F&&(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)(G,{isOpen:T,groups:O,onSelect:eu,onClose:em,isMobile:F,onFreeInput:eh,isCatalogStale:z,cliToolId:a})]})});var em=n(9900);function eh(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,em.LK)}).catch(e=>{console.error("Failed to send special keys:",e)})},[e,t,n,a])}let ex=[{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"}],ef=[{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 ep(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=eh(t,n,a,s),h=(0,i.useCallback)(e=>{u(e[0]),setTimeout(()=>u(null),em.tX),m(e)},[m]),x=(0,i.useMemo)(()=>l?[...ex,...ef]:ex,[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 eg=n(36402),eb=n(17846),ev=n(69264),ey=n(27307),ej=n(24027),ew=n(51963),ek=n(39867);let eN="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 eC(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,A.r)({active:t}),p=(0,i.useCallback)(()=>{a(),n()},[a,n]),g=(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:p,className:eN,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:g,className:eN,children:[u?(0,r.jsx)(et.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(en.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:eN,children:[m?(0,r.jsx)(et.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(ew.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:eN,"aria-label":h("actions.downloadFile"),children:[(0,r.jsx)(ek.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),h("actions.downloadFile")]})]})]})]}):null}var eS=n(11063),eT=n(60322),eE=n(65229),eI=n(97624),eM=n(37354),eA=n(57828),eL=n(18514),eR=n(59854),eP=n(76246);let eD={highlightName:"terminal-search",currentHighlightName:"terminal-search-current",fallbackOverlayId:"terminal-search-fallback-overlay",fallbackOverlayBgColor:"rgba(255, 165, 0, 0.6)"},eF={highlightName:"history-search",currentHighlightName:"history-search-current",fallbackOverlayId:"history-search-fallback-overlay",fallbackOverlayBgColor:"rgba(59, 130, 246, 0.6)"};function eO(){return"undefined"!=typeof CSS&&null!==CSS&&"highlights"in CSS}function ez(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 e_(e){var t;eO()&&(CSS.highlights.delete(e.highlightName),CSS.highlights.delete(e.currentHighlightName)),null==(t=document.getElementById(e.fallbackOverlayId))||t.remove()}function eB(e,t,n,a){if(0===t.length)return void e_(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?ez(r,s.start,s.end):null;if(eO()){let e=[];t.forEach((t,a)=>{if(a===n)return;let s=ez(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 eV(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eF;e_(e)}function eW(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)},[]),p=(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 g=(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:p,nextMatch:g,prevMatch:b,setSearchQuery:r}}var eH=n(90487);function eU(){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 eK=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(eU,{})}),e$="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",eq=/^---\s*\nmarp:\s*true/;function eG(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)(eE.A,{className:"w-4 h-4"})})]})}let eJ="\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 eY(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,eg.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(eJ,"</body>")):t+eJ,[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 eH.A.highlight(t,{language:"html",ignoreIllegals:!0}).value}catch(e){return eH.A.highlightAuto(t).value}},[t]),p=(0,i.useMemo)(()=>Array.from({length:t.split("\n").length},(e,t)=>t+1),[t]),g=(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:p.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=g[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:x,sandbox:eS.Ko[l],title:u("htmlPreview.title",{path:n}),className:"w-full h-full border-0 bg-white"},"".concat(n,"-").concat(l))})]})}let eQ=(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),[p,g]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(null),[N,C]=(0,i.useState)(0),[S,T]=(0,i.useState)(!1),[E,I]=(0,i.useState)("viewer"),[M,A]=(0,i.useState)(!1),[L,R]=(0,i.useState)(null),[P,D]=(0,i.useState)(!1),F=(0,i.useRef)(null),O=(0,c.c)("worktree"),_=(0,eg.SC)(),B=u?null!=L?L:u.content:void 0,{searchOpen:V,searchQuery:W,searchMatches:H,searchCurrentIdx:U,searchInputRef:K,openSearch:$,closeSearch:q,nextMatch:G,prevMatch:J,setSearchQuery:Y}=eW(B),Q=(0,i.useMemo)(()=>!!((null==u?void 0:u.content)&&!u.isImage&&!u.isVideo&&!u.isPdf),[u]),X=(null==u?void 0:u.extension)==="md",Z=(0,i.useCallback)(async()=>{if(Q&&B)try{await (0,eT.l)(B),v(!0),setTimeout(()=>v(!1),em.pX)}catch(e){}},[Q,B]),ee=(0,i.useCallback)(async()=>{try{await (0,eT.l)(s),j(!0),setTimeout(()=>j(!1),em.pX)}catch(e){}},[s]),ea=(0,i.useCallback)(()=>{T(e=>!e)},[]);(0,i.useEffect)(()=>{if(0===H.length||!F.current)return;let e=H[U],t=F.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[U,H]),(0,i.useEffect)(()=>{if(!S||X)return;let e=e=>{"Escape"===e.key&&T(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[S,X]),(0,i.useEffect)(()=>{if(!t||!s){h(null),g(null),v(!1),I("viewer"),A(!1),R(null),D(!1),q();return}I("viewer"),A(!1),R(null),D(!1),(async()=>{f(!0),g(null);try{let t=await fetch("/api/worktrees/".concat(a,"/files/").concat((0,eP.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){g(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&&eq.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 er=!!(w&&w.length>0),es=(0,i.useCallback)(e=>{R(e)},[]),el=(0,i.useCallback)((e,t)=>{h(e=>e?{...e,content:t}:e),R(t),null==l||l(e)},[l]),ei=(0,i.useCallback)(async()=>{(!P||await _({description:O("editor.unsavedCloseConfirm"),variant:"danger"}))&&n()},[P,_,O,n]);(0,i.useEffect)(()=>{if(!X||M)return;let e=e=>{"Escape"===e.key&&(V?q():S?T(!1):ei())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[X,M,V,S,ei]);let[eo,ec]=(0,i.useState)("");(0,i.useEffect)(()=>{"viewer"===E&&void 0!==B&&ec(B)},[E,B]),(0,i.useEffect)(()=>{if(!X||!t)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[X,t]);let ed=(0,i.useMemo)(()=>{if(!u||void 0===B||u.isImage||u.isVideo||u.isHtml||u.isPdf)return null;let e=Array.from({length:B.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:eH.A.highlight(B,{language:u.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:eH.A.highlightAuto(B).value}}},[u,B]),eu=()=>u?u.isImage?(0,r.jsx)(eb.a,{src:u.content,alt:u.path,mimeType:u.mimeType}):u.isVideo?(0,r.jsx)(ev.u,{src:u.content,mimeType:u.mimeType}):u.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(ey.PdfPreview,{dataUri:u.content,filePath:s,variant:"download"})}):u.isHtml?(0,r.jsx)(eY,{htmlContent:u.content,filePath:s}):eh():null,eh=()=>{if(!ed)return null;let e=new Set(H),t=H.length>0?H[U]:-1,n=ed.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:F,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:ed.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)})})})})},ex="/api/worktrees/".concat(a,"/files/").concat((0,eP.o)(s),"?download=1"),ef=s?s.split("/").pop()||s:"",ep=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:ex,download:ef,className:e,"aria-label":O("actions.downloadFile"),title:O("actions.download"),children:[(0,r.jsx)(ek.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:O("actions.download")})]})},eN=()=>(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)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ew.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:[Q&&(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"})}),Q&&(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)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(en.A,{className:"w-3.5 h-3.5"})}),ep("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:ea,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)(eI.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(eM.A,{className:"w-3.5 h-3.5"})})]})]}),eS=()=>(0,r.jsx)(eG,{searchInputRef:K,searchQuery:W,searchMatches:H,searchCurrentIdx:U,onQueryChange:Y,onPrev:J,onNext:G,onClose:q});if(X&&u&&!x&&!p){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:eR.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:ea,"aria-pressed":!0,"aria-label":O("actions.exitFullscreen"),className:e$,children:(0,r.jsx)(eI.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ei(),"aria-label":O("actions.close"),className:e$,children:(0,r.jsx)(eE.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)(eA.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)(eL.A,{className:"h-4 w-4"}),O("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>A(!0),"aria-label":O("fileViewer.moreActions"),className:e$,children:(0,r.jsx)(d.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:ea,"aria-pressed":!1,"aria-label":O("actions.fullscreen"),className:e$,children:(0,r.jsx)(eM.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ei(),"aria-label":O("actions.close"),className:e$,children:(0,r.jsx)(eE.A,{className:"h-5 w-5"})})]}),V&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eS()}),(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:V?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eh()}):er?w?(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," / ",w.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>C(e=>Math.min(w.length-1,e+1)),disabled:N===w.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:w[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)(ej.G8,{content:eo,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)(eK,{worktreeId:a,filePath:s,initialContent:u.content,embedded:!0,onSave:el,onDirtyChange:D,onContentChange:es,onOpenFile:o},s)})]}),(0,r.jsx)(eC,{open:M,onClose:()=>A(!1),onSearch:()=>{I("viewer"),$()},onCopyContent:Z,onCopyPath:ee,downloadUrl:ex,downloadName:ef,contentCopied:b,pathCopied:y})]})})}return S&&u&&!x&&!p?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:eR.M.MAXIMIZED_EDITOR},children:[eN(),V&&eS(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:eu()})]}):(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")})]}),p&&(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:p})]}),(0,r.jsx)("div",{className:"mt-3",children:ep("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&&!p&&(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:[eN(),V&&eS()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:eu()})]})]})})});var eX=n(36809),eZ=n(46892),e0=n(41898),e1=n(26232),e2=n(50857),e5=n(94442);function e4(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,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(""),[v,y]=(0,i.useState)(0),[j,w]=(0,i.useState)("all"),[k,N]=(0,i.useState)(!1),{showToast:C}=(0,e5.dj)(),S=(0,c.c)("worktree");(0,i.useEffect)(()=>{(async()=>{try{h(!0),p(null);let e=await V.y.getLogs(t);a(e)}catch(e){p((0,V.hS)(e))}finally{h(!1)}})()},[t]);let T=(0,i.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),E=async e=>{try{h(!0),p(null);let n=await V.y.getLogFile(t,e);d(n.content),l(e),b(""),y(0)}catch(e){p((0,V.hS)(e))}finally{h(!1)}},I=(0,i.useCallback)(async()=>{if(s)try{N(!0);let e=await V.y.getLogFile(t,s,{sanitize:!0});await (0,eT.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,V.hS)(e)}),"error")}finally{N(!1)}},[t,s,C,S]),M=(0,i.useMemo)(()=>{let e;if(!g||!o)return[];let t=RegExp((0,x.Nt)(g),"gi"),n=[];for(;null!==(e=t.exec(o));)n.push({index:e.index,length:e[0].length});return n},[g,o]);(0,i.useEffect)(()=>{y(0)},[g]);let A=()=>{M.length>0&&y(e=>(e+1)%M.length)},L=()=>{M.length>0&&y(e=>(e-1+M.length)%M.length)},R=(0,i.useMemo)(()=>{if(!o||!g||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,g,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"===j?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(m.$n,{variant:"claude"===j?"primary":"ghost",size:"sm",onClick:()=>w("claude"),children:S("logViewer.toolCount",{tool:"Claude",count:n.filter(e=>e.toLowerCase().includes("claude")).length})}),(0,r.jsx)(m.$n,{variant:"codex"===j?"primary":"ghost",size:"sm",onClick:()=>w("codex"),children:S("logViewer.toolCount",{tool:"Codex",count:n.filter(e=>e.toLowerCase().includes("codex")).length})}),(0,r.jsx)(m.$n,{variant:"gemini"===j?"primary":"ghost",size:"sm",onClick:()=>w("gemini"),children:S("logViewer.toolCount",{tool:"Gemini",count:n.filter(e=>e.toLowerCase().includes("gemini")).length})}),(0,r.jsx)(m.$n,{variant:"antigravity"===j?"primary":"ghost",size:"sm",onClick:()=>w("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"===j?S("logViewer.empty"):S("logViewer.emptyFiltered",{tool:j})}),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:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?L():A())},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:L,disabled:0===M.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(m.$n,{variant:"ghost",size:"sm",onClick:A,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:g&&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&&g&&0===M.length&&o&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:g})})]})]})]})}function e3(){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 V.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 e6=n(31166);function e8(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,p]=(0,i.useState)(null),g=(0,i.useRef)(!1),b="global"===l,v="npx"===l,y=b||v,j=v?"npx commandmate@latest":"commandmate update",w=(0,i.useCallback)(async()=>{m("starting");try{let e=await V.GQ.startUpdate();x(e.logPath),m(e.willRestart?"updating":"no-restart")}catch(e){e instanceof V.hD&&400===e.status?p(o("update.errorNotGlobal")):e instanceof V.hD&&409===e.status?p(o("update.errorInProgress")):p(o("update.errorGeneric")),m("error")}},[o]);return((0,i.useEffect)(()=>{if("updating"!==d)return;let e=!1,t=Date.now();g.current=!1;let n=setInterval(async()=>{if(e)return;if(Date.now()-t>3e5)return void m("timeout");let n=await V.GQ.ping();if(!e){if(!n){g.current=!0;return}g.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)(e6.$,{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:j})]}),"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:j})]}),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)(eg.TM,{isOpen:"confirming"===d,title:o("update.confirmTitle"),description:o("update.confirmDescription",{version:null!=n?n:""}),confirmLabel:o("update.confirmButton"),onConfirm:w,onCancel:()=>m("idle")})]}):null}function e9(e){let{version:t,className:n}=e,a=(0,c.c)("worktree"),{data:s,loading:l}=e3(),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)(e8,{...o})]})}let e7="https://github.com/Kewton/CommandMate",te="".concat(e7,"/issues"),tt="".concat(e7,"/issues/new"),tn="".concat(tt,"?template=bug_report.md"),ta="".concat(tt,"?template=feature_request.md"),tr="".concat(tt,"?template=question.md");function ts(e){let{className:t}=e,n=(0,c.c)("worktree"),a=[{href:tn,label:n("feedback.bugReport")},{href:ta,label:n("feedback.featureRequest")},{href:tr,label:n("feedback.question")},{href:te,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 tl=n(94465),ti=n(38606),to=n(54014),tc=n(24033);let td="application/x-commandmate-agent-instance",tu=(0,i.memo)(function(e){let{splitIndex:t,cliToolId:n,instanceId:a,instance:s,availableInstances:l,onInstanceChange:o,status:d="idle",agentModel:u,agentUsage:m,agentUsageDetail:x,onFocus:f,attaching:p=!1,headerExtras:g,terminal:b,footer:v,style:y,onDropInstance:j,draggedInstanceId:w}=e,k=(0,c.c)("worktree"),[N,C]=(0,i.useState)(null),S=null!=j,T=(0,i.useCallback)(()=>null==w||l.some(e=>e.id===w)?"allowed":"forbidden",[w,l]),E=(0,i.useCallback)(e=>{if(!S)return;e.preventDefault();let t=T();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",C(e=>e===t?e:t)},[S,T]),I=(0,i.useCallback)(e=>{if(!S)return;e.preventDefault();let t=T();C(e=>e===t?e:t)},[S,T]),M=(0,i.useCallback)(()=>{S&&C(null)},[S]),A=(0,i.useCallback)(e=>{if(!S)return;e.preventDefault(),C(null);let t=e.dataTransfer.getData(td);t&&(null==j||j(t))},[S,j]),L=(0,i.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),R=(0,i.useCallback)(()=>{f()},[f]),P="Terminal split ".concat(t+1),D=(0,to.sw)(null!=s?s:{cliTool:n}),F=k("terminal.selectInstance",{split:P});return(0,r.jsxs)("div",{role:"region","aria-label":P,"data-testid":"terminal-split-pane-".concat(t),"data-split-index":t,style:y,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===N?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===N?" ring-2 ring-accent-400":"forbidden"===N?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:R,onMouseDown:f,onDragOver:E,onDragEnter:I,onDragLeave:M,onDrop:A,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)(e1.rI,{children:[(0,r.jsxs)(e1.ty,{"data-testid":"cli-selector-".concat(t),"aria-label":F,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:D}),(0,r.jsx)(tc.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsx)(e1.SQ,{align:"start",className:"min-w-[10rem]",children:(0,r.jsx)(e1.Hr,{value:a,onValueChange:o,children:l.map(e=>(0,r.jsx)(e1.Ht,{value:e.id,children:(0,to.sw)(e)},e.id))})})]}),u&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(t),title:k("agentModel.modelLabel",{model:u}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none text-muted-foreground",children:u}),m&&(0,r.jsx)("span",{"data-testid":"split-agent-usage-".concat(t),title:null!=x?x:k("agentSession.chipLabel",{usage:m}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none tabular-nums text-muted-foreground",children:m}),g,(0,r.jsx)("button",{type:"button",onClick:L,"aria-label":"Search terminal output for ".concat(P),"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:[p?(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 ",D," session..."]}):null,b]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:v})]})});var tm=n(34681),th=n(20562),tx=n(8803),tf=n(46980),tp=n.n(tf),tg=n(62459),tb=n.n(tg);let tv="[... 古い出力を省略しました / older output truncated ...]",ty=new(tb())({fg:"#d1d5db",bg:"#1f2937",newline:!0,escapeXML:!0}),tj=/[\x40-\x7e]/;function tw(e){let t=function(e){if(e.length<=1048576)return e;let t=tv+"\n",n=1048576-t.length;if(n<=0)return tv.slice(0,1048576);let a=e.length-n,r=e.indexOf("\n",a);if(-1!==r&&r-a<=65536)return t+e.slice(r+1);let s=function(e,t){let n=e.lastIndexOf("\x1b",t-1);if(-1===n)return t;let a=e.slice(n+1,t);if(tj.test(a.slice(1)))return t;for(let n=t;n<e.length;n++)if(tj.test(e[n]))return n+1;return e.length}(e,a),l=e.charCodeAt(s);return l>=56320&&l<=57343&&(s+=1),t+e.slice(s)}(e.replace(/\0/g,"")),n=ty.toHtml(t);return tp().sanitize(n,{ALLOWED_TAGS:["span","br"],ALLOWED_ATTR:["style"],ALLOW_DATA_ATTR:!1})}let tk=/\x1b(?:\[[0-9;?]*)?$/,tN=/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\[[0-9;]*m/g;function tC(e){return e.replace(tN,"")}function tS(e){let t=e.match(tN);return t?t.join(""):""}function tT(e){return""===tC(e).trim()}let tE=/\x1b\[([0-9;]*)m/g;function tI(e){return""===tC(e).trim()}function tM(e){return tI(e)&&""!==tC(e)&&function(e){let t;for(tE.lastIndex=0;null!==(t=tE.exec(e));)if(function(e){let t=0;for(;t<e.length;){let n=e[t];if(38===n||48===n||58===n){if(48===n)return!0;let a=e[t+1];t+=5===a?3:2===a?5:2;continue}if(n>=40&&n<=47||n>=100&&n<=107)return!0;t+=1}return!1}(t[1].split(";").filter(e=>""!==e).map(e=>Number(e)).filter(e=>Number.isInteger(e))))return!0;return!1}(e)}function tA(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:"✕"})]})}let tL=new Set(["claude","codex","opencode"]),tR=new Set(["opencode"]),tP=new Set(["opencode"]),tD=/\x1b\[[0-9;]*m/g;function tF(e){return{compactTuiLayoutPadding:tL.has(e),preservePaintedPanelRows:tR.has(e),mobileWrapMode:tP.has(e)?"frame":"viewport"}}function tO(){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 tz=(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,preservePaintedPanelRows:u=!1,wrapMode:m="viewport",className:h=""}=e,{scrollRef:x,autoScroll:f,handleScroll:p,scrollToBottom:g,scrollToTop:b}=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}),v=null!=t?t:"",y=(0,i.useMemo)(()=>d?u?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(""===e)return"";let{isStructuralRow:n}=t,a=e.split("\n"),r=[],s=!1,l=0,i=e=>{var t;return tI(e)&&!(null!=(t=null==n?void 0:n(e))&&t)};for(;l<a.length;){if(!i(a[l])){r.push(a[l]),s=!0,l++;continue}let e=l;for(;e<a.length&&i(a[e]);)e++;let t=e-l,n=!s,o=e>=a.length;if(!n&&!o)if(t<=2)for(let t=l;t<e;t++)r.push(a[t]);else r.push(tS(a.slice(l,e).join("")));l=e}return r.join("\n")}(v,{isStructuralRow:tM}):function(e){if(""===e)return"";let t=e.split("\n"),n=[],a=!1,r=0;for(;r<t.length;){if(!tT(t[r])){n.push(t[r]),a=!0,r++;continue}let e=r;for(;e<t.length&&tT(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(tS(t.slice(r,e).join("")));r=e}return n.join("\n")}(v):v,[d,u,v]),j=(0,i.useMemo)(()=>{if("frame"===m)return{minWidth:"".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:400,n=1;for(let a of e.split("\n")){let e=a.replace(tD,"").trimEnd().length;if(e>n&&(n=e),n>=t)return t}return n}(y),"ch")}},[m,y]),{isOpen:w,query:k,matchCount:N,currentIndex:C,isAtMaxMatches:S,openSearch:T,closeSearch:E,setQuery:I,nextMatch:M,prevMatch:A}=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)(""),p=o.length,g=(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}=g(e);if(c(t),u(0),h(a),n.current)if(t.length>0){var r;r=n.current,eB(r,t,0,eD)}else e_(eD)},[g,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)},[]),j=(0,i.useCallback)(()=>{r(!1),l(""),f.current="",c([]),u(0),h(!1),x.current&&clearTimeout(x.current),e_(eD)},[]),w=(0,i.useCallback)(()=>{0!==p&&u(e=>{let t=(e+1)%p;return n.current&&o.length>0&&eB(n.current,o,t,eD),t})},[p,o,n]),k=(0,i.useCallback)(()=>{0!==p&&u(e=>{let t=(e-1+p)%p;return n.current&&o.length>0&&eB(n.current,o,t,eD),t})},[p,o,n]);return(0,i.useEffect)(()=>{f.current.length<2||b(f.current)},[t,b]),(0,i.useEffect)(()=>()=>{x.current&&clearTimeout(x.current),e_(eD)},[]),{isOpen:a,query:s,matchCount:p,currentIndex:d,isAtMaxMatches:m,openSearch:y,closeSearch:j,setQuery:v,nextMatch:w,prevMatch:k}}({output:y,containerRef:x}),L=(0,i.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),T())},[T]);(0,i.useEffect)(()=>{let e=()=>T();return window.addEventListener("terminal-search-open",e),()=>window.removeEventListener("terminal-search-open",e)},[T]);let[R,P]=(0,i.useState)(()=>y?[{key:0,html:tw(y)}]:[]),D=(0,i.useRef)(y),F=(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(tk),a=n?e.length-n[0].length:e.length;return{mode:"append",text:t,appended:t.slice(a),retainedLength:a}}(D.current,y);if(D.current=y,"noop"===e.mode)return;let t="append"===e.mode&&e.appended.length>1048576;if("append"===e.mode&&!t)return void P(t=>(F.current+=1,t.length>=400)?[{key:F.current,html:tw(y)}]:[...t,{key:F.current,html:tw(e.appended)}]);F.current+=1,P(y?[{key:F.current,html:tw(y)}]:[])},[y]);let[O,z]=(0,i.useState)(!1);(0,i.useEffect)(()=>{a?z(!1):n&&z(!0)},[a,n]);let _=!t,B=_&&a,V=_&&!a&&!n&&O,W=(0,i.useRef)(!1);(0,i.useEffect)(()=>{c&&(W.current=!0)},[c]),(0,i.useEffect)(()=>{if(x.current){if(W.current&&c&&y){x.current.scrollTo({top:0,behavior:"instant"}),W.current=!1;return}!c&&f&&x.current.scrollTo({top:x.current.scrollHeight,behavior:"instant"})}},[R,y,f,c,x]);let H=(0,i.useMemo)(()=>["terminal","font-mono","text-sm","p-4","rounded-lg","overflow-y-auto","frame"===m?"overflow-x-auto":"overflow-x-hidden","bg-gray-900","text-gray-300","border","border-gray-700","h-full",n?"active":"",h].filter(Boolean).join(" "),[n,h,m]),[U,K]=(0,i.useState)(!1),$=(0,i.useRef)(null),q=(0,i.useCallback)(()=>{K(!0),$.current&&clearTimeout($.current),$.current=setTimeout(()=>K(!1),1500)},[]);(0,i.useEffect)(()=>()=>{$.current&&clearTimeout($.current)},[]);let G=(0,i.useCallback)(()=>{p(),q()},[p,q]),J=["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",U?"opacity-100":"opacity-60"].join(" ");return(0,r.jsxs)("div",{className:"relative h-full flex flex-col",children:[w&&(0,r.jsx)("div",{className:"absolute top-2 right-2 z-10",children:(0,r.jsx)(tA,{query:k,onQueryChange:I,matchCount:N,currentIndex:C,onNext:M,onPrev:A,onClose:E,isAtMaxMatches:S})}),(0,r.jsxs)("div",{ref:x,role:"log","aria-live":"polite","aria-label":"Terminal output",className:H,onScroll:G,onKeyDown:L,tabIndex:0,children:[(0,r.jsx)("div",{className:"frame"===m?"whitespace-pre w-max":"whitespace-pre-wrap break-words",style:j,children:R.map(e=>(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:e.html}},e.key))}),B&&(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:"読込中..."}),V&&(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)(tO,{})]}),f?(0,r.jsx)("button",{type:"button",onClick:b,className:J,"aria-label":"Scroll to top",children:(0,r.jsx)(th.A,{size:16,"aria-hidden":"true"})}):(0,r.jsx)("button",{type:"button",onClick:g,className:J,"aria-label":"Scroll to bottom",children:(0,r.jsx)(tx.A,{size:16,"aria-hidden":"true"})})]})}),t_=[{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"}],tB={key:"Escape",label:"Esc",ariaLabel:"Send Escape"},tV={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=eh(t,n,a,s),d="codex"===n?[...t_,tB,tV]:[...t_,tB],u=(0,i.useCallback)(e=>{o(e),setTimeout(()=>o(null),em.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)})]})}function tH(e){return""!==(null!=e?e:"").trim()}function tU(e){let{worktreeId:t,cliToolId:n,instanceId:a,composerText:s,onActionSent:l}=e,o=(0,c.c)("worktree"),[d,u]=(0,i.useState)(!1),m=eh(t,n,a,l),h=(0,i.useCallback)(()=>{m(["Enter"])},[m]),x=(0,i.useCallback)(()=>{u(!0);let e=a&&a!==n?{cliToolId:n,instanceId:a}:{cliToolId:n};fetch("/api/worktrees/".concat(encodeURIComponent(t),"/clear-composer"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(()=>{l&&setTimeout(l,em.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,l]);if(!tH(s))return null;let f=s.length>300?"".concat(s.slice(0,300),"…"):s;return(0,r.jsxs)("div",{"data-testid":"unsent-composer-bar",role:"region","aria-label":o("unsentComposer.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-info-subtle border border-info-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-info-foreground shrink-0",children:o("unsentComposer.label")}),(0,r.jsx)("code",{"data-testid":"unsent-composer-text",className:"flex-1 min-w-0 font-mono text-xs text-foreground break-all line-clamp-3 whitespace-pre-wrap",children:f}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:h,"aria-label":o("unsentComposer.run"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-info-foreground text-info-subtle hover:opacity-90 transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:o("unsentComposer.run")}),(0,r.jsx)("button",{type:"button",onClick:x,disabled:d,"aria-label":o("unsentComposer.clear"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-surface border border-info-border text-info-foreground hover:bg-muted disabled:opacity-50 disabled:cursor-not-allowed transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",children:o("unsentComposer.clear")})]})]})}let tK=RegExp("^\\p{M}$","u"),t$=/^([^\S\n]*)╹(▀{4,})/,tq=/^([^\S\n]*)[│┃]/;function tG(e,t){return"opencode"===e&&null!==function(e){let t=tC(e).split("\n"),n=-1,a=-1,r=-1;for(let e=0;e<t.length;e++){let s=t$.exec(t[e]);s&&(n=e,r=(a=s[1].length)+1+s[2].length)}if(-1===n)return null;let s=0,l="";for(let e=0;e<t.length;e++){let i=t[e];if(e!==n){let e=tq.exec(i);if(!e||e[1].length!==a)continue}let o=i.slice(function(e,t){if(e.length<=t)return e.length;let n=0,a=0;for(let r of e){let e=+!tK.test(r);if(1===e&&n>=t)break;n+=e,a+=r.length}return a}(i,r)).trim();""!==o&&(s+=1,""===l&&(l=function(e,t,n){let a=new TextEncoder;if(a.encode(e).length<=200)return e;let r=200-a.encode(n).length,s=0,l="";for(let t of e){let e=a.encode(t).length;if(s+e>r)break;s+=e,l+=t}return"".concat(l).concat(n)}(o,200,"…[truncated]")))}return s<2?null:{id:"opencode_sidebar",matchedText:l,boxRight:r,rows:s}}(null!=t?t:"")}function tJ(e){let{cliToolId:t,frame:n}=e,a=(0,c.c)("worktree");return(0,i.useMemo)(()=>tG(t,n),[t,n])?(0,r.jsxs)("div",{"data-testid":"opencode-sidebar-notice",role:"status","aria-label":a("opencodeSidebar.regionLabel"),className:"flex flex-wrap items-center gap-2 px-2 py-1.5 bg-warning-subtle border border-warning-border rounded-lg",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-warning-foreground shrink-0",children:a("opencodeSidebar.label")}),(0,r.jsx)("span",{className:"flex-1 min-w-0 text-xs text-foreground",children:a("opencodeSidebar.body")}),(0,r.jsx)("code",{"data-testid":"opencode-sidebar-notice-chord",className:"shrink-0 font-mono text-xs px-1.5 py-0.5 rounded bg-surface border border-warning-border text-warning-foreground",children:"ctrl+x b"})]}):null}let tY=["Up","Down","Left","Right","Enter","Escape","Tab","BTab","PageUp","PageDown","Home","End","q"],tQ=["a","l","n","t","m","g","u","r","c"],tX=["C-p","C-t"];[...tY,...tX,...tQ],[...tY,...tX,...tQ];var tZ=n(2317);let t0=e=>"boolean"==typeof e;function t1(e){return["C-x",e]}let t2=[{id:"agents",keys:t1("a"),notation:"ctrl+x a"},{id:"sessions",keys:t1("l"),notation:"ctrl+x l"},{id:"newSession",keys:t1("n"),notation:"ctrl+x n"},{id:"models",keys:t1("m"),notation:"ctrl+x m"},{id:"themes",keys:t1("t"),notation:"ctrl+x t"}],t5=[[{id:"agentNext",keys:["Tab"],notation:"tab"},{id:"agentPrev",keys:["BTab"],notation:"shift+tab"},{id:"commands",keys:["C-p"],notation:"ctrl+p"},{id:"variant",keys:["C-t"],notation:"ctrl+t"}],t2,[{id:"timeline",keys:t1("g"),notation:"ctrl+x g",sessionScoped:!0},{id:"undo",keys:t1("u"),notation:"ctrl+x u",sessionScoped:!0},{id:"redo",keys:t1("r"),notation:"ctrl+x r",sessionScoped:!0},{id:"compact",keys:t1("c"),notation:"ctrl+x c",sessionScoped:!0}],[{id:"pageUp",keys:["PageUp"],notation:"pgup"},{id:"pageDown",keys:["PageDown"],notation:"pgdn"},{id:"first",keys:["Home"],notation:"home"},{id:"last",keys:["End"],notation:"end"}]],t4=t5.reduce((e,t)=>e+t.length,0),t3=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,hasAgentSession:s,onKeysSent:l,compact:o=!1,collapsible:d=!1}=e,u=(0,c.c)("worktree"),[m,h]=(0,i.useState)(null),x=eh(t,n,a,l),{open:f,toggle:p}=function(){let{value:e,setValue:t,isAvailable:n}=(0,tZ.V)({key:"commandmate:mobile:opencodeQuickKeysOpen",defaultValue:!1,validate:t0});return{open:e,toggle:(0,i.useCallback)(()=>t(e=>!e),[t]),isPersistent:n}}(),g=(0,i.useId)(),b=(0,i.useCallback)(e=>{h(e.id),setTimeout(()=>h(null),em.tX),x([...e.keys])},[x]);if("opencode"!==n)return null;let v=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 ".concat(d?"px-1.5 pb-1.5":"py-1.5 bg-muted rounded-lg"),id:d?g:void 0,role:"toolbar","aria-label":u("opencodeQuickKeys.toolbarLabel"),"data-testid":"opencode-quick-keys",children:[d?null:(0,r.jsx)("span",{className:"text-xs text-muted-foreground mx-2",children:u("opencodeQuickKeys.caption")}),t5.map((e,t)=>(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[t>0?(0,r.jsx)("span",{className:"w-px h-6 bg-border mx-0.5","aria-hidden":"true"}):null,e.map(e=>{let t=u("opencodeQuickKeys.keys.".concat(e.id)),n=!0===e.sessionScoped&&!s;return(0,r.jsxs)("button",{type:"button",disabled:n,className:"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 disabled:opacity-50 disabled:cursor-not-allowed\n ".concat(m===e.id?"bg-accent-500 text-white border-accent-500 scale-95":"bg-surface dark:bg-surface-2 hover:bg-muted active:bg-muted disabled:hover:bg-surface"),"aria-label":"".concat(t," (").concat(e.notation,")"),title:n?u("opencodeQuickKeys.needsSession",{notation:e.notation}):"".concat(t," — ").concat(e.notation),"data-testid":"opencode-quick-key-".concat(e.id),onClick:()=>b(e),children:[t,o?null:(0,r.jsx)("span",{className:"ml-1.5 text-xs text-muted-foreground",children:e.notation})]},e.id)})]},e[0].id))]});return d?(0,r.jsxs)("div",{className:"bg-muted rounded-lg","data-testid":"opencode-quick-keys-disclosure",children:[(0,r.jsxs)("button",{type:"button",className:"w-full min-h-[44px] flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg touch-manipulation transition-colors hover:bg-surface-2 active:bg-surface-2 focus:outline-none focus:ring-2 focus:ring-ring","aria-expanded":f,"aria-controls":g,"aria-label":f?u("opencodeQuickKeys.hideKeys"):u("opencodeQuickKeys.showKeys"),"data-testid":"opencode-quick-keys-toggle",onClick:p,children:[(0,r.jsx)(tc.A,{className:"w-4 h-4 shrink-0 transition-transform duration-150 ".concat(f?"":"-rotate-90"),"aria-hidden":"true"}),(0,r.jsx)("span",{children:u("opencodeQuickKeys.toolbarLabel")}),(0,r.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:t4})]}),f?v:null]}):v});var t6=n(63365);let t8=/^[>❯]/,t9=/^\u203A/;function t7(e){return void 0===e||""===tC(e).trim()}function ne(e){let t=[],n={dim:!1,bold:!1},a=0;for(;a<e.length;){let r=e[a];if("\x1b"!==r){t.push({ch:r,dim:n.dim,bold:n.bold}),a++;continue}let s=e[a+1];if("["===s){let t=a+2;for(;t<e.length&&!/[A-Za-z]/.test(e[t]);)t++;if(t>=e.length)break;"m"===e[t]&&(n=function(e,t){let n=""===e?["0"]:e.split(";"),{dim:a,bold:r}=t;for(let e=0;e<n.length;e++){let t=""===n[e]?0:Number(n[e]);if(!Number.isNaN(t)){if(38===t||48===t||58===t){let t=""===n[e+1]||void 0===n[e+1]?-1:Number(n[e+1]);5===t?e+=2:2===t?e+=4:e+=1;continue}0===t||22===t?(a=!1,r=!1):1===t?r=!0:2===t&&(a=!0)}}return{dim:a,bold:r}}(e.slice(a+2,t),n)),a=t+1;continue}if("]"===s){let t=a+2;for(;t<e.length;){if("\x07"===e[t]){t++;break}if("\x1b"===e[t]&&"\\"===e[t+1]){t+=2;break}t++}a=t;continue}a+=2}return t}let nt=new Set(["claude","codex"]);function nn(e){let t=e.length;for(;t>0&&""===e[t-1].trim();)t--;return e.slice(0,t)}let na={session:null,context:null,diff:null};function nr(e){var t,n,a,r,s,l,i,o,c,d,u,m;let h=e.session,x=e.context,f=e.diff;return JSON.stringify([null!=(t=null==h?void 0:h.title)?t:null,null!=(n=null==h?void 0:h.agent)?n:null,null!=(a=null==h?void 0:h.model)?a:null,null!=(r=null==h?void 0:h.cost)?r:null,null!=(s=null==h?void 0:h.tokens)?s:null,null!=(l=null==x?void 0:x.tokens)?l:null,null!=(i=null==x?void 0:x.limit)?i:null,null!=(o=null==x?void 0:x.percent)?o:null,null!=(c=null==f?void 0:f.turnMessageId)?c:null,null!=(d=null==f?void 0:f.revertedMessageId)?d:null,null!=(u=null==f?void 0:f.files.map(ns))?u:null,null!=(m=null==f?void 0:f.revertedFiles.map(ns))?m:null])}function ns(e){var t,n;return"".concat(null!=(t=e.file)?t:"",":").concat(null!=(n=e.status)?n:"",":").concat(e.additions,":").concat(e.deletions)}function nl(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,composerText:"",attaching:!0,autoScroll:!0})),[c,d]=(0,i.useState)(()=>({visible:!1,data:null,messageId:null,answering:!1})),[u,m]=(0,i.useState)(na),h=(0,i.useRef)(0),x=(0,i.useRef)(n);x.current=n;let f=(0,i.useRef)(s);f.current=s;let p=(0,i.useRef)(c.visible);p.current=c.visible;let{connected:g,subscribe:b,unsubscribe:v,addListener:y}=(0,t6.xM)(),j=(0,i.useRef)(0),w=(0,i.useRef)(0),k=(0,i.useRef)(null),N=(0,i.useRef)(null),[C,S]=(0,i.useState)(!1),T=(0,i.useCallback)(()=>{S(!0),null!==N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{N.current=null,S(!1)},5e3)},[]),E=(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?(w.current+=1,null!=k.current||(k.current=Date.now())):(w.current=0,k.current=null);let r=w.current>=2&&null!==k.current&&Date.now()-k.current>=500,s=e.isRunning?function(e,t){if(!nt.has(t))return{text:"",state:"unsupported_tool"};let n=e.split("\n"),a=function(e,t){if("claude"===t){let t=function(e){var t;let n=e=>/^─{10,}$/.test(tC(e).trimEnd()),a=e.length-1;for(;a>=0&&""===e[a].trim();)a--;if(a<0)return null;let r=-1;for(let t=a;t>=Math.max(0,a-4);t--)if(n(e[t])){r=t;break}if(r<0)return null;let s=-1;for(let t=r-1;t>=Math.max(0,r-40);t--)if(n(e[t])){s=t;break}return s<0||!t8.test(tC(null!=(t=e[s+1])?t:""))?null:{openingSeparator:s,closingSeparator:r}}(e);return null===t?null:{firstRow:t.openingSeparator+1,lastRow:t.closingSeparator-1,glyph:t8}}let n=function(e){let t=e.length-1;for(;t>=0&&t7(e[t]);)t--;if(t<0)return null;for(let n=0;n<4&&t>=0;n++){let n=t,a=t;for(;a>0&&!t7(e[a-1]);)a--;if(function(e){if(void 0===e)return!1;let t=ne(e);if(0===t.length||"›"!==t[0].ch||t[0].dim||t.length>1&&" "!==t[1].ch)return!1;let n=t.slice(2).find(e=>" "!==e.ch);return void 0===n||!n.bold}(e[a]))return{firstRow:a,lastRow:Math.min(n,a+40-1)};for(t=a-1;t>=0&&t7(e[t]);)t--}return null}(e);return null===n?null:{firstRow:n.firstRow,lastRow:n.lastRow,glyph:t9}}(n,t);if(null===a)return{text:"",state:"no_composer"};let r=[],s=[];for(let e=a.firstRow;e<=a.lastRow;e++){var l;let t=function(e,t,n){if(t){let t=e.findIndex(e=>n.test(e.ch));if(t<0)return e;let a=t+1;return a<e.length&&/\s/.test(e[a].ch)&&a++,e.slice(a)}let a=0;for(;a<2&&a<e.length&&" "===e[a].ch;)a++;return e.slice(a)}(ne(null!=(l=n[e])?l:""),e===a.firstRow,a.glyph);r.push(t.filter(e=>!e.dim).map(e=>e.ch).join("").trimEnd()),s.push(t.map(e=>e.ch).join("").trimEnd())}let i=nn(r).join("\n");return""!==i.trim()?{text:i.slice(0,2e3),state:"content"}:{text:"",state:""===nn(s).join("\n").trim()?"empty":"ghost"}}(a,x.current).text:"";o(t=>{var n,l,i,o,c;let d=!1===e.isRunning,u=!!a||!!e.isRunning||d;return{...t,output:u?a:t.output,realtimeSnippet:null!=(n=e.realtimeSnippet)?n:"",isRunning:null!=(l=e.isRunning)&&l,isThinking:null!=(i=e.thinking)&&i,isSelectionListActive:null!=(o=e.isSelectionListActive)&&o,isPagerActive:null!=(c=e.isPagerActive)&&c,isUnclassifiedActive:r,composerText:s,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&&p.current&&d({visible:!1,data:null,messageId:null,answering:!1})},[]),I=(0,i.useCallback)(async()=>{let e=++h.current;try{var a,r,l,i,o,c;let d=await fetch("/api/worktrees/".concat(t,"/current-output?cliTool=").concat(n,"&instance=").concat(encodeURIComponent(s)));if(!d.ok)return;let u=await d.json();if(h.current!==e||x.current!==n||f.current!==s||u.cliToolId&&u.cliToolId!==n)return;E(u);let p={session:null!=(i=null==(a=u.structuredEvents)?void 0:a.session)?i:null,context:null!=(o=null==(r=u.structuredEvents)?void 0:r.sessionContext)?o:null,diff:null!=(c=null==(l=u.structuredEvents)?void 0:l.sessionDiff)?c:null};m(e=>nr(e)===nr(p)?e:p)}catch(t){if(h.current!==e||x.current!==n||f.current!==s)return;console.error("[useTerminalPanePolling] fetch error:",t)}},[t,n,s,E]),M="".concat(t,"::").concat(n,"::").concat(s),A=(0,i.useRef)(M);(0,i.useEffect)(()=>{A.current!==M&&(A.current=M,h.current+=1,j.current=0,w.current=0,k.current=null,S(!1),null!==N.current&&(clearTimeout(N.current),N.current=null),o(e=>({...e,output:"",realtimeSnippet:"",isRunning:!1,isThinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,composerText:"",attaching:!0})),d({visible:!1,data:null,messageId:null,answering:!1}),m(na))},[M]),(0,i.useEffect)(()=>{if(r)return b(t),()=>v(t)},[r,t,b,v]),(0,i.useEffect)(()=>{j.current=0,S(!1),null!==N.current&&(clearTimeout(N.current),N.current=null)},[g]),(0,i.useEffect)(()=>()=>{null!==N.current&&clearTimeout(N.current)},[]),(0,i.useEffect)(()=>{if(r)return y(e=>{var n;if("terminal_snapshot"!==e.type||e.worktreeId!==t||e.cliToolId!==x.current||e.instanceId!==f.current||e.version<=j.current)return;j.current=e.version,T();let a=e.output.split("\n").slice(-100).join("\n");E({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,y,E,T]),(0,i.useEffect)(()=>{if(r)return y(e=>{if("session_status_changed"===e.type)e.worktreeId===t&&!1===e.isRunning&&(null==e.instance||e.instance===f.current)&&(null==e.cliTool||e.cliTool===x.current)&&(j.current=0,E({fullOutput:"",realtimeSnippet:"",isRunning:!1,thinking:!1,isSelectionListActive:!1,isPagerActive:!1,isUnclassifiedActive:!1,isPromptWaiting:!1,promptData:null}))})},[r,t,y,E]),(0,i.useEffect)(()=>{if(!r)return;let e=!1,t=c.visible||l.isSelectionListActive||l.isPagerActive||l.isUnclassifiedActive,n=setInterval(()=>{"hidden"!==document.visibilityState&&I()},g&&C&&!t?15e3:l.isRunning||t?2e3:5e3);"undefined"!=typeof document&&"hidden"!==document.visibilityState&&I();let a=()=>{"visible"!==document.visibilityState||e||I()};return document.addEventListener("visibilitychange",a),()=>{e=!0,null!==n&&(clearInterval(n),n=null),document.removeEventListener("visibilitychange",a)}},[r,g,C,l.isRunning,l.isSelectionListActive,l.isPagerActive,l.isUnclassifiedActive,c.visible,I]);let L=(0,i.useCallback)(e=>{o(t=>t.autoScroll===e?t:{...t,autoScroll:e})},[]),R=(0,i.useCallback)(e=>{d(t=>({...t,answering:e}))},[]);return{terminal:l,prompt:c,agentSession:u,setAutoScroll:L,setPromptAnswering:R,clearPrompt:(0,i.useCallback)(()=>{d({visible:!1,data:null,messageId:null,answering:!1})},[]),refresh:(0,i.useCallback)(()=>I(),[I])}}let ni=(0,i.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,disableAutoFollow:s}=e,{terminal:l,prompt:i,agentSession:o,setAutoScroll:c,refresh:d}=nl({worktreeId:t,cliToolId:n,instanceId:a}),{compactTuiLayoutPadding:u,preservePaintedPanelRows:m,mobileWrapMode:h}=tF(n),x=l.isUnclassifiedActive&&!i.visible,f=tH(l.composerText),p=tG(n,l.realtimeSnippet||l.output);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","data-testid":"mobile-terminal-region",children:(0,r.jsx)(tz,{output:l.output,isActive:l.isRunning,isThinking:l.isThinking,autoScroll:l.autoScroll,onScrollChange:c,disableAutoFollow:s,compactTuiLayoutPadding:u,preservePaintedPanelRows:m,wrapMode:h,className:"h-full"})}),f?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tU,{worktreeId:t,cliToolId:n,instanceId:a,composerText:l.composerText,onActionSent:d})}):null,p?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tJ,{cliToolId:n,frame:l.realtimeSnippet||l.output})}):null,l.isRunning?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1","data-testid":"mobile-quick-keys-slot",children:(0,r.jsx)(t3,{worktreeId:t,cliToolId:n,instanceId:a,hasAgentSession:null!==o.session,onKeysSent:d,compact:!0,collapsible:!0})}):null,x?(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:d})}):null]})});var no=n(96195),nc=n(12181),nd=n(20508),nu=n(27937);function nm(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 nh=n(35299),nx=n(6132),nf=n(48314),np=n(54916),ng=n(51238),nb=n(22133),nv=n(10934),ny=n(5225),nj=n(55041),nw=n(8574);let nk={en:nw.c,ja:nj.ja};function nN(e){var t;return null!=(t=nk[e])?t:nw.c}var nC=n(83012);let nS=/(\/[^\s\n<>"']+\.[a-zA-Z0-9]+)/g;function nT(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 nE=(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(nS);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))})}),nI=(0,i.memo)(function(e){let{content:t,onFilePathClick:n}=e,a=(0,i.useMemo)(()=>{let e=e=>i.Children.map(e,e=>"string"==typeof e?(0,r.jsx)(nE,{content:e,onFilePathClick:n}):e);return{p:t=>{let{children:n}=t;return(0,r.jsx)("p",{children:e(n)})},li:t=>{let{children:n}=t;return(0,r.jsx)("li",{children:e(n)})},td:t=>{let{children:n}=t;return(0,r.jsx)("td",{children:e(n)})},th:t=>{let{children:n}=t;return(0,r.jsx)("th",{children:e(n)})},strong:t=>{let{children:n}=t;return(0,r.jsx)("strong",{children:e(n)})},em:t=>{let{children:n}=t;return(0,r.jsx)("em",{children:e(n)})}}},[n]),s=(0,i.useMemo)(()=>[nb.A],[]),l=(0,i.useMemo)(()=>[nv.A,ny.A],[]);return(0,r.jsx)(ng.oz,{remarkPlugins:s,rehypePlugins:l,components:a,children:t})});function nM(){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 nA=(0,i.memo)(function(e){let{message:t,onFilePathClick:n,onCopy:a,onInsertToMessage:s,onRetryPending:l,onDiscardPending:i}=e,o=(0,eX.Ym)(),d=(0,c.c)("worktree"),u=(0,c.c)("common"),m=nN(o),h=(0,nC.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)(nh.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)(nx.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)(nf.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)(eE.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)(np.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)(en.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)(nE,{content:t.content,onFilePathClick:n})})]})}),nL=(0,i.memo)(function(e){var t;let{message:n,index:a,total:s,isExpanded:l,onFilePathClick:o,onCopy:d,hasLongContent:u=!1,onToggleExpand:m}=e,h=(0,eX.Ym)(),x=(0,c.c)("worktree"),f=nN(h),p=(0,nC.bg)(n.timestamp,f),{text:g,isTruncated:b}=(0,i.useMemo)(()=>nT(n.content),[n.content]),v=l||!b?n.content:g,y="string"==typeof(t=n.requestId)&&t.startsWith("oc-turn:"),j=y&&b&&!l;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:x("conversation.assistant")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),s>1&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",a+1,"/",s,")"]}),(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===a&&u&&!!m&&(0,r.jsxs)("button",{type:"button",onClick:m,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":l,"aria-label":x(l?"conversation.collapseMessage":"conversation.expandMessage"),children:[(0,r.jsx)(tc.A,{size:12,className:"transition-transform ".concat(l?"rotate-180":""),"aria-hidden":"true"}),x(l?"conversation.collapse":"conversation.expand")]}),d&&(0,r.jsx)("button",{type:"button","data-testid":"copy-assistant-message",onClick:()=>d(n.content),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors","aria-label":x("conversation.copyMessage"),title:x("conversation.copy"),children:(0,r.jsx)(en.A,{size:14,"aria-hidden":"true"})})]})]}),y?(0,r.jsx)("div",{"data-message-id":n.id,"data-markdown":"true",className:["assistant-md text-xs text-foreground break-words [word-break:break-word] max-w-full overflow-x-hidden",j?"".concat("max-h-[3.25rem]"," overflow-y-hidden"):""].filter(Boolean).join(" "),children:(0,r.jsx)(nI,{content:n.content,onFilePathClick:o})}):(0,r.jsxs)("div",{"data-message-id":n.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)(nE,{content:v,onFilePathClick:o}),!l&&b&&(0,r.jsx)("span",{className:"text-muted-foreground",children:"..."})]})]})}),nR=(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)(nL,{message:e,index:c,total:t.length,isExpanded:n,onFilePathClick:a,onCopy:s,hasLongContent:l,onToggleExpand:o})]},e.id))})});function nP(){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 nD=(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,p=(0,i.useMemo)(()=>n.assistantMessages.some(e=>{let{isTruncated:t}=nT(e.content);return t}),[n.assistantMessages]),g=(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)(nP,{}),n.userMessage&&(0,r.jsx)(nA,{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)(nR,{messages:n.assistantMessages,isExpanded:s,onFilePathClick:a,onCopy:o,hasLongContent:p,onToggleExpand:g}):null:(0,r.jsx)("div",{className:"bg-muted/40 border-l-2 border-border p-3 border-t border-border",children:(0,r.jsx)(nM,{})})]})});function nF(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 p=(0,i.useCallback)(e=>{"Escape"===e.key&&d()},[d]),g=(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:g,onKeyDown:p,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 nO="commandmate.worktree.historyVisible",nz="commandmate.worktree.historyWidth";function n_(e){return Number.isFinite(e)?Math.min(60,Math.max(10,e)):40}let nB="commandmate:historyPaneStateChange";function nV(e){try{window.dispatchEvent(new CustomEvent(nB,{detail:e}))}catch(e){}}function nW(){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(nO);if("true"===e)return!0;if("false"===e)return!1}catch(e){}return!0}(),n=function(){try{let e=window.localStorage.getItem(nz);if(null===e)return 40;let t=Number(e);if(Number.isFinite(t))return n_(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(nB,e),()=>window.removeEventListener(nB,e)},[]),{visible:e,width:n,toggle:(0,i.useCallback)(()=>{let e=!r.current;t(e);try{window.localStorage.setItem(nO,String(e))}catch(e){}nV({visible:e,width:s.current})},[]),setWidth:(0,i.useCallback)(e=>{let t=n_(e);a(t);try{window.localStorage.setItem(nz,String(t))}catch(e){}nV({visible:r.current,width:t})},[])}}var nH=n(72115);let nU="worktree-history-pane",nK=(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":nU,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")})]})})}),n$=(0,i.memo)(function(e){let{history:t,terminal:n}=e,{visible:a,width:s,toggle:l,setWidth:o}=nW(),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:nU,"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)(T,{componentName:"HistoryPane",children:t})}),(0,r.jsx)(nH.f,{onResize:d,orientation:"horizontal",ariaValueNow:s})]}):(0,r.jsx)(nK,{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)(T,{componentName:"TerminalAndFilePanel",children:n})})]})}),nq=[50,100,150,200,250,500,1e3],nG="commandmate:historyDisplayLimit";function nJ(e){return nq.includes(e)}let nY="commandmate:historyUserOnly";function nQ(e){return"split-history-slot-".concat(e)}function nX(){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 nZ(){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 n0=["h-full","flex","flex-col","overflow-hidden","bg-surface-2","rounded-lg","border","border-border"],n1=(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:p,onHistoryDisplayLimitChange:g,historyUserOnly:b=!1,onHistoryUserOnlyChange:v,onCollapse:y,splitIndex:j,cliToolId:w}=e,k=(0,c.c)("worktree"),N=(0,i.useRef)(null),C=(0,i.useMemo)(()=>void 0===j?eF:{highlightName:"history-search-".concat(j),currentHighlightName:"history-search-current-".concat(j),fallbackOverlayId:"history-search-fallback-overlay-".concat(j),fallbackOverlayBgColor:eF.fallbackOverlayBgColor},[j]),S=void 0===j?"history-pane-collapse-button":"history-pane-collapse-button-".concat(j),T=void 0===j?nU:nQ(j),E=(0,i.useRef)(!0),I=(0,i.useRef)(-1),M=(0,i.useRef)(null),{pairs:A,isExpanded:L,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:D,matchCount:F,currentIndex:O,isAtMaxMatches:_,matchPositions:B,currentMatch:V,openSearch:W,closeSearch:H,setQuery:U,onCompositionStart:K,onCompositionEnd:$,nextMatch:q,prevMatch:G}=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),p=(0,i.useRef)(nm(t)),g=(0,i.useRef)(t);g.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)},[]),j=(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}}(g.current,e);o(t),d(0),m(n)},[]),w=(0,i.useCallback)(e=>{y(),x.current=e,f.current||(h.current=setTimeout(()=>{j(e)},300))},[y,j]),k=(0,i.useCallback)(e=>{s(e),w(e)},[w]),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(()=>{j(e)},300))},[y,j]);return(0,i.useEffect)(()=>{let e=nm(t);if(e===p.current)return;p.current=e;let n=x.current;n.length>=2&&j(n)},[t,j]),(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])}),J=P&&B.length>0,[Y,Q]=(0,i.useState)(new Set);(0,i.useEffect)(()=>{H()},[n]);let X=(0,i.useMemo)(()=>b?A.filter(e=>e.userMessage):A,[A,b]),Z=(0,i.useMemo)(()=>{let e=new Map;for(let t of X)for(let n of(t.userMessage&&e.set(t.userMessage.id,t.id),t.assistantMessages))e.set(n.id,t.id);return e},[X]),ee=(0,i.useMemo)(()=>{let e=new Map;return X.forEach((t,n)=>e.set(t.id,n)),e},[X]),et=(0,no.Te)({count:X.length,getScrollElement:()=>N.current,estimateSize:()=>160,overscan:6,getItemKey:e=>{var t,n;return null!=(n=null==(t=X[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=X.length;I.current=t,-1!==e&&t>e&&t>0&&E.current&&!J&&et.scrollToIndex(t-1,{align:"end"})},[X.length,J,et]),(0,i.useLayoutEffect)(()=>{if(!P||0===B.length)return void Q(e=>0===e.size?e:new Set);Q(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}(B,A))},[P,B,A]),(0,i.useEffect)(()=>{if(!P||!V)return;let e=Z.get(V.messageId);if(void 0===e)return;let t=ee.get(e);void 0!==t&&et.scrollToIndex(t,{align:"center"})},[P,V,Z,ee,et]),(0,i.useLayoutEffect)(()=>{let e=N.current;if(!e)return;if(!P||0===B.length)return void eV(C);let t=null;for(let a of B){var n;let r=(n=a.messageId,e.querySelector('[data-message-id="'.concat(CSS.escape(n),'"]')));if(!r)continue;let s=(null==V?void 0:V.messageId)===a.messageId,l=s?V.localIndex:-1;!function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eF;eB(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"}),()=>{eV(C)}},[P,B,V,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)(()=>[...n0,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,eT.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=L(e.id)||Y.has(e.id);return(0,r.jsx)("div",{className:a?"opacity-60":"",children:(0,r.jsx)(nD,{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);nJ(t)&&(null==g||g(t))},[g]),em=(0,i.useCallback)(()=>{P?H():W()},[P,W,H]);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:[g&&void 0!==p&&(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:p,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:nq.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)(nc.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(nd.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)(nu.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)(nF,{query:D,onQueryChange:U,matchCount:F,currentIndex:O,onNext:q,onPrev:G,onClose:H,isAtMaxMatches:_,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)(nX,{}):0===X.length?(0,r.jsx)(nZ,{}):0===en.length?(0,r.jsx)("div",{"data-testid":"history-fallback-list",children:X.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=X[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})})})]})}),n2={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};var n5=n(7504),n4=n(22198),n3=n(21786),n6=n(26754),n8=n(71360),n9=n(9286);function n7(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let ae=(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"),p=(0,i.useRef)(null),{shouldRender:g,isExiting:b}=(0,n9.O)(t,em.$B),v="".concat(n.x,":").concat(n.y,":").concat(s),[y,j]=(0,i.useState)(null),w=(null==y?void 0:y.key)===v?y:null;(0,i.useLayoutEffect)(()=>{if(!t)return;let e=p.current;if(!e)return;let a=e.getBoundingClientRect();j({key:v,left:n7(n.x,a.width,window.innerWidth),top:n7(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)(n5.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)(n4.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)(n3.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)(eL.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>k(u)},{id:"move",label:f("contextMenu.move"),icon:(0,r.jsx)(n6.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)(n8.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=p.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&&p.current){let e=p.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),g)?(0,r.jsx)("div",{ref:p,"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:eR.M.CONTEXT_MENU,left:"".concat(w?w.left:0,"px"),top:"".concat(w?w.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 at=n(30061);let an="commandmate.worktree.fileMetadataDisplay",aa={showSize:!0,showCreated:!1,showModified:!1},ar="commandmate:fileMetadataDisplayChange";function as(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 al=(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"})})}),ai=(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"})})}),ao=(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))})}),ac=(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-accent-500",scss:"text-accent-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"})})}),ad=(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:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=aa}=t,j=(0,c.c)("worktree"),[w,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?nN(v):void 0,[v]),I=(0,i.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(as(n.size))),n.birthtime){let t=(0,nC.bg)(new Date(n.birthtime),E);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,nC.bg)(new Date(n.mtime),E);t&&e.push("".concat(j("fileTree.metadata.modified"),": ").concat(t))}return e.length>0?e.join("\n"):void 0},[S,n.size,n.birthtime,n.mtime,E,j]),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]),A=(0,i.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),M())},[M]),L=(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:A,onContextMenu:L,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:w?(0,r.jsx)(u.y,{size:"xs",variant:"accent"}):(0,r.jsx)(al,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4"}),S?(0,r.jsx)(ai,{open:C}):(0,r.jsx)(ac,{extension:n.extension}),(0,r.jsx)(at.nR,{content:n.name,metadata:I,className:"flex-1 truncate text-sm text-foreground",children:"name"===g&&p?(0,r.jsx)(ao,{text:n.name,query:p}):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&&j("fileTree.itemCount",{count:n.itemCount}):as(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,nC.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,nC.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==p?void 0:p.trim()))return!0;if("name"===g){let t=p.toLowerCase();return!!e.name.toLowerCase().includes(t)||"directory"===e.type}if("content"===g&&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:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var au=n(26989);let am=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function ah(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 ax=(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:ah(n.left-u.current.x,n.width,window.innerWidth),y:ah(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)(au.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")}),am.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 af(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 ap(e){return"commandmate:file-tree-expanded:"+e}function ag(e){try{let t=window.localStorage.getItem(ap(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 ab=n(89559);let av=(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:p=!1,searchQuery:g,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,eX.Ym)(),k=(0,c.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,i.useState)(aa),n=(0,i.useRef)(e);n.current=e,(0,i.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(an);if(!t)return{...aa};return e=JSON.parse(t),"object"!=typeof e||null===e?{...aa}:{showSize:"boolean"==typeof e.showSize?e.showSize:aa.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:aa.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:aa.showModified}}catch(e){return{...aa}}}())},[]),(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(ar,e),()=>window.removeEventListener(ar,e)},[]);let a=(0,i.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(an,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(ar,{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,A]=(0,i.useState)([]),{expanded:L,setExpanded:R,resetExpanded:P}=function(e){let[t,n]=(0,i.useState)(()=>ag(e)),a=(0,i.useRef)(e);(0,i.useEffect)(()=>{a.current!==e&&(a.current=e,n(ag(e)))},[e]),(0,i.useEffect)(()=>{!function(e,t){try{let n=ap(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),[D,F]=(0,i.useState)(()=>new Map),O=(0,i.useRef)(null),z=(0,i.useRef)(L);z.current=L;let _=(0,i.useRef)(k);_.current=k;let B=(0,i.useRef)(new Set),{menuState:V,openMenu:W,closeMenu:H}=function(){let[e,t]=(0,i.useState)(n2),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(n2)},[]);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(_.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(z.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;A(e.items),F(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:_.current("fileTree.loadError"))}finally{K.current&&T(!1)}}},[U,R]);(0,i.useEffect)(()=>{$()},[$,f]);let q=(0,i.useRef)(null),G=(0,i.useRef)(!1);(0,i.useEffect)(()=>{q.current=null},[t]),af({intervalMs:5e3,enabled:p,onPoll:(0,i.useCallback)(async()=>{if(K.current&&!G.current){G.current=!0;try{let e=["",...Array.from(z.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{G.current=!1}}},[U,$])});let J=(0,i.useCallback)(async e=>{if(!(D.has(e)||B.current.has(e))){B.current.add(e);try{let t=await U(e);t&&F(n=>{let a=new Map(n);return a.set(e,t.items),a})}catch(e){console.error("[FileTreeView] Error loading children:",e)}finally{B.current.delete(e)}}},[D,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]),Q=(0,i.useCallback)(()=>{var e;P(),F(new Map),null==(e=O.current)||e.scrollTo({top:0}),null==j||j()},[P,j]),X=(0,i.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,x.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,i.useEffect)(()=>{X.size>0&&R(e=>{let t=new Set(e);for(let e of X)(D.has(e)||(null==v?void 0:v.some(t=>t.filePath.startsWith(e+"/"))))&&t.add(e);return t})},[X,D,v,R]);let Z=(0,i.useMemo)(()=>{if(!(null==g?void 0:g.trim()))return M;if("name"===b){let e=g.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=D.get(r);if(e&&t(e,r).length>0)return!0}return s});return t(M,"")}return"content"===b&&X.size>0?M.filter(e=>{if(X.has(e.name))return!0;if("directory"===e.type){for(let t of X)if(t.startsWith(e.name+"/")||t===e.name)return!0}return!1}):M},[M,g,b,X,D]);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)(n5.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)(n4.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==g?void 0:g.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:g})})}):(0,r.jsxs)("div",{ref:O,"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)(n5.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)(n4.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)(ax,{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-accent-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)(ab.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:Q,"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)(nf.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)(nx.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)(ad,{item:e,path:"",depth:0,worktreeId:t,expanded:L,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:W,searchQuery:g,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(ae,{isOpen:V.isOpen,position:V.position,targetPath:V.targetPath,targetType:V.targetType,onClose:H,onNewFile:a,onNewDirectory:s,onRename:l,onDelete:o,onUpload:d,onMove:u})]})}),ay=(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"})})}),aj=(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"})})}),aw=(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")})}),ak=(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]),p=(0,i.useCallback)(()=>{var e;d(),null==(e=h.current)||e.focus()},[d]),g=(0,i.useCallback)(e=>{if("Escape"===e.key)if(t)p();else{var n;null==(n=h.current)||n.blur()}},[t,p]);return(0,i.useEffect)(()=>{if(!(window.innerWidth<el.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)(ay,{})}),(0,r.jsx)("input",{ref:h,type:"text","data-testid":"search-input",value:t,onChange:f,onKeyDown:g,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)(aw,{}):t?(0,r.jsx)("button",{type:"button","data-testid":"search-clear",onClick:p,className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors","aria-label":x("search.clear"),children:(0,r.jsx)(aj,{})}):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 aN(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var aC=n(12108),aS=n(60850);let aT=(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:p=!0}=e,g=(0,c.c)("schedule"),b=(0,c.c)("worktree"),v=!!(h||x),[y,j]=(0,i.useState)(a.title),[w,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,aS.U)({value:y,saveFn:async e=>{await s(a.id,{title:e})}}),{isSaving:M,error:A,saveNow:L}=(0,aS.U)({value:w,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==A?void 0:A.message)?n:null,P=(0,i.useCallback)(e=>{j(e.target.value)},[]),D=(0,i.useCallback)(e=>{k(e.target.value)},[]),F=(0,i.useCallback)(()=>{I()},[I]),O=(0,i.useCallback)(()=>{L()},[L]),z=(0,i.useCallback)(()=>{l(a.id)},[a.id,l]),_=(0,i.useCallback)(()=>{w.trim()&&(null==m||m(w))},[w,m]),B=(0,i.useCallback)(async()=>{if(w.trim())try{await (0,eT.l)(w),C(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>C(!1),2e3)}catch(e){}},[w]);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:F,placeholder:g("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":g("memoMoveUp"),title:g("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)(aC.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:!p,"aria-label":g("memoMoveDown"),title:g("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)(tc.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),m&&(0,r.jsx)("button",{type:"button","data-testid":"insert-memo-content",onClick:_,"aria-label":g("memoInsertToMessage"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-accent-600 dark:hover:text-accent-400 transition-colors rounded",title:g("memoInsertToMessage"),children:(0,r.jsx)(np.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:B,"aria-label":g("memoCopyContent"),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-foreground transition-colors rounded",children:N?(0,r.jsx)(et.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(en.A,{className:"w-4 h-4"})}),(0,r.jsx)("button",{type:"button",onClick:z,"aria-label":g("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:w,onChange:D,onBlur:O,placeholder:g("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})]})}),aE=(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 aI(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 p=(0,i.useCallback)(e=>{"Escape"===e.key?d():"Enter"===e.key&&(e.preventDefault(),l())},[d,l]),g=(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:g,onKeyDown:p,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 aM=(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,eg.SC)(),[d,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(null),{query:N,matches:C,currentMatch:S,totalCount:T,setQuery:E,reset:I,navigateNext:M,navigatePrev:A,onCompositionStart:L,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)(aN(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)},[]),p=(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)},[]),g=(0,i.useCallback)(e=>{f(),d.current=e,u.current||(c.current=setTimeout(()=>{p(e)},300))},[f,p]),b=(0,i.useCallback)(e=>{a(e),g(e)},[g]),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]),j=(0,i.useCallback)(()=>{o(e=>0===x?-1:(e-1+x)%x)},[x]),w=(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(()=>{p(e)},300))},[f,p]);return(0,i.useEffect)(()=>{let e=aN(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=2&&p(n)},[t,p]),(0,i.useEffect)(()=>()=>{f(),d.current=""},[f]),{query:n,matches:r,currentMatch:l,totalCount:x,setQuery:b,reset:v,navigateNext:y,navigatePrev:j,onCompositionStart:w,onCompositionEnd:k}}({memos:d}),P=j&&N.length>0,D=P?C:d,F=(0,i.useCallback)(async()=>{x(!0),b(null);try{let e=await V.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,V.hS)(e))}finally{x(!1)}},[t]);(0,i.useEffect)(()=>{F()},[F]);let O=(0,i.useCallback)(async()=>{p(!0),y(null);try{let e=await V.$T.create(t,{title:s("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,V.hS)(e))}finally{p(!1)}},[t,s]),_=(0,i.useCallback)(async(e,n)=>{await V.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),B=(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 V.$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]),W=(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 V.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,V.hS)(e)),await F()}},[d,t,F]),H=(0,i.useCallback)(()=>{F()},[F]),U=(0,i.useCallback)(()=>{w(e=>(e&&I(),!e))},[I]),K=(0,i.useCallback)(()=>{w(!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")})]})}):g?(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:g}),(0,r.jsx)("button",{type:"button",onClick:H,"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:j?(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(aI,{query:N,onQueryChange:E,matchCount:T,currentIndex:S,onNext:M,onPrev:A,onClose:K,onCompositionStart:L,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===D.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:s("memoNoMatch")})}),D.map((e,t)=>(0,r.jsx)(aT,{memo:e,onUpdate:_,onDelete:B,onInsertToMessage:a,onMoveUp:P?void 0:()=>W(t,-1),onMoveDown:P?void 0:()=>W(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)(aE,{currentCount:d.length,maxCount:20,onAdd:O,isLoading:f,className:"mt-2"})]})});var aA=n(85872),aL=n(53292),aR=n(53482);let aP={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"},aD=i.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=(0,c.c)("common"),l=(0,eg.SC)(),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(""),[h,x]=(0,i.useState)(!0),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(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 aA.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){p(!0),b(null);try{let n=await aA.Ar.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{p(!1)}}},[u,f,t,a]),M=(0,i.useCallback)(async e=>{let n=function(e){let t=aA.KG.indexOf(e);return aA.KG[(t+1)%aA.KG.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await aA.Ar.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),E()}},[t,E,a]),A=(0,i.useCallback)(async e=>{if(await l({description:s("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await aA.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]),L=(0,i.useCallback)(e=>{y(e),w(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=j.trim();if(e&&!C){S(!0),b(null);try{let n=await aA.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,j,k,C,t,R,a]),D=(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 aA.Ar.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),E()}},[o,t,E,a]),F=(0,i.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),I())},[I]),O=(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:F,maxLength:aL.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")," ",O.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[T("doing")," ",O.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[T("done")," ",O.done]})]}),g&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:g}),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(aP[e.status]),children:T(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>L(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:()=>D(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:()=>D(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:()=>A(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)(tl.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:j,onChange:e=>w(e.target.value),maxLength:aL.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)(aR.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:aL.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===j.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 aF=n(95740),aO=n(66630),az=n(37586),a_=n(47650);function aB(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,a_.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:eR.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)(eE.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 aV=["default","acceptEdits","plan","dontAsk","bypassPermissions"],aW=["read-only","workspace-write","danger-full-access"],aH=["allow-all-tools","yolo"],aU=["--dangerously-skip-permissions"],aK=[],a$=[],aq=[],aG=[],aJ={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions"};function aY(e){switch(e){case"claude":return aV;case"codex":return aW;case"copilot":return aH;case"antigravity":return aU;case"gemini":return aK;case"vibe-local":return a$;case"opencode":return aq;default:return aG}}let aQ=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/;var aX=n(3199);let aZ=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],a0={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=aJ.claude)?a:"",model:"",agent:"",variant:"",continueSession:!1,title:""},a1="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",a2="block text-xs font-semibold text-foreground mb-1",a5="mt-1 text-xs text-danger-foreground";function a4(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)(aF.A,{size:14,"aria-hidden":"true"}),n]})}function a3(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)(tc.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 a6(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"),p=(0,el.a)(),g=(0,i.useMemo)(()=>u&&u.length>0?u:(0,to.lu)([...to.XH]),[u]),[b,v]=(0,i.useState)(a0),[y,j]=(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,m,h,x,f;if(!a)return;S(null),N(!1);let p=null!=(t=null==l?void 0:l.cliToolId)?t:a0.cliToolId;v({name:null!=(n=null==l?void 0:l.name)?n:a0.name,cronExpression:null!=(r=null==l?void 0:l.cronExpression)?r:a0.cronExpression,message:null!=(s=null==l?void 0:l.message)?s:a0.message,cliToolId:p,enabled:null!=(i=null==l?void 0:l.enabled)?i:a0.enabled,permission:null!=(o=null==l?void 0:l.permission)?o:a0.permission,model:null!=(c=null==l?void 0:l.model)?c:a0.model,agent:null!=(d=null==l?void 0:l.agent)?d:a0.agent,variant:null!=(u=null==l?void 0:l.variant)?u:a0.variant,continueSession:null!=(m=null==l?void 0:l.continueSession)?m:a0.continueSession,title:null!=(h=null==l?void 0:l.title)?h:a0.title});let b=g.find(e=>e.cliTool===p);j(null!=(f=null!=(x=null==b?void 0:b.id)?x:null==(e=g[0])?void 0:e.id)?f:p)},[a,l,g]),(0,i.useEffect)(()=>{a&&E(new Set(p?["basic"]:["basic","advanced","message"]))},[a,p]);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=aY(b.cliToolId),A=M.length>0,L=aX.Vt.has(b.cliToolId),R=aX.aN.has(b.cliToolId),P=!!o,D=(0,i.useMemo)(()=>{let e=b.name.trim();return e?e.length>100?f("edit.errorNameTooLong",{max:100}):aQ.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]),O=(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)(()=>L&&b.model.trim()?(0,aX.JY)(b.model.trim()).valid?null:f("edit.errorModelInvalid"):null,[L,b.model,f]),_=(0,i.useMemo)(()=>R&&b.agent.trim()?(0,aX.sd)(b.agent.trim(),"agent").valid?null:f("edit.errorAgentInvalid"):null,[R,b.agent,f]),B=(0,i.useMemo)(()=>R&&b.variant.trim()?(0,aX.sd)(b.variant.trim(),"variant").valid?null:f("edit.errorVariantInvalid"):null,[R,b.variant,f]),V=(0,i.useMemo)(()=>R&&b.title.trim()?(0,aX.kj)(b.title.trim()).valid?null:f("edit.errorTitleInvalid"):null,[R,b.title,f]),W=!D&&!F&&!O&&!z&&!_&&!B&&!V,H=(0,i.useCallback)(e=>{v(t=>({...t,cliToolId:e,permission:function(e){let t=aJ[e];if(void 0!==t)return t;let n=aY(e);return n.length>0?n[0]:""}(e),model:aX.Vt.has(e)?t.model:"",agent:aX.aN.has(e)?t.agent:"",variant:aX.aN.has(e)?t.variant:"",continueSession:!!aX.aN.has(e)&&t.continueSession,title:aX.aN.has(e)?t.title:""}))},[]),U=(0,i.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&(j(e),H(t.cliTool))},[g,H]),K=aZ.some(e=>e.value===b.cronExpression)?b.cronExpression:"custom",$=(0,i.useCallback)(e=>{"custom"!==e&&v(t=>({...t,cronExpression:e}))},[]),q=(0,i.useCallback)(e=>{null==d||d(e),h()},[d,h]),G=(0,i.useCallback)(async()=>{if(W&&!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:A?b.permission:"",model:L&&b.model.trim()?b.model.trim():void 0,agent:R&&b.agent.trim()?b.agent.trim():void 0,variant:R&&b.variant.trim()?b.variant.trim():void 0,continueSession:!!R&&!!b.continueSession||void 0,title:R&&b.title.trim()?b.title.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)}}},[W,k,s,b,A,L,R,o,x,h,f]),J=null!=(n=null==(t=g.find(e=>e.id===y))?void 0:t.alias)?n:(0,to.f_)(b.cliToolId),Y=b.name.trim()?"".concat(b.name.trim()," \xb7 ").concat(b.cronExpression):b.cronExpression,Q=[J,A?b.permission:null,L&&b.model.trim()?b.model.trim():null,R&&b.agent.trim()?"--agent ".concat(b.agent.trim()):null,R&&b.variant.trim()?"--variant ".concat(b.variant.trim()):null,R&&b.continueSession?"--continue":null].filter(Boolean).join(" \xb7 "),X=b.message.trim(),Z=X.length>32?"".concat(X.slice(0,32),"…"):X,ee=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,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:a1}),D&&(0,r.jsx)("p",{className:a5,"data-testid":"schedule-name-error",children:D})]}),(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)(a4,{testId:"schedule-cron-ask-ai",label:f("edit.askAiCron"),title:f("edit.askAiHint"),onClick:()=>q(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(a1," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":f("edit.cronPreset"),value:K,onChange:e=>$(e.target.value),className:"".concat(a1," sm:w-48"),children:[aZ.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:a5,"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")})]})]}),et=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,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=>U(e.target.value),className:a1,children:g.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),L&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,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:a1}),z&&(0,r.jsx)("p",{className:a5,"data-testid":"schedule-model-error",children:z})]}),R&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,htmlFor:"schedule-agent-input",children:f("edit.opencodeAgent")}),(0,r.jsx)("input",{id:"schedule-agent-input","data-testid":"schedule-agent-input",type:"text",value:b.agent,placeholder:f("edit.opencodeAgentPlaceholder"),onChange:e=>v(t=>({...t,agent:e.target.value})),className:a1}),_&&(0,r.jsx)("p",{className:a5,"data-testid":"schedule-agent-error",children:_})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,htmlFor:"schedule-variant-input",children:f("edit.opencodeVariant")}),(0,r.jsx)("input",{id:"schedule-variant-input","data-testid":"schedule-variant-input",type:"text",value:b.variant,placeholder:f("edit.opencodeVariantPlaceholder"),onChange:e=>v(t=>({...t,variant:e.target.value})),className:a1}),B&&(0,r.jsx)("p",{className:a5,"data-testid":"schedule-variant-error",children:B})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,htmlFor:"schedule-title-input",children:f("edit.opencodeTitle")}),(0,r.jsx)("input",{id:"schedule-title-input","data-testid":"schedule-title-input",type:"text",value:b.title,placeholder:f("edit.opencodeTitlePlaceholder"),onChange:e=>v(t=>({...t,title:e.target.value})),className:a1}),V&&(0,r.jsx)("p",{className:a5,"data-testid":"schedule-title-error",children:V})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(m.Sc,{"data-testid":"schedule-continue-toggle",checked:b.continueSession,onCheckedChange:e=>v(t=>({...t,continueSession:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:f("edit.opencodeContinue")})]})]}),A&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:a2,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:a1,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),en=(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)(a4,{testId:"schedule-message-ask-ai",label:f("edit.askAiMessage"),title:f("edit.askAiHint"),onClick:()=>q(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(a1," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[O?(0,r.jsx)("p",{className:a5,"data-testid":"schedule-message-error",children:O}):(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})})]})]}),ea=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(a3,{id:"basic",title:f("edit.sectionBasic"),summary:Y,icon:(0,r.jsx)(w.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:I,children:ee}),(0,r.jsx)(a3,{id:"advanced",title:f("edit.sectionAdvanced"),summary:Q,icon:(0,r.jsx)(aO.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:I,children:et}),(0,r.jsx)(a3,{id:"message",title:f("edit.sectionMessage"),summary:Z,icon:(0,r.jsx)(az.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:I,children:en}),C&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:C})]}),er=(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 G(),disabled:!W||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")})]}),es=P?f("edit.titleEdit"):f("edit.titleCreate");return p?(0,r.jsx)(aB,{isOpen:a,onClose:h,title:es,footer:er,children:ea}):(0,r.jsx)(tl.a,{isOpen:a,onClose:h,title:es,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[ea,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:er})]})})}function a8(e){return new Date(e).toLocaleString()}function a9(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 a7=(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:[a8(e.started_at),a9(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",a9(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 re(){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 rt(){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 rn=(0,i.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:s}=e,l=(0,c.c)("schedule"),o=(0,eg.SC)(),[d,u]=(0,i.useState)([]),[h,x]=(0,i.useState)([]),[f,p]=(0,i.useState)([]),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(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),A=(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();p(e.schedules||[])}else p([])}catch(e){y(e instanceof Error?e.message:"Failed to fetch data")}finally{b(!1)}},[t]);(0,i.useEffect)(()=>{A()},[A]);let L=(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=(0,aX.I_)(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 L(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)},[L]),D=(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 A()}catch(e){console.error("Failed to delete schedule:",e)}},[t,l,A,o]),F=(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 A()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,A]);return g?(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 A(),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"===j,onClick:()=>w("schedules"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("schedules"===j?"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"===j,onClick:()=>w("logs"),className:"-mb-px px-3 py-2 text-sm font-medium border-b-2 transition-colors ".concat("logs"===j?"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"===j?(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"),": ",a8(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 F(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)(re,{})}),(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 D(e.name),className:"p-1.5 text-muted-foreground hover:text-danger-foreground hover:bg-danger-subtle rounded transition-colors",children:(0,r.jsx)(rt,{})})]})]}),(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"),": ",a8(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(a7,{worktreeId:t,logs:d})}),(0,r.jsx)(a6,{isOpen:C,worktreeId:t,initialValues:T,originalName:I,onInsertToMessage:a,instances:s,onClose:()=>S(!1),onSaved:()=>{A()}})]})}),ra=(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,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null!=s?String(s):""),[j,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{y(null!=s?String(s):"")},[s]),(0,i.useEffect)(()=>{let e=!1;return p(!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||p(!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){w(!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{w(!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:g,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:to.vz,max:to.NL,value:v,onChange:N,onBlur:C,placeholder:o("vibeLocalContextWindowDefault"),disabled:j,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"})]})]})}),rr=Object.freeze({agent:null,providerId:null,modelId:null,variant:null}),rs=[{id:"opencode",label:(0,to.oo)("opencode")}];function rl(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}}let ri=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),[s,l]=(0,i.useState)({}),[o,d]=(0,i.useState)({connected:!1,providers:[],agents:[]}),[u,h]=(0,i.useState)(!0),[x,f]=(0,i.useState)(!1),[p,g]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1;return h(!0),fetch("/api/worktrees/".concat(t,"/instances/opencode")).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>{var n,a;e||(l(null!=(n=t.settings)?n:{}),d(null!=(a=t.catalog)?a:{connected:!1,providers:[],agents:[]}),g(null))}).catch(()=>{e||g(a("opencodeSettingsLoadError"))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[t,a]);let b=(0,i.useCallback)(async(e,n)=>{l(t=>({...t,[e]:n})),f(!0),g(null);try{let r=await fetch("/api/worktrees/".concat(t,"/instances/opencode"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:e,...n})});if(!r.ok)return void g(a("opencodeSettingsSaveError"));let s=await r.json();s.settings&&l(t=>({...t,[e]:s.settings}))}catch(e){g(a("opencodeSettingsSaveError"))}finally{f(!1)}},[t,a]);return(0,r.jsxs)("div",{className:"mt-4 pt-4 border-t border-border","data-testid":"opencode-instance-settings",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-1",children:a("opencodeSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:a("opencodeSettingsDescription")}),u?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),a("loading")]}):(0,r.jsxs)("div",{className:"space-y-4",children:[!o.connected&&(0,r.jsx)("p",{"data-testid":"opencode-settings-offline",className:"text-xs text-muted-foreground",children:a("opencodeSettingsOffline")}),n.map(e=>{var t,l,i,c,d,u;let m=null!=(t=s[e.id])?t:{...rr},h=m.providerId&&m.modelId?"".concat(m.providerId,"/").concat(m.modelId):"",f=function(e,t){var n;if(!t.providerId||!t.modelId)return null;let a=e.providers.find(e=>e.id===t.providerId);return null!=(n=null==a?void 0:a.models.find(e=>e.id===t.modelId))?n:null}(o,m),p=null!=(l=null==f?void 0:f.variants)?l:[],g=o.agents.filter(e=>"primary"===e.mode);return(0,r.jsxs)("div",{className:"space-y-2",children:[n.length>1&&(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:e.label}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeAgent"),g.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-agent-select-".concat(e.id),value:null!=(i=m.agent)?i:"",disabled:x,onChange:t=>void b(e.id,{...m,agent:""===t.target.value?null:t.target.value}),className:"mt-1 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:a("opencodeDefault")}),g.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-agent-input-".concat(e.id),defaultValue:null!=(c=m.agent)?c:"",disabled:x,placeholder:a("opencodeAgentPlaceholder"),onBlur:t=>void b(e.id,{...m,agent:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 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"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeModel"),o.providers.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-model-select-".concat(e.id),value:h,disabled:x,onChange:t=>{var n,a;let r=rl(t.target.value);b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null,variant:null})},className:"mt-1 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:a("opencodeDefault")}),o.providers.map(e=>(0,r.jsx)("optgroup",{label:e.name,children:e.models.map(t=>(0,r.jsx)("option",{value:"".concat(e.id,"/").concat(t.id),children:t.name},t.id))},e.id))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-model-input-".concat(e.id),defaultValue:h,disabled:x,placeholder:a("opencodeModelPlaceholder"),onBlur:t=>{var n,a;let r=rl(t.target.value.trim());b(e.id,{...m,providerId:null!=(n=null==r?void 0:r.providerId)?n:null,modelId:null!=(a=null==r?void 0:r.modelId)?a:null})},className:"mt-1 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"})]}),(0,r.jsxs)("label",{className:"block text-xs text-muted-foreground",children:[a("opencodeVariant"),p.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-variant-select-".concat(e.id),value:null!=(d=m.variant)?d:"",disabled:x,onChange:t=>void b(e.id,{...m,variant:""===t.target.value?null:t.target.value}),className:"mt-1 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:a("opencodeDefault")}),p.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]}):(0,r.jsx)("input",{type:"text","data-testid":"opencode-variant-input-".concat(e.id),defaultValue:null!=(u=m.variant)?u:"",disabled:x,placeholder:a("opencodeVariantPlaceholder"),onBlur:t=>void b(e.id,{...m,variant:""===t.target.value.trim()?null:t.target.value.trim()}),className:"mt-1 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"})]}),f&&0===p.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeNoVariants")})]},e.id)}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("opencodeVariantLaunchNote")}),x&&(0,r.jsxs)("div",{"data-testid":"opencode-settings-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(m.y$,{size:"xs",variant:"muted"}),a("loading")]}),p&&(0,r.jsx)("p",{"data-testid":"opencode-settings-error",className:"text-xs text-danger-foreground",children:p})]})]})}),ro=(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=to.XH,persistToServer:x=!0}=e,f=(0,c.c)("schedule"),p=n.length>u?n.slice(0,u):n,[g,b]=(0,i.useState)(()=>new Set(p)),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),k=(0,i.useRef)(g);k.current=g,(0,i.useEffect)(()=>{j||b(new Set(p))},[n,j,u]);let N=g.has("vibe-local"),C=g.has("opencode"),S=(0,i.useCallback)(async(e,n)=>{let r=new Set(k.current);if(n?r.add(e):(r.delete(e),w(!0)),b(r),r.size>=2){let e=Array.from(r);if(!x){b(new Set(e)),a(e),w(!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(p))}catch(e){b(new Set(p))}finally{y(!1),w(!1)}}},[t,p,a,x]),T=g.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=g.has(e),n=!t&&T;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,to.oo)(e),checked:t,disabled:n||v,onCheckedChange:t=>S(e,!0===t)}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground",children:(0,to.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")]}),C&&(0,r.jsx)(ri,{worktreeId:t,instances:rs}),N&&(0,r.jsx)(ra,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})});function rc(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function rd(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 ru=n(49476),rm=n(52056),rh=n(65506),rx=n(20017),rf=n(6191);let rp=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d,modelByInstance:m,sourceByInstance:h}=e,x=(0,c.c)("schedule"),f=(0,c.c)("common"),p=(0,c.c)("worktree"),g=(0,eg.SC)(),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)({}),[N,C]=(0,i.useState)(to.XH[0]),[S,T]=(0,i.useState)(null),E=function(e,t,n){let[a,r]=(0,i.useState)({}),s=t.some(e=>"opencode"===e.cliTool);return(0,i.useEffect)(()=>{if(n)return;if(!s)return void r({});let t=!1,a=async()=>{try{var n;let a=await fetch("/api/worktrees/".concat(e));if(!a.ok)return;let s=await a.json();if(t)return;let l={};for(let[e,t]of Object.entries(null!=(n=s.sessionStatusByInstance)?n:{}))(null==t?void 0:t.eventSource)&&(l[e]=t.eventSource);r(l)}catch(e){}};a();let l=setInterval(()=>void a(),1e4);return()=>{t=!0,clearInterval(l)}},[e,s,n]),null!=n?n:a}(t,n,h),I=n.length>=to.Ab,M=n.length<=1,A=n.some(e=>"vibe-local"===e.cliTool),L=(0,i.useCallback)(async e=>{let n=e.map((e,t)=>({...e,order:t}));v(!0),j(null);try{(await fetch("/api/worktrees/".concat(t),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:n})})).ok?a(n):j(x("agentInstanceSaveError"))}catch(e){j(x("agentInstanceSaveError"))}finally{v(!1)}},[t,a,x]),R=(0,i.useCallback)(()=>{if(n.length>=to.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)}(N,n);L([...n,{id:e,cliTool:N,alias:function(e,t){let n=(0,to.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(N,e),order:n.length}])},[N,n,L]),P=(0,i.useCallback)(async e=>{var t;if(n.length<=1)return;let a=n.find(t=>t.id===e);await g({description:f("confirmDelete",{name:null!=(t=null==a?void 0:a.alias)?t:""}),variant:"danger"})&&L(n.filter(t=>t.id!==e))},[n,L,g,f]),D=(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]],L(r)},[n,L]),F=(0,i.useCallback)((e,t)=>{k(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&&L(n.map(n=>n.id===e?{...n,alias:t}:n))},[n,L]),O=(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),L(a)},[n,L]);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:x("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:x("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:n.map((e,t)=>{var a,s;let l=e.id in w?w[e.id]:e.alias,i=S===t,o=null!=(a=null==m?void 0:m[e.id])?a:null,c=null==E?void 0:E[e.id],d=lp(c,p),u=!!(s=c)&&("sse"!==s.kind||"live"!==s.liveness);return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>T(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==S&&O(S,t),T(null)},onDragEnd:()=>T(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(i?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(ru.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":x("agentInstanceAliasLabel"),value:l,maxLength:to.pQ,disabled:b,placeholder:x("agentInstanceAliasPlaceholder"),onChange:t=>k(n=>({...n,[e.id]:t.target.value})),onBlur:t=>F(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)(at.nR,{content:(0,to.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),o&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:p("agentModel.modelLabel",{model:o}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:o}),d&&(0,r.jsxs)("span",{"data-testid":"agent-instance-source-".concat(e.id),title:p(u?"agentSource.degradedTitle":"agentSource.healthyTitle"),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(u?"text-warning":"text-muted-foreground"),children:[u?(0,r.jsx)(rm.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}):(0,r.jsx)(rh.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:d})]})]}),(0,r.jsxs)(e1.rI,{children:[(0,r.jsx)(e1.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":x("agentInstanceActions"),title:x("agentInstanceActions"),disabled:b,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)(rx.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(e1.SQ,{align:"end",children:[(0,r.jsxs)(e1._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>D(t,-1),children:[(0,r.jsx)(aC.A,{className:"w-4 h-4"}),x("agentInstanceMoveUp")]}),(0,r.jsxs)(e1._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===n.length-1,onSelect:()=>D(t,1),children:[(0,r.jsx)(tc.A,{className:"w-4 h-4"}),x("agentInstanceMoveDown")]}),(0,r.jsx)(e1.mB,{}),(0,r.jsxs)(e1._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:M,onSelect:()=>{P(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(n8.A,{className:"w-4 h-4"}),x("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":x("agentInstanceBaseTool"),value:N,disabled:b||I,onChange:e=>C(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:to.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,to.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:b||I,onClick:R,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)(rf.A,{className:"w-4 h-4"}),x("agentInstanceAdd")]})]}),I&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:x("agentInstanceMax",{max:to.Ab})}),M&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:x("agentInstanceMin",{min:1})}),b&&(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"}),x("loading")]}),y&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:y}),A&&(0,r.jsx)(ra,{worktreeId:t,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:o,onVibeLocalContextWindowChange:d})]})}),rg=(0,i.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o,visibleInstanceIds:d,onToggleInstanceVisible:u,modelByInstance:h,sourceByInstance:x}=e,f=(0,c.c)("schedule"),p=(0,c.c)("worktree"),g=new Set(d),b=d.length<=1;return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(rp,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:s,onVibeLocalModelChange:l,vibeLocalContextWindow:i,onVibeLocalContextWindowChange:o,modelByInstance:h,sourceByInstance:x}),(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:f("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:f("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let n=g.has(e.id),a=n&&b,s=null!=(t=null==h?void 0:h[e.id])?t:null;return(0,r.jsxs)("label",{className:"flex items-center gap-2 p-2 rounded-lg cursor-pointer ".concat(a?"opacity-60 cursor-not-allowed":"hover:bg-muted"),children:[(0,r.jsx)(m.Sc,{"data-testid":"mobile-visible-instance-toggle-".concat(e.id),checked:n,disabled:a,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,to.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,to.oo)(e.cliTool)}),s&&(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-model-".concat(e.id),title:p("agentModel.modelLabel",{model:s}),className:"block text-xs text-muted-foreground truncate",children:s})]})]},e.id)})}),b&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:f("mobileVisibleInstanceMin")})]})]})}),rb=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var rv=n(82912),ry=n.n(rv);n(95704);let rj=[36e5,108e5,288e5],rw={36e5:"autoYes.durations.1h",108e5:"autoYes.durations.3h",288e5:"autoYes.durations.8h"};function rk(e){if(e.length>500)return{valid:!1,error:"Pattern must be ".concat(500," characters or less")};if(!ry()(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 rN(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 rC(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 rS="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 rT(e){let{isOpen:t,worktreeId:n,instances:a,onClose:s,onSaved:l}=e,o=(0,c.c)("schedule"),d=(0,el.a)(),u=(0,i.useMemo)(()=>a&&a.length>0?a:(0,to.lu)([...to.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:to.XH[0]}),[p,g]=(0,i.useState)(rb[0]),[b,v]=(0,i.useState)(!1),[y,j]=(0,i.useState)(null);(0,i.useEffect)(()=>{var e,n;t&&(h(""),g(rb[0]),j(null),v(!1),f(null!=(n=null==(e=u[0])?void 0:e.id)?n:to.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:to.XH[0])}},[u,x]);let w=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){j(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:p})});if(t.ok){let e=await t.json();l(),"session_not_running"===e.warning?(j("session_not_running"),h("")):s()}}catch(e){}finally{v(!1)}}},[n,u,x,m,p,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:rS,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(rS," 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:p,onChange:e=>g(Number(e.target.value)),className:rS,children:rb.map(e=>(0,r.jsx)("option",{value:e,children:rC(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:!w,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)(aB,{isOpen:t,onClose:s,title:S,footer:C,children:N}):(0,r.jsx)(tl.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 rE(e){return new Date(e).toLocaleString()}function rI(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,c.c)("schedule"),o=(0,el.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:rC(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:rE(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:rE(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:rE(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)(aB,{isOpen:!0,title:x,onClose:l,footer:h,children:m}):(0,r.jsx)(tl.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 rM=(0,i.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,c.c)("schedule"),s=(0,eg.SC)(),l=(0,i.useMemo)(()=>n&&n.length>0?n:(0,to.lu)([...to.XH]),[n]),[o,d]=(0,i.useState)([]),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),[f,p]=(0,i.useState)(null),[,g]=(0,i.useState)(0),b=(0,i.useRef)(null),y=(0,i.useRef)(null),j=(0,i.useRef)(null),w=(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?j.current=t.timers[t.timers.length-1].createdAt:j.current=null}}catch(e){}},[t]),k=(0,i.useCallback)(async()=>{if(null!=j.current)try{let n=new URLSearchParams;n.set("before",String(j.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&&(j.current=t.timers[t.timers.length-1].createdAt)}}catch(e){}},[t]);(0,i.useEffect)(()=>{function e(){return w(),b.current=setInterval(()=>{w()},1e4),y.current=setInterval(()=>{g(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)}},[w]);let N=(0,i.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w]),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&&w()}catch(e){}},[t,w,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)(rf.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)(rf.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:()=>p(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),p(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:rN(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:rC(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)(rT,{isOpen:h,worktreeId:t,instances:n,onClose:()=>x(!1),onSaved:()=>{w()}}),(0,r.jsx)(rI,{timer:f,instances:l,onClose:()=>p(null)})]})});var rA=n(35626),rL=n(99648);let rR={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},rP={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},rD={outcome:"unknown",evidenceKind:"not_measured",labelKey:rR.unknown,evidenceKindKey:rP.not_measured,limitationKey:null},rF={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"},rO={NO_SLASH_COMMAND:"skills.compatibility.limitation.noSlashCommand"};function rz(e){return{agent:e,discoveryRoots:[],discovery:rD,invocation:rD,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:rF.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}rL.td,rR.verified,rP.mechanical,rR.verified,rP.mechanical,rF.SESSION_RESTART,rL.Co,rR.verified,rP.self_report,rR.unsupported,rP.mechanical,rO.NO_SLASH_COMMAND,rF.SESSION_RESTART_NO_SLASH,rz("gemini"),rz("vibe-local"),rL.Co,rL.td,rR.verified,rP.mechanical,rR.verified,rP.mechanical,rO.NO_SLASH_COMMAND,rF.SESSION_RESTART,rz("copilot"),rz("antigravity");let r_={SATISFIED:"SKILL_COMPAT_SATISFIED",HOST_VERSION_OUT_OF_RANGE:"SKILL_COMPAT_HOST_VERSION_OUT_OF_RANGE",HOST_VERSION_UNKNOWN:"SKILL_COMPAT_HOST_VERSION_UNKNOWN",RANGE_UNSUPPORTED:"SKILL_COMPAT_RANGE_UNSUPPORTED"};r_.SATISFIED,r_.HOST_VERSION_OUT_OF_RANGE,r_.HOST_VERSION_UNKNOWN,r_.RANGE_UNSUPPORTED;let rB={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};rB.CONFIRMED,rB.RESTRICTED,rB.STALE_DECLARATION,rB.UNVERIFIED;let rV=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;function rW(e){if("string"!=typeof e||e.length>64)return null;let t=rV.exec(e);return t?{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),prerelease:t[4]?t[4].split("."):[],build:t[5]?t[5].split("."):[]}:null}let rH={UP_TO_DATE:"SKILL_UPDATE_UP_TO_DATE",HIGHEST_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_HIGHEST_COMPATIBLE",LATEST_UNVERIFIED:"SKILL_UPDATE_RECOMMEND_LATEST_UNVERIFIED",NONE_COMPATIBLE:"SKILL_UPDATE_RECOMMEND_NONE_COMPATIBLE",INSTALLED_VERSION_INVALID:"SKILL_UPDATE_INSTALLED_VERSION_INVALID",RANGE_UNSUPPORTED:"SKILL_UPDATE_RANGE_UNSUPPORTED"};function rU(e,t){let n=function(e,t){let n=rW(e),a=rW(t);return n&&a?n.major!==a.major?n.major<a.major?-1:1:n.minor!==a.minor?n.minor<a.minor?-1:1:n.patch!==a.patch?n.patch<a.patch?-1:1:function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return -1;let n=Math.min(e.length,t.length);for(let a=0;a<n;a++){let n=e[a],r=t[a];if(n===r)continue;let s=/^\d+$/.test(n),l=/^\d+$/.test(r);if(s&&l)return Number(n)<Number(r)?-1:1;if(s)return -1;if(l)return 1;return n<r?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}(n.prerelease,a.prerelease):null}(e,t);return null!==n&&n>0}rH.UP_TO_DATE,rH.HIGHEST_COMPATIBLE,rH.LATEST_UNVERIFIED,rH.NONE_COMPATIBLE,rH.INSTALLED_VERSION_INVALID,rH.RANGE_UNSUPPORTED;var rK=n(75333),r$=n(34380),rq=n(37381),rG=n(95584),rJ=n(80130);let rY={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function rQ(e){let{heading:t,paths:n,testid:a}=e;return 0===n.length?null:(0,r.jsxs)("div",{"data-testid":a,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:n.map(e=>(0,r.jsx)("li",{className:"break-all font-mono text-xs text-foreground",children:e},e))})]})}function rX(e){var t;let{skillId:n,skillName:a,worktreeId:s,installedVersion:l,versions:o}=e,d=(0,c.c)("skills"),u=(0,i.useMemo)(()=>o.filter(e=>rU(e.version,l)),[o,l]),h=(0,i.useMemo)(()=>{var e,t,n;return null!=(n=null==(e=null!=(t=u.find(e=>"compatible"===e.compatibility.commandmate.status))?t:u[0])?void 0:e.version)?n:null},[u]),[x,f]=(0,i.useState)(rY),p=(0,i.useCallback)(()=>{f({...rY,open:!0,selectedVersion:h})},[h]),g=(0,i.useCallback)(()=>{f(rY)},[]),b=(0,i.useCallback)(async()=>{let e=x.selectedVersion;if(!e)return;f(e=>({...e,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let t=await (0,rJ.Sw)(s,n,{version:e});f(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,x.selectedVersion,s]),v=(0,i.useCallback)(async()=>{var e;let t=x.plan;if(!t||!t.updatable)return;f(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,rJ.h2)(s,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:x.riskAcknowledged,acknowledgeRiskIncrease:x.riskIncreaseAcknowledged,idempotencyKey:(e=t.token,"skill-update-".concat(e))});f(e=>({...e,applying:!1,applyResult:a.ok?a.data:null,applyFailure:a.ok?null:a.failure}))},[n,x.plan,x.riskAcknowledged,x.riskIncreaseAcknowledged,s]);if(0===u.length)return(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:d("update.upToDate",{version:l})});let y=x.plan,j=x.applyResult;return(0,r.jsxs)("div",{"data-testid":"skill-update-dialog-host",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(m.Ex,{variant:"info","data-testid":"skill-update-badge",children:d("update.badge")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("update.fromTo",{from:l,to:u[0].version})}),(0,r.jsx)(m.$n,{variant:"secondary",size:"sm",onClick:p,"data-testid":"skill-update-trigger",children:d("update.open")})]}),(0,r.jsx)(m.Jh,{isOpen:x.open,onClose:g,title:d("update.heading"),size:"lg",children:(0,r.jsxs)("div",{className:"space-y-3 p-4","data-testid":"skill-update-dialog",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:d("update.intro",{skill:a,version:l})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:d("update.ready")}),(0,r.jsxs)("label",{className:"block text-xs font-medium text-muted-foreground",children:[d("update.versionPicker"),(0,r.jsx)("select",{className:"".concat("w-full rounded-md border border-input bg-surface px-3 py-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"," mt-1"),value:null!=(t=x.selectedVersion)?t:"",onChange:e=>f(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:x.busy,"data-testid":"skill-update-version-select",children:u.map(e=>(0,r.jsxs)("option",{value:e.version,children:[e.version,e.prerelease?" (".concat(d("detail.prerelease"),")"):"","compatible"!==e.compatibility.commandmate.status?" — ".concat(d(rG.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(m.$n,{variant:"primary",disabled:x.busy||!x.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:x.busy?d("update.building"):d("update.build")}),x.failure&&(0,r.jsxs)(rq.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:d((0,rG.FW)(x.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:x.failure.code})})]}),y&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-plan",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground",children:d("update.fromTo",{from:y.update.fromVersion,to:y.update.toVersion})}),null!==y.update.latestVersion&&y.update.latestVersion!==y.update.toVersion&&(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:d("update.latestAvailable",{version:y.update.latestVersion})})]}),(0,r.jsx)(rq.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:d((0,rG.e5)(y.nextActionKey))}),y.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-blockers",children:y.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),d((0,rG.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-risk",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("plan.riskHeading")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-foreground",children:[(0,r.jsx)(rK.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(rK.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(rq.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:d((0,rG.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(rq.u,{tone:"warning","data-testid":"skill-update-high-risk",children:d((0,rG.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!x.applyResult&&y.requiresRiskAcknowledgement&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:x.riskAcknowledged,onChange:e=>f(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),d("update.ackRisk")]}),y.updatable&&!x.applyResult&&y.riskIncreased&&(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs text-foreground",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:x.riskIncreaseAcknowledged,onChange:e=>f(t=>({...t,riskIncreaseAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk-increase"}),d("update.ackRiskIncrease")]})]}),(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-security-diff",children:[y.securityDiff.permissions.added.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-added",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.permissionsAdded")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.added.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:d(null!=(t=rG.z2[e])?t:"plan.permissionsNone")},e)})})]}),y.securityDiff.permissions.removed.length>0&&(0,r.jsxs)("div",{"data-testid":"skill-update-permissions-removed",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.permissionsRemoved")}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:y.securityDiff.permissions.removed.map(e=>{var t;return(0,r.jsx)("li",{className:"text-xs text-foreground",children:d(null!=(t=rG.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(rQ,{heading:d("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(rQ,{heading:d("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(rQ,{heading:d("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(rQ,{heading:d("update.executablesRemoved"),paths:y.securityDiff.executables.removed,testid:"skill-update-executables-removed"})]}),y.securityDiff.changelogs.length>0&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-changelogs",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("detail.changelogHeading")}),y.securityDiff.changelogs.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:e.version}),(0,r.jsx)("p",{className:"whitespace-pre-wrap text-xs text-muted-foreground",children:e.changelog})]},e.version))]}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-files",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("update.filesHeading")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-stats",children:d("update.stats",{added:y.stats.added,updated:y.stats.updated,removed:y.stats.removed,unchanged:y.stats.unchanged})}),(0,r.jsx)("ul",{className:"space-y-1",children:y.files.filter(e=>"unchanged"!==e.change).map(e=>{var t,n;return(0,r.jsxs)("li",{"data-testid":"skill-update-file",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(m.Ex,{variant:null!=(t=rG.JD[e.change])?t:"gray",children:d(null!=(n=rG.KS[e.change])?n:"update.change.update")}),(0,r.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:e.path})]}),e.diff&&(0,r.jsxs)("details",{className:"mt-1",children:[(0,r.jsx)("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:d("update.showDiff")}),(0,r.jsx)("pre",{className:"mt-1 overflow-x-auto rounded-md bg-muted p-2 text-xs text-foreground",children:e.diff})]})]},e.path)})})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-expiry",children:d("plan.expiresAt",{timestamp:y.expiresAt})}),y.updatable&&!x.applyResult&&(0,r.jsx)(m.$n,{variant:"primary",disabled:x.applying||y.requiresRiskAcknowledgement&&!x.riskAcknowledged||y.riskIncreased&&!x.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:x.applying?d("update.applying"):d("update.apply")}),x.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(rq.u,{tone:"danger",children:[(0,r.jsx)("p",{children:d((0,rG.FW)(x.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:x.applyFailure.code})})]}),x.applyFailure.nextActionKey&&(0,r.jsx)(rq.u,{tone:"warning",children:d((0,rG.e5)(x.applyFailure.nextActionKey))}),x.applyFailure.blockers&&x.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:x.applyFailure.blockers.map(e=>{var t;return(0,r.jsxs)("li",{className:"text-xs text-danger-foreground",children:[e.path&&(0,r.jsx)("span",{className:"mr-1 break-all font-mono",children:e.path}),d((0,rG.e5)(e.messageKey))]},"".concat(e.code,":").concat(null!=(t=e.path)?t:""))})})]})]}),j&&(0,r.jsxs)("div",{className:"space-y-3","data-testid":"skill-update-result",children:[(0,r.jsx)(rq.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:d((0,rG.e5)(j.operation.nextActionKey))}),"reload"in j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-foreground",children:d("update.fromTo",{from:j.update.fromVersion,to:j.update.toVersion})}),(0,r.jsxs)("div",{className:"space-y-1","data-testid":"skill-update-result-reload",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:d("operation.reloadHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:j.reload.agents.map(e=>(0,r.jsx)("li",{className:"text-xs text-muted-foreground",children:d((0,rG.e5)(e.messageKey),{agent:(0,to.f_)(e.agent),skillId:j.reload.skillId,version:j.reload.version})},e.agent))})]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-result-rollback",children:d((0,rG.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let rZ={status:"loading",skills:[],failure:null},r0={status:"loading",skills:[],failure:null};function r1(e){var t,n,a,s,l,o,d,u;let{worktreeId:h,className:x=""}=e,f=(0,c.c)("skills"),[p,g]=(0,i.useState)(rZ),[b,v]=(0,i.useState)(r0),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(0),[N,C]=(0,i.useState)(0);(0,i.useEffect)(()=>{let e=new AbortController;return g(rZ),(0,rJ.s5)(e.signal).then(t=>{e.signal.aborted||g(t.ok?{status:"loaded",skills:t.data.skills,failure:null}:{status:"error",skills:[],failure:t.failure})}).catch(()=>{}),()=>e.abort()},[w]),(0,i.useEffect)(()=>{let e=new AbortController;return v(r0),(0,rJ.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 Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),T=(0,i.useMemo)(()=>new Map(p.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[p.skills]),E=(0,i.useMemo)(()=>{let e=new Map;for(let[r,s]of S){var t,n,a;e.set(r,(a=null!=(n=null==(t=T.get(r))?void 0:t.latest)?n:null,null!==s&&null!==a&&rU(a,s)))}return e},[S,T]),I=(0,i.useMemo)(()=>{var e;return null!=(e=p.skills.find(e=>e.id===y))?e:null},[p.skills,y]),M=(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==I?void 0:I.compatibility)?a:null,t=I?I.recommendedVersion:null!=(s=null==M?void 0:M.version)?s:null,n=I?I.recommendedVersion?e&&"compatible"!==e.status?f("detail.install.blockedIncompatible",{reason:f((0,rG.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:()=>{j(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(rA.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==I?void 0:I.name)?o:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[M&&I&&(0,r.jsx)(rX,{skillId:y,skillName:I.name,worktreeId:h,installedVersion:M.version,versions:I.versions}),(0,r.jsx)(r$.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)(rq.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:()=>j(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)(rK.qW,{risk:e.effectiveRisk}),E.get(e.skillId)&&(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-update-badge-".concat(e.skillId),children:f("worktreePane.updateBadge")})]}),(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"===p.status?(0,r.jsx)(m.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===p.status?(0,r.jsxs)(m.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(rq.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=p.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===p.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:p.skills.map(e=>{let t=(0,rG.gh)(e),n=S.has(e.id),a=!0===E.get(e.id);return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>j(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}),n&&(a?(0,r.jsx)(m.Ex,{variant:"info","data-testid":"worktree-skills-catalog-update-badge-".concat(e.id),children:f("worktreePane.updateBadge")}):(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})}),(0,r.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground","data-testid":"worktree-skills-catalog-version-".concat(e.id),children:f("worktreePane.version",{version:e.latest})}),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)(rK.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(rK.qW,{risk:t})]})]})},e.id)})})]})]})})}var r2=n(76907),r5=n(52799);let r4={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},r3={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},r6={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},r8=["failed","timeout","error"];class r9 extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function r7(e,t){let n=await e.json().catch(()=>({})),a="string"==typeof n.error?n.error:"".concat(t," (").concat(e.status,")"),r="number"==typeof n.runningRunId?n.runningRunId:null;throw new r9(a,e.status,r)}function se(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function st(e,t){var n,a;let r=await fetch("".concat(se(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:r7(r,"Failed to load tasks")}async function sn(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=arguments.length>2?arguments[2]:void 0,r=await fetch("".concat(se(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:r7(r,"Failed to load verification runs")}async function sa(e,t,n){let a=await fetch("".concat(se(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:r7(a,"Failed to load the verification run")}async function sr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(se(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return r7(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new r9("Verification response carried no run id",n.status);return a.runId}function ss(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function sl(e){let{heading:t,action:n,children:a,testId:s}=e;return(0,r.jsxs)("section",{className:"border-b border-border px-3 py-3 last:border-b-0","data-testid":s,children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:t}),n]}),a]})}function si(e){let{label:t,children:n}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:t}),(0,r.jsx)("span",{className:"min-w-0 break-words text-xs text-foreground",children:n})]})}function so(e){var t,n;let{task:a}=e,s=(0,c.c)("worktree"),l=a.contract,i=null!=(t=l.goal)?t:"",o=i.length>240?"".concat(i.slice(0,240),"…"):i;return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-contract",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"min-w-0 break-words text-sm font-medium text-foreground",children:l.title||a.title}),(0,r.jsx)(r5.E,{variant:r4[a.status],"data-testid":"verification-task-status",children:s("task.status.".concat(a.status))})]}),(0,r.jsx)("p",{className:"whitespace-pre-wrap break-words text-xs text-muted-foreground",children:o}),(0,r.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,r.jsx)(si,{label:s("verification.contract.scopeAllow"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.allow.join(", ")||"—"})}),l.scope.deny.length>0&&(0,r.jsx)(si,{label:s("verification.contract.scopeDeny"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.deny.join(", ")})}),(0,r.jsx)(si,{label:s("verification.contract.gates"),children:(0,r.jsx)("span",{className:"font-mono",children:null===l.verify.gates?s("verification.contract.gatesAll"):l.verify.gates.join(", ")||s("verification.contract.gatesAll")})}),(0,r.jsx)(si,{label:s("verification.contract.autoYes"),children:(0,r.jsx)("span",{className:"font-mono",children:null!=(n=l.autoYes.mode)?n:s("verification.contract.autoYesUnset")})}),a.contractPath&&(0,r.jsx)(si,{label:s("verification.contract.file"),children:(0,r.jsx)("span",{className:"font-mono",children:a.contractPath})}),(0,r.jsx)(si,{label:s("verification.contract.updated"),children:ss(a.updatedAt)})]})]})}function sc(e){let{run:t,selected:n,onSelect:a}=e,s=(0,c.c)("worktree"),l=s("verification.runStatus.".concat(t.status));return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",onClick:()=>a(t.id),"aria-current":n?"true":void 0,"aria-label":s("verification.runs.select",{runId:t.id,verdict:l}),"data-testid":"verification-run-".concat(t.id),className:"flex w-full flex-col gap-0.5 rounded-md border px-2 py-2 text-left text-xs transition-colors touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(n?"border-accent-500 bg-accent-50 dark:bg-accent-900/30":"border-border bg-surface hover:bg-muted"),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(r5.E,{variant:r3[t.status],className:"flex-shrink-0 font-mono",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:ss(t.startedAt)})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:s("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:s("verification.runs.trigger",{trigger:t.trigger})})]})]})})}function sd(e){let{gate:t}=e,n=(0,c.c)("worktree"),a=r8.includes(t.status),[s,l]=(0,i.useState)(null),o=null!=s?s:a,d=function(e,t){let n=(null!=e?e:"").replace(/\n+$/,"");if(""===n)return{lines:[],omitted:0};let a=n.split("\n");return a.length<=40?{lines:a,omitted:0}:{lines:a.slice(-40),omitted:a.length-t}}(t.logTail,40),u=function(e){if(null==e||!Number.isFinite(e))return null;if(e<1e3)return"".concat(Math.max(0,Math.round(e)),"ms");let t=e/1e3;return t<10?"".concat(t.toFixed(1),"s"):"".concat(Math.round(t),"s")}(t.durationMs);return(0,r.jsxs)("li",{className:"rounded-md border border-border bg-surface p-2","data-testid":"verification-gate-".concat(t.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(r5.E,{variant:r6[t.status],className:"flex-shrink-0 font-mono",children:n("verification.gateStatus.".concat(t.status))}),(0,r.jsx)("span",{className:"min-w-0 break-all font-mono text-xs font-medium text-foreground",children:t.gateId}),"contract"===t.source&&(0,r.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",children:n("verification.gates.contractSource")})]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[11px] text-muted-foreground",children:[null!==t.exitCode&&void 0!==t.exitCode&&(0,r.jsx)("span",{children:n("verification.gates.exitCode",{code:t.exitCode})}),u&&(0,r.jsx)("span",{children:n("verification.gates.duration",{duration:u})}),t.command&&(0,r.jsx)("span",{className:"break-all",children:t.command})]}),(0,r.jsx)("button",{type:"button",onClick:()=>l(!o),"aria-expanded":o,"data-testid":"verification-gate-log-toggle-".concat(t.gateId),className:"mt-1 rounded text-[11px] font-medium text-accent-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-accent-400 touch-manipulation",children:n(o?"verification.gates.hideLog":"verification.gates.showLog")}),o&&(0,r.jsx)("div",{className:"mt-1","data-testid":"verification-gate-log-".concat(t.gateId),children:0===d.lines.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.gates.noLog")}):(0,r.jsxs)(r.Fragment,{children:[d.omitted>0&&(0,r.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:n("verification.gates.logOmitted",{count:d.omitted,runId:t.runId})}),(0,r.jsx)("pre",{className:"max-h-64 overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:d.lines.join("\n")})]})})]})}let su=(0,i.memo)(function(e){let{state:t,className:n=""}=e,a=(0,c.c)("worktree"),{task:s,runs:l,selectedRunId:o,selectedRun:d,loading:u,error:m,detailError:h,detailLoading:x,rerunPending:f,rerunFailure:p,selectRun:g,refresh:b,rerun:v}=t,y=(0,i.useCallback)(()=>{v()},[v]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(n).trim(),"data-testid":"verification-pane",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)(r2.A,{size:16,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("h2",{className:"truncate text-sm font-semibold text-foreground",children:a("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:b,"aria-label":a("verification.refresh"),title:a("verification.refresh"),"data-testid":"verification-refresh-button",className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:(0,r.jsx)(ab.A,{size:14,"aria-hidden":"true"})})]}),m&&(0,r.jsx)("p",{className:"border-b border-danger-border bg-danger-subtle px-3 py-2 text-xs text-danger-foreground","data-testid":"verification-error",role:"alert",children:a("verification.loadError",{message:m})}),u?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:a("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sl,{heading:a("verification.contract.heading"),testId:"verification-contract-section",children:s?(0,r.jsx)(so,{task:s}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:a("verification.contract.empty")})}),(0,r.jsxs)(sl,{heading:a("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(e6.$,{type:"button",size:"sm",variant:"secondary",onClick:y,disabled:f,"data-testid":"verification-rerun-button",children:a(f?"verification.runs.rerunPending":"verification.runs.rerun")}),children:[p&&(0,r.jsx)("p",{className:"mb-2 rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-rerun-failure",role:"alert",children:"conflict"===p.kind?null!==p.runningRunId?a("verification.runs.rerunConflict",{runId:p.runningRunId}):a("verification.runs.rerunConflictUnknown"):a("verification.runs.rerunError",{message:p.message})}),0===l.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:a("verification.runs.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:l.map(e=>(0,r.jsx)(sc,{run:e,selected:e.id===o,onSelect:g},e.id))})]}),null!==o&&(0,r.jsx)(sl,{heading:a("verification.gates.heading",{runId:o}),testId:"verification-gates-section",children:null!==h?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-error",role:"alert",children:"not-found"===h?a("verification.gates.notFound"):a("verification.gates.loadError",{message:h})}):null===d?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:a(x?"verification.gates.loading":"verification.gates.empty")}):0===d.gates.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-empty",children:a("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:d.gates.map(e=>(0,r.jsx)(sd,{gate:e},e.id))})})]})]})});var sm=n(70532),sh=n(46046),sx=n(47972),sf=n(5590),sp=n(25840);class sg extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function sb(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new sg(null!=(s=null==o||null==(n=o.error)?void 0:n.code)?s:"HTTP_".concat(e.status),null!=(l=null==o||null==(a=o.error)?void 0:a.message)?l:t,null!=(i=null==o||null==(r=o.error)?void 0:r.issues)?i:[])}function sv(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function sy(e,t){var n,a;let r=await fetch(sv(e,t),{cache:"no-store"});if(!r.ok)throw await sb(r,"Failed to load env files");let s=await r.json();return{files:null!=(n=s.files)?n:[],selected:null!=(a=s.selected)?a:null}}async function sj(e,t,n){var a;let r=await fetch(sv(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await sb(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let sw=/^[A-Za-z_][A-Za-z0-9_]*$/;function sk(e){return e.split(/\r\n|\n|\r/)}function sN(e,t,n){for(let a=n;a<e.length;a+=1){if('"'===t&&"\\"===e[a]){a+=1;continue}if(e[a]===t)return a}return -1}function sC(e){let t=sk(e),n=[],a=[],r=new Map;for(let e=0;e<t.length;e+=1){let s,l=e+1,i=t[e].trim();if(""===i||i.startsWith("#"))continue;let o=/^export\s+/.test(i),c=o?i.replace(/^export\s+/,""):i,d=c.indexOf("=");if(-1===d){a.push({line:l,code:"invalid-syntax",severity:"error"});continue}let u=c.slice(0,d).trim();if(!sw.test(u)){a.push({line:l,code:"invalid-key",severity:"error",...u.length>0&&u.length<=64?{key:u}:{}});continue}let m=c.slice(d+1).replace(/^[ \t]+/,""),h=null,x=l;if(m.startsWith('"')||m.startsWith("'")){h=m[0];let n=m.slice(1),r=sN(n,h,0);for(;-1===r&&e+1<t.length;)e+=1,x=e+1,n+="\n".concat(t[e]),r=sN(n,h,0);if(-1===r){a.push({line:l,code:"unterminated-quote",severity:"error",key:u});continue}let i=n.slice(0,r);s='"'===h?function(e){let t="";for(let n=0;n<e.length;n+=1){let a=e[n];if("\\"!==a||n===e.length-1){t+=a;continue}let r=e[n+1];switch(n+=1,r){case"n":t+="\n";break;case"r":t+="\r";break;case"t":t+=" ";break;case"\\":t+="\\";break;case'"':t+='"';break;default:t+="\\".concat(r)}}return t}(i):i}else s=(function(e){let t=/\s#/.exec(e);return t?e.slice(0,t.index):e})(m).replace(/[ \t]+$/,"");void 0!==r.get(u)&&a.push({line:l,code:"duplicate-key",severity:"warning",key:u}),r.set(u,l),n.push({key:u,value:s,line:l,endLine:x,exported:o,quote:h})}return{entries:n,issues:a}}let sS=/[\s#'"$`\\]/;function sT(e){if(!sS.test(e))return e;let t=e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t");return'"'.concat(t,'"')}function sE(e,t,n){let a=sk(e),r=new Map(t.map(e=>[e.line,e])),s=new Map,l=[];for(let e of n)null!==e.sourceLine&&r.has(e.sourceLine)?s.set(e.sourceLine,e):l.push(e);let i=[],o=0;for(let e=0;e<a.length;e+=1){let t=e+1;if(t<=o)continue;let n=r.get(t);if(!n){i.push(a[e]);continue}o=n.endLine;let l=s.get(t);l&&i.push("".concat(n.exported?"export ":"").concat(l.key,"=").concat(sT(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(sT(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let sI=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,sM=0;function sA(){return sM+=1,"env-row-".concat(sM)}function sL(e){return e.map(e=>({id:sA(),key:e.key,value:e.value,sourceLine:e.line}))}let sR="••••••••";function sP(e){return 0===e.length?"":sR}let sD="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",sF={"invalid-syntax":"envManager.issues.invalidSyntax","invalid-key":"envManager.issues.invalidKey","unterminated-quote":"envManager.issues.unterminatedQuote","duplicate-key":"envManager.issues.duplicateKey","control-character":"envManager.issues.controlCharacter","too-large":"envManager.issues.tooLarge","too-many-entries":"envManager.issues.tooManyEntries"},sO=(0,i.memo)(function(e){let{worktreeId:t,className:n=""}=e,a=(0,c.c)("worktree"),s=function(e){var t;let[n,a]=(0,i.useState)([]),[r,s]=(0,i.useState)(".env"),[l,o]=(0,i.useState)(null),[c,d]=(0,i.useState)(!0),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)("kv"),[v,y]=(0,i.useState)([]),[j,w]=(0,i.useState)(""),[k,N]=(0,i.useState)(""),[C,S]=(0,i.useState)([]),[T,E]=(0,i.useState)(""),[I,M]=(0,i.useState)(new Set),[A,L]=(0,i.useState)(!1),[R,P]=(0,i.useState)(0),D=(0,i.useRef)(0);(0,i.useEffect)(()=>{let t=!1,n=D.current+1;return D.current=n,d(!0),x(null),p(!1),sy(e,r).then(e=>{var r,s;if(t||D.current!==n)return;a(e.files);let l=e.selected;o(l);let i=null!=(r=null==l?void 0:l.content)?r:"",c=null!=(s=null==l?void 0:l.entries)?s:[];E(i),N(i),S(c),y(sL(c)),w(i),M(new Set),L(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof sg?e:null;x({code:null!=(a=null==s?void 0:s.code)?a:"UNKNOWN",message:null!=(r=null==s?void 0:s.message)?r:e instanceof Error?e.message:"Failed to load"}),o(null)}).finally(()=>{t||D.current!==n||d(!1)}),()=>{t=!0}},[e,r,R]);let F=(0,i.useMemo)(()=>"raw"===g?j:sE(k,C,v),[g,j,k,C,v]),O=(0,i.useMemo)(()=>(function(e){let t=[];if("string"!=typeof e)return{valid:!1,issues:[{line:null,code:"invalid-syntax",severity:"error"}],entries:[]};if(new TextEncoder().encode(e).length>262144)return{valid:!1,issues:[{line:null,code:"too-large",severity:"error"}],entries:[]};let n=e.split(/\r\n|\n|\r/);for(let e=0;e<n.length;e+=1)sI.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=sC(e);return t.push(...a.issues),a.entries.length>1e3&&t.push({line:null,code:"too-many-entries",severity:"error"}),t.sort((e,t)=>{var n,a;return(null!=(n=e.line)?n:0)-(null!=(a=t.line)?a:0)}),{valid:!t.some(e=>"error"===e.severity),issues:t,entries:a.entries}})(F),[F]),z=(0,i.useMemo)(()=>"raw"===g?j!==T:k!==T||v.length!==C.length||v.some((e,t)=>{var n,a;return e.key!==(null==(n=C[t])?void 0:n.key)||e.value!==(null==(a=C[t])?void 0:a.value)}),[g,j,T,k,v,C]),_=(0,i.useCallback)(e=>{if(e!==g){if("raw"===e)w(sE(k,C,v));else{let e=sC(j);N(j),S(e.entries),y(sL(e.entries))}b(e)}},[g,k,C,v,j]),B=(0,i.useCallback)(e=>{s(e),b("kv")},[]),V=(0,i.useCallback)(e=>{w(e),p(!1)},[]),W=(0,i.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),p(!1)},[]),H=(0,i.useCallback)(e=>{var t,n;let a={id:sA(),key:null!=(t=null==e?void 0:e.key)?t:"",value:null!=(n=null==e?void 0:e.value)?n:"",sourceLine:null};y(e=>[...e,a]),p(!1),(null==e?void 0:e.key)&&M(t=>new Set([...t,e.key]))},[]),U=(0,i.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),p(!1)},[]),K=(0,i.useCallback)(e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),$=(0,i.useCallback)(()=>L(e=>!e),[]),q=(0,i.useCallback)(()=>{M(new Set(v.map(e=>e.key)))},[v]),G=(0,i.useCallback)(()=>M(new Set),[]),J=(0,i.useCallback)(()=>P(e=>e+1),[]),Y=(0,i.useCallback)(()=>{O.valid&&!u&&(m(!0),x(null),sj(e,r,F).then(()=>{p(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof sg?e:null;x({code:null!=(t=null==a?void 0:a.code)?t:"UNKNOWN",message:null!=(n=null==a?void 0:a.message)?n:e instanceof Error?e.message:"Failed to save"})}).finally(()=>m(!1)))},[O.valid,u,e,r,F]);return{files:n,selectedFile:r,detail:l,loading:c,saving:u,error:h,saved:f,mode:g,rows:v,rawDraft:j,revealedKeys:I,rawRevealed:A,suggestions:null!=(t=null==l?void 0:l.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:B,setMode:_,setRawDraft:V,updateRow:W,addRow:H,removeRow:U,toggleReveal:K,toggleRawReveal:$,revealAll:q,hideAll:G,reload:J,save:Y}}(t),{mode:l,rows:o,revealedKeys:d,rawRevealed:m}=s,h=(0,i.useMemo)(()=>s.issues.filter(e=>"error"===e.severity),[s.issues]),x=(0,i.useMemo)(()=>s.issues.filter(e=>"warning"===e.severity),[s.issues]),f="raw"===l?m:o.length>0&&o.every(e=>d.has(e.key)),p=(0,i.useCallback)(()=>{if("raw"===l)return void s.toggleRawReveal();f?s.hideAll():s.revealAll()},[l,f,s]),g=(0,i.useMemo)(()=>"raw"!==l||m?"":function(e,t){let n=e.split(/\r\n|\n|\r/),a=new Map,r=new Set;for(let e of t){a.set(e.line,e);for(let t=e.line+1;t<=e.endLine;t+=1)r.add(t)}let s=[];for(let e=0;e<n.length;e+=1){let t=e+1;if(r.has(t))continue;let l=a.get(t);if(!l){s.push(n[e]);continue}s.push("".concat(l.exported?"export ":"").concat(l.key,"=").concat(sP(l.value)))}return s.join("\n")}(s.rawDraft,sC(s.rawDraft).entries),[l,m,s.rawDraft]),b=(0,i.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(sF[e.code],{line:null!=(n=e.line)?n:0,key:null!=(s=e.key)?s:""})},"".concat(e.code,"-").concat(null!=(l=e.line)?l:"file","-").concat(t))},[a]);return(0,r.jsxs)("div",{"data-testid":"env-manager-pane",role:"region","aria-label":a("envManager.title"),className:"flex flex-col h-full min-h-0 bg-background ".concat(n).trim(),children:[(0,r.jsxs)("div",{className:"flex-shrink-0 border-b border-border bg-surface dark:bg-surface-2 p-2 space-y-2",children:[(0,r.jsx)("div",{role:"group","aria-label":a("envManager.filePickerLabel"),className:"flex gap-1 overflow-x-auto scrollbar-hide",children:s.files.map(e=>(0,r.jsxs)(e6.$,{size:"sm",variant:e.name===s.selectedFile?"primary":"ghost",onClick:()=>s.selectFile(e.name),"aria-pressed":e.name===s.selectedFile,"data-testid":"env-file-".concat(e.name),className:"flex-shrink-0 whitespace-nowrap min-h-[44px] gap-1.5 font-mono text-xs",children:[e.name,!e.exists&&(0,r.jsx)(r5.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(r5.E,{variant:"info",children:a("envManager.templateBadge")})]},e.name))}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("div",{role:"group","aria-label":a("envManager.viewModeLabel"),className:"flex gap-1",children:[(0,r.jsx)(e6.$,{size:"sm",variant:"kv"===l?"primary":"ghost",onClick:()=>s.setMode("kv"),"aria-pressed":"kv"===l,"data-testid":"env-mode-kv",className:"min-h-[44px]",children:a("envManager.viewKeyValue")}),(0,r.jsx)(e6.$,{size:"sm",variant:"raw"===l?"primary":"ghost",onClick:()=>s.setMode("raw"),"aria-pressed":"raw"===l,"data-testid":"env-mode-raw",className:"min-h-[44px]",children:a("envManager.viewRaw")})]}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsxs)(e6.$,{size:"sm",variant:"ghost",onClick:p,"data-testid":"env-toggle-all","aria-pressed":f,className:"min-h-[44px] gap-1.5",children:[f?(0,r.jsx)(sm.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eA.A,{size:16,"aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:f?a("envManager.hideAll"):a("envManager.revealAll")})]}),(0,r.jsx)(e6.$,{size:"sm",variant:"ghost",onClick:s.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(ab.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(e6.$,{size:"sm",variant:"primary",onClick:s.save,loading:s.saving,disabled:!s.canSave||!s.dirty,"data-testid":"env-save",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(sh.A,{size:16,"aria-hidden":"true"}),a("envManager.save")]})]})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-3",children:[(0,r.jsx)("p",{"data-testid":"env-description",className:"text-xs text-muted-foreground",children:a("envManager.description")}),s.loading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)(u.y,{size:"sm"}),a("envManager.loading")]}),s.error&&(0,r.jsx)("div",{role:"alert","data-testid":"env-error",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-sm text-danger-foreground",children:a("envManager.loadError")}),!s.loading&&s.detail&&!s.detail.exists&&(0,r.jsx)("p",{"data-testid":"env-not-created",className:"rounded-md border border-border bg-muted p-2 text-xs text-muted-foreground",children:a("envManager.notCreatedHint",{file:s.selectedFile})}),s.saved&&!s.dirty&&(0,r.jsx)("p",{"data-testid":"env-saved",className:"text-xs text-success-foreground",children:a("envManager.saved")}),h.length>0&&(0,r.jsxs)("div",{role:"alert","data-testid":"env-errors",className:"rounded-md border border-danger-border bg-danger-subtle p-2 text-xs text-danger-foreground",children:[(0,r.jsxs)("p",{className:"flex items-center gap-1.5 font-medium",children:[(0,r.jsx)(rm.A,{size:14,"aria-hidden":"true"}),a("envManager.validationFailed")]}),(0,r.jsx)("ul",{className:"mt-1 list-disc pl-5 space-y-0.5",children:h.map(b)})]}),x.length>0&&(0,r.jsx)("div",{"data-testid":"env-warnings",className:"rounded-md border border-warning-border bg-warning-subtle p-2 text-xs text-warning-foreground",children:(0,r.jsx)("ul",{className:"list-disc pl-5 space-y-0.5",children:x.map(b)})}),!s.loading&&"kv"===l&&(0,r.jsxs)("div",{"data-testid":"env-kv-view",className:"space-y-2",children:[0===o.length&&(0,r.jsx)("p",{"data-testid":"env-empty",className:"px-1 py-4 text-center text-sm text-muted-foreground",children:a("envManager.empty")}),o.map(e=>{let t=d.has(e.key);return(0,r.jsxs)("div",{"data-testid":"env-row","data-env-key":e.key,className:"flex flex-col gap-1 rounded-md border border-border bg-surface dark:bg-surface-2 p-2 sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)(sf.p,{inputSize:"sm",value:e.key,onChange:t=>s.updateRow(e.id,{key:t.target.value}),"aria-label":a("envManager.keyLabel"),spellCheck:!1,autoComplete:"off","data-testid":"env-row-key",className:"font-mono text-xs sm:w-2/5"}),(0,r.jsxs)("div",{className:"flex flex-1 items-center gap-1",children:[(0,r.jsx)(sf.p,{inputSize:"sm",readOnly:!t,value:t?e.value:sP(e.value),onChange:t=>s.updateRow(e.id,{value:t.target.value}),"aria-label":a("envManager.valueLabel",{key:e.key}),spellCheck:!1,autoComplete:"off","data-testid":"env-row-value","data-masked":t?"false":"true",className:"flex-1 font-mono text-xs"}),(0,r.jsx)(e6.$,{size:"sm",variant:"ghost",onClick:()=>s.toggleReveal(e.key),"aria-label":t?a("envManager.hideValue",{key:e.key}):a("envManager.showValue",{key:e.key}),"aria-pressed":t,"data-testid":"env-row-reveal",className:"".concat(sD," min-h-[44px]"),children:t?(0,r.jsx)(sm.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(eA.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(e6.$,{size:"sm",variant:"ghost",onClick:()=>s.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(sD," min-h-[44px] text-danger"),children:(0,r.jsx)(n8.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(e6.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(rf.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),s.suggestions.length>0&&(0,r.jsxs)(sx.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(sx.aR,{children:[(0,r.jsx)(sx.ZB,{className:"text-sm",children:a("envManager.suggestionsTitle")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.suggestionsHint")})]}),(0,r.jsx)(sx.Wu,{className:"flex flex-wrap gap-2",children:s.suggestions.map(e=>(0,r.jsxs)(e6.$,{size:"sm",variant:"secondary",onClick:()=>s.addRow({key:e.key,value:e.value}),"data-testid":"env-suggestion-".concat(e.key),className:"min-h-[44px] gap-1.5 font-mono text-xs",children:[(0,r.jsx)(rf.A,{size:14,"aria-hidden":"true"}),e.key,(0,r.jsx)("span",{className:"font-sans text-muted-foreground",children:e.source})]},"".concat(e.source,":").concat(e.key)))})]})]}),!s.loading&&"raw"===l&&(0,r.jsx)("div",{"data-testid":"env-raw-view",className:"space-y-2",children:m?(0,r.jsx)(sp.T,{value:s.rawDraft,onChange:e=>s.setRawDraft(e.target.value),"aria-label":a("envManager.rawLabel"),spellCheck:!1,"data-testid":"env-raw-editor",className:"min-h-[240px] font-mono text-xs"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sp.T,{readOnly:!0,value:g,"aria-label":a("envManager.rawMaskedLabel"),spellCheck:!1,"data-testid":"env-raw-masked",className:"min-h-[240px] font-mono text-xs"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:a("envManager.rawMaskedHint",{mask:sR})})]})})]})]})}),sz=[{id:"notes",labelKey:"notes"},{id:"logs",labelKey:"logs"},{id:"agent",labelKey:"agentTab"},{id:"timer",labelKey:"timerTab"},{id:"todo",labelKey:"todoTab"},{id:"skills",labelKey:"skillsTab"},{id:"verification",labelKey:"verificationTab"},{id:"env",labelKey:"envTab"}],s_=(0,i.memo)(function(e){var t,n;let{worktreeId:a,className:s="",selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,maxAgents:x,availableAgents:f,persistToServer:p,onInsertToMessage:g,useInstanceManagement:b=!1,instances:v,onInstancesChange:y,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,verification:N,requestedSubTab:C}=e,S=(0,c.c)("schedule"),[T,E]=(0,i.useState)(null!=(t=null==C?void 0:C.tab)?t:"notes"),I=(0,i.useRef)(null!=(n=null==C?void 0:C.token)?n:null);(0,i.useEffect)(()=>{C&&C.token!==I.current&&(I.current=C.token,E(C.tab))},[C]);let M=(0,i.useCallback)(e=>{E(e)},[]),A=(0,i.useRef)({});(0,i.useEffect)(()=>{var e,t;null==(t=A.current[T])||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest",inline:"nearest"})},[T]);let L=N?sz:sz.filter(e=>"verification"!==e.id);return(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(s),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:L.map(e=>(0,r.jsx)("button",{type:"button",ref:t=>{A.current[e.id]=t},onClick:()=>M(e.id),className:"flex-shrink-0 whitespace-nowrap px-3 py-2 text-sm font-medium transition-colors ".concat(T===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:S(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===T&&(0,r.jsx)(aM,{worktreeId:a,className:"h-full",onInsertToMessage:g}),"logs"===T&&(0,r.jsx)(rn,{worktreeId:a,className:"h-full",onInsertToMessage:g,instances:v}),"agent"===T&&(b&&v&&y&&j&&w?(0,r.jsx)("div",{className:"h-full overflow-y-auto",children:(0,r.jsx)(rg,{worktreeId:a,instances:v,onInstancesChange:y,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k})}):(0,r.jsx)(ro,{worktreeId:a,selectedAgents:l,onSelectedAgentsChange:o,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:h,maxAgents:x,availableAgents:f,persistToServer:p})),"timer"===T&&(0,r.jsx)(rM,{worktreeId:a,instances:v,selectedAgents:l}),"todo"===T&&(0,r.jsx)(aD,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(r1,{worktreeId:a,className:"h-full"}),"verification"===T&&N&&(0,r.jsx)(su,{state:N,className:"h-full"}),"env"===T&&(0,r.jsx)(sO,{worktreeId:a,className:"h-full"})]})]})}),sB=["status","changes","history","advanced"],sV="commandmate:gitPane:",sW={activeTab:"".concat(sV,"activeTab"),historyOpen:"".concat(sV,"historyOpen"),advancedOpen:"".concat(sV,"advancedOpen")};function sH(e){return"string"==typeof e&&sB.includes(e)}let sU=e=>"boolean"==typeof e,sK=i.useLayoutEffect;function s$(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let sq=(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,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(!1),j=(0,i.useRef)(null),w=(0,i.useRef)(null),[k,N]=(0,i.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,i.useCallback)(()=>{let e=j.current,t=w.current;if(!e||!t)return;let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),r=window.innerHeight-n.bottom,s=n.top;N({top:s$(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:s$(n.left,a.width,window.innerWidth)})},[]);sK(()=>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}),p(!1)},[]),E=(0,i.useCallback)(()=>{g&&(u(g,v),b(null))},[g,v,u]);return(0,r.jsxs)("div",{className:"relative",ref:j,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:()=>p(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,a_.createPortal)((0,r.jsx)("div",{ref:w,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}),g&&(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:g.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")})]})]})})]})}),sG=(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})]})}),sJ=(0,i.createContext)(null);function sY(e){let{value:t,children:n}=e;return(0,r.jsx)(sJ.Provider,{value:t,children:n})}function sQ(){let e=(0,i.useContext)(sJ);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let sX=(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})})}),sZ={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"},s0={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},s1=(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:sB.map(e=>{let s=e===t,l=a(s0[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)(sX,{path:sZ[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function s2(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=sQ();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(s1,{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 s5={added:"text-success-foreground",modified:"text-warning-foreground",deleted:"text-danger-foreground",renamed:"text-info",untracked:"text-accent-600 dark:text-accent-400",unmerged:"text-warning-foreground"},s4=(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"})})}),s3=(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)(aF.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),s6=(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})}),s8=(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})}),s9={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"}},s7=(0,i.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:s,onRefresh:l,refreshing:o=!1}=e,{isMobile:d}=sQ(),m=(0,c.c)("worktree"),h=(0,eX.Ym)(),x=(0,i.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,nC.fw)(new Date(e).toISOString(),nN(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)(s4,{})})]}),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(s9[f].tooltipKey),children:m(s9[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})]})]})]})]})}),le=(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:p}=sQ(),g=(0,c.c)("worktree"),b="running"===t,v=null!=a?a:g("git.network.failed"),[y,j]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(!b)return void j(0);let e=setInterval(()=>j(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:g("git.network.quickActions")}),(0,r.jsxs)("div",{className:"flex items-center ".concat(p?"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:g("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:g("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:g("git.network.noUpstreamTooltip"),children:g("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(p?"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:g("git.network.progress",{operation:g("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:g("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:g("git.network.conflicts",{files:l.join(", ")})})]})}),lt=(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"),[p,g]=(0,i.useState)(o),[b,v]=(0,i.useState)(null),[y,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(!1),[N,C]=(0,i.useState)(null),S=(0,i.useCallback)(async e=>{if(b===e){v(null),j(null),C(null);return}v(e),j(null),C(null),k(!0);try{let t=await x(e,l);j(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:()=>g(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:p?"▼":"▶"}),f("git.changes.listHeader",{title:t,count:a.length})]}),p&&0===a.length&&(0,r.jsx)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:f("git.changes.empty")}),p&&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(s5[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:[w&&(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}),!w&&!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)(s6,{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))})})]})}),ln=(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:p,onPreview:g,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=sQ(),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)(s4,{})})]}),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)(lt,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:M,busy:o,onDiff:p,onPreview:g,onToggleStage:v}),(0,r.jsx)(lt,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:T,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:M,busy:o,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsx)(lt,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:E,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:M,busy:o,onDiff:p,onPreview:g,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=>j(!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:w,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})]})]})]})}),la=(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:p,onToggleInlineDiff:g,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=sQ(),T=(0,c.c)("worktree"),[E,I]=(0,i.useState)(!0),[M,A]=(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)(s4,{})})]}),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:()=>g(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")})]}),p&&(0,r.jsx)(s8,{message:p}),!f&&!p&&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(w===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(s5[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:[j&&(0,r.jsx)(s8,{message:j}),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&&!j&&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(w===e.path?"bg-accent-50 dark:bg-accent-900/30":""),children:[(0,r.jsx)("span",{className:"inline-block w-14 font-medium ".concat(s5[e.status]),children:e.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:e.path})]})},e.path))})]}),S&&w&&(0,r.jsxs)("div",{className:"border-t border-border",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>A(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:w})]}),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)(s6,{line:e},t))})})}),!C&&!N&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:T("git.history.noDiff")})]})]}),!S&&w&&!j&&(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:w})})]})]})]})});function lr(e){return"`"+e+"`"}let ls={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},ll=(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:p}=sQ(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!f),[j,w]=(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),A=(0,i.useCallback)(()=>{0!==k.trim().length&&(h(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,h]),L=(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?"▼":"▶"}),g("git.branches.title")]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>w(!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:g("git.branches.newButton")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":g("git.branches.refresh"),children:(0,r.jsx)(s4,{})})]})]}),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:g(ls[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:g("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:g("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:g("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":g("git.branches.deleteBranch",{name:e.name}),children:g("git.branches.delete")})]},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})]}),j&&(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:g("git.branches.createTitle")}),(0,r.jsx)("input",{type:"text",value:k,onChange:e=>N(e.target.value),placeholder:g("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":g("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":g("git.branches.baseLabel"),children:[(0,r.jsx)("option",{value:"",children:g("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:[p&&(0,r.jsx)(s3,{className:"mr-auto",testId:"branch-create-ask-ai",disabled:0===k.trim().length,onClick:()=>{p(function(e,t,n){let a=n&&n.trim().length>0?lr(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:lr(t.trim())})}(g,k,C)),w(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>w(!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:A,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:g("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:[g("git.branches.deleteTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:T.name}),g("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"}),g("git.branches.forceDeleteLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[p&&T&&(0,r.jsx)(s3,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(g(I?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:lr(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:L,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:g("git.branches.delete")})]})]})})]})}),li=(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:p}=e,{isMobile:g,onInsertToMessage:b}=sQ(),v=(0,c.c)("worktree"),y=(0,c.c)("common"),[j,w]=(0,i.useState)(!g),[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:()=>w(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:j?"▼":"▶"}),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:[j&&b&&t.length>0&&(0,r.jsx)(s3,{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)(s4,{})})]})]}),j&&(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)(s3,{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:()=>{p(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")})]})]})]})}),lo={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},lc=(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:p}=sQ(),g=(0,c.c)("worktree"),b=(0,c.c)("common"),[v,y]=(0,i.useState)(!1),[j,w]=(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),[A,L]=(0,i.useState)(!1),[R,P]=(0,i.useState)(!1),[D,F]=(0,i.useState)(!0),O=k?"HEAD":t,z=!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?"▼":"▶"}),g("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:g("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:g("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:g("git.danger.forcePushOpen")})]}),!t&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("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:g("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"}),g("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"}),g("git.danger.resetTargetSelectedPrefix"),t?g("git.danger.resetTargetSelectedHash",{hash:t.slice(0,7)}):g("git.danger.resetTargetNoneSelected")]})]}),(0,r.jsx)(m.z6,{value:j,onValueChange:e=>w(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)}),g(lo[e])]},e))}),"hard"===j&&(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:g("git.danger.resetHardWarning")}),d&&(0,r.jsx)("p",{className:"text-xs text-danger-foreground","data-testid":"reset-hard-session-warning",children:g("git.danger.runningSessionWarning")}),(0,r.jsx)("input",{type:"text",value:C,onChange:e=>S(e.target.value),placeholder:g("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:[p&&(0,r.jsx)(s3,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(p("hard"===j?g("git.aiPrompts.resetHard",{target:lr(O)}):g("git.aiPrompts.reset",{target:lr(O),mode:j})),E(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||z||"hard"===j&&C!==(null!=l?l:""),onClick:()=>{O&&(u(O,j,"hard"===j?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:g("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:g("git.danger.revertTitle")}),(0,r.jsxs)("p",{className:"text-xs text-foreground mb-2",children:[g("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:g("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:A,onCheckedChange:e=>L(!0===e),"data-testid":"revert-no-commit"}),g("git.danger.revertNoCommit")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(s3,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(g("git.aiPrompts.revert",{commit:lr(t.slice(0,7))})),M(!1),L(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{h(t,A),M(!1),L(!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:g("git.danger.revert")}),(0,r.jsx)("button",{type:"button",onClick:()=>{M(!1),L(!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:g("git.danger.forcePushTitle")}),(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-protected-branch-warning",children:g("git.danger.protectedBranchWarning")}),d&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"force-push-session-warning",children:g("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:D,onCheckedChange:e=>F(!0===e),"data-testid":"force-push-with-lease"}),g("git.danger.forceWithLease")]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[p&&(0,r.jsx)(s3,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(e,t){let{branch:n,ahead:a}=t,r=n?lr(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:lr("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(g,{branch:l,ahead:null!=o?o:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(D),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:g("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")})]})]})]})}),ld=(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:p,setActiveTab:g,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,tZ.V)({key:sW.activeTab,defaultValue:"status",validate:sH}),{value:a,setValue:r}=(0,tZ.V)({key:sW.historyOpen,defaultValue:!0,validate:sU}),{value:s,setValue:l}=(0,tZ.V)({key:sW.advancedOpen,defaultValue:!1,validate:sU}),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}}(),w=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:A,inlineFilesLoading:L,inlineFilesError:R,selectedFile:P,diffContent:D,isLoading:F,isLoadingFiles:O,isLoadingDiff:z,commitError:_,detailError:B,setDiffContent:V,fetchCommits:W,handleCommitSelect:H,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,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[j,w]=(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),A=(0,i.useCallback)(async()=>{w(!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{w(!1)}},[e]),L=(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)(()=>{A()},[A]);let P=(0,i.useCallback)(e=>{s(e),L(e)},[L]),D=(0,i.useCallback)(e=>{r&&(b(e),R(r,e))},[r,R]),F=(0,i.useCallback)(async t=>{if(c===t){d(null),m([]),p(null);return}d(t),m([]),p(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(()=>({}));p(e.error||"Failed to fetch commit details");return}let a=await n.json();m(Array.isArray(a.files)?a.files:[])}catch(e){p("Failed to fetch commit details")}finally{x(!1)}},[e,c]),O=(0,i.useCallback)((e,t)=>{s(e),b(t),o(u),R(e,t)},[u,R]),z=(0,i.useCallback)(()=>{s(null),o([]),b(null),y(null),M(null),A()},[A]);return{commits:n,selectedCommit:r,changedFiles:l,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:h,inlineFilesError:f,selectedFile:g,diffContent:v,isLoading:j,isLoadingFiles:k,isLoadingDiff:C,commitError:T,detailError:I,setDiffContent:y,fetchCommits:A,handleCommitSelect:P,handleFileSelect:D,handleToggleInlineDiff:F,handleInlineDiffFile:O,handleRefresh:z}}(l,o),G=(0,i.useCallback)(async()=>{await W(),await S()},[W,S]),{staged:J,stagedLoading:Y,stagedError:Q,opBusy:X,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,p]=(0,i.useState)(!1),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(null),j=(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)(()=>{j()},[j]);let w=(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 j()}catch(e){d("Failed to stage file")}finally{m(!1)}},[e,j]),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 j()}catch(e){d("Failed to unstage file")}finally{m(!1)}},[e,j]),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(""),p(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,h,f,j,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:p,committing:g,changesCommitError:v,fetchStaged:j,handleStage:w,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)=>{V(e),o(e,t)},[V,o]),onCommitted:G}),{branches:em,branchInclude:eh,branchesLoading:ex,branchesError:ef,branchBusy:ep,branchActionError:eg,fetchBranches:eb,handleBranchIncludeChange:ev,handleBranchesRefresh:ey,handleCheckout:ej,handleBranchCreate:ew,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),p=(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)(()=>{p(s)},[p,s]);let g=(0,i.useCallback)(e=>{l(e)},[]),b=(0,i.useCallback)(()=>{p(s)},[p,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(),p(s)])}catch(e){f("Failed to checkout branch")}finally{h(!1)}},[e,s,n,p]),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 p(s)}catch(e){f("Failed to create branch")}finally{h(!1)}},[e,s,p]),j=(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 p(s)}catch(e){f("Failed to delete branch")}finally{h(!1)}},[e,s,p]);return{branches:a,branchInclude:s,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:x,fetchBranches:p,handleBranchIncludeChange:g,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(l,{onCheckoutCascade:(0,i.useCallback)(async()=>{await Promise.all([S(),es(),W()])},[S,es,W])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eT,stashActionError:eE,stashConflictNotice:eI,fetchStash:eM,handleStashPush:eA,handleStashPop:eL,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),p=(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)(()=>{p()},[p]);let g=(0,i.useCallback)(async()=>{await Promise.all([p(),n()])},[p,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 g()}catch(e){h(n)}finally{u(!1)}},[g]),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:p,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:eD,dangerActionError:eF,dangerConflictNotice:eO,handleReset:ez,handleRevert:e_}=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),W()])},[S,es,eb,eh,W])}),{operation:eB,progressState:eV,error:eW,errorReason:eH,conflict:eU,conflictFiles:eK,runFetch:e$,runPull:eq,runPush:eG,abort:eJ}=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)([]),p=(0,i.useRef)(null),g=(0,i.useRef)(n);(0,i.useEffect)(()=>{g.current=n},[n]),(0,i.useEffect)(()=>()=>{var e;null==(e=p.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;p.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),p.current=null,null==(o=g.current)||o.call(g,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=p.current)||e.abort()},[])}}(l,{onCascade:(0,i.useCallback)(e=>{S(),eb(eh),"pull"===e&&(es(),W())},[S,eb,eh,es,W])}),eY="auth_failed"===eH?f("git.network.authFailedGuidance"):"protected_branch"===eH?f("git.danger.protectedBranchWarning"):eW,eQ="running"===eV&&("push"===eB||"pull"===eB),eX=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,i.useCallback)(()=>{e$({})},[e$]),e0=(0,i.useCallback)(()=>eu(()=>eG({setUpstream:!eX})),[eu,eG,eX]);af({intervalMs:5e3,enabled:"running"!==eV,onPoll:S});let e1=(0,i.useMemo)(()=>({isMobile:d,onDiffSelect:o,onInsertToMessage:h}),[d,o,h]),e2=(0,r.jsx)(s7,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eV}),e5=(0,r.jsx)(le,{progressState:eV,operation:eB,error:eY,conflict:eU,conflictFiles:eK,hasUpstream:eX,onPull:()=>eq({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(sq,{branches:em,busy:ep||eQ,actionError:eg,hasRunningSession:w,isMobile:d,onCheckout:ej})}),e4=(0,r.jsx)(ln,{staged:J,loading:Y,error:Q,busy:X||eQ,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)(la,{commits:T,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:q,selectedCommit:E,onCommitSelect:H,inlineDiffCommit:M,inlineFiles:A,inlineFilesLoading:L,inlineFilesError:R,onToggleInlineDiff:K,onInlineDiffFile:$,changedFiles:I,isLoadingFiles:O,detailError:B,selectedFile:P,onFileSelect:U,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(sG,{open:y,onToggle:j,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"===eV,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)(ll,{branches:em,include:eh,loading:ex,error:ef,busy:ep||eQ,actionError:eg,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(li,{stashes:eN,loading:eC,error:eS,busy:eT||eQ,actionError:eE,conflictNotice:eI,hasRunningSession:w,onRefresh:eM,onPush:eA,onPop:eL,onApply:eR,onDrop:eP}),(0,r.jsx)(lc,{selectedCommit:E,busy:eD||eQ,actionError:eF,conflictNotice:eO,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:w,onReset:ez,onRevert:e_,onForcePush:e=>eG(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(sY,{value:e1,children:(0,r.jsx)(s2,{activeTab:p,onTabChange:g,className:x,statusSection:e2,quickActionsSection:e5,changesSection:e4,historySection:e3,advancedSection:e6})})}),lu=(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=ly(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)(lj,{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")})}),lm=(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:p,onMove:g,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:A,disableAutoFollow:L,historySubTab:R,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:W,useInstanceManagement:H,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,verification:G,toolsSubTabRequest:J}=e,Y=(0,c.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(T,{componentName:"TerminalDisplay",children:(0,r.jsx)(ni,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:L})});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:Y("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:Y("detail.subTabGit")})]}),"message"===R?(0,r.jsx)(T,{componentName:"HistoryPane",children:(0,r.jsx)(n1,{messages:s,worktreeId:n,onFilePathClick:o,className:"flex-1 min-h-0",showToast:j,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:W})}):(0,r.jsx)(T,{componentName:"GitPane",children:(0,r.jsx)(ld,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var Q;return(0,r.jsx)(T,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(ak,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(av,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:h,onRename:x,onDelete:f,onUpload:p,onMove:g,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(Q=y.results)?void 0:Q.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(T,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(s_,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:E,onVibeLocalModelChange:I,vibeLocalContextWindow:M,onVibeLocalContextWindowChange:A,onInsertToMessage:F,useInstanceManagement:H,instances:U,onInstancesChange:K,visibleInstanceIds:$,onToggleInstanceVisible:q,modelByInstance:lv(null==a?void 0:a.sessionStatusByInstance),verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(lu,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),lh="v".concat("0.29.0"),lx=[{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 lf(e,t,n){if(!e)return null;let a=t?"".concat(e," \xb7 ").concat(t):e;return n?"".concat(n," \xb7 ").concat(a):a}function lp(e,t){if(!e||!e.liveness&&!e.degradedReason)return null;let n=t("sse"===e.kind?"agentSource.kindSse":"scraper"===e.kind?"agentSource.kindScraper":"agentSource.kindHooks"),a=void 0===e.degradedReason?null:"port_identity_changed"===e.degradedReason?t("agentSource.reasonPortIdentityChanged"):"heartbeat_stale"===e.degradedReason?t("agentSource.reasonHeartbeatStale"):"not_subscribed"===e.degradedReason?t("agentSource.reasonNotSubscribed"):t("agentSource.reasonOther",{reason:e.degradedReason}),r=["stale"===e.liveness?t("agentSource.livenessStale"):"live"===e.liveness?t("agentSource.livenessLive"):null,a].filter(e=>null!==e).join(" \xb7 ");return r?t("agentSource.line",{kind:n,state:r}):t("agentSource.lineBare",{kind:n})}function lg(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return"number"==typeof e&&Number.isFinite(e)?new Intl.NumberFormat(t,{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(e):null}function lb(e,t,n,a){var r;let s=lg(null==e?void 0:e.cost,a),l=(r=null==t?void 0:t.tokens,"number"==typeof r&&Number.isFinite(r)?new Intl.NumberFormat(a,{notation:"compact",maximumFractionDigits:1}).format(r):null),i=[];return s&&i.push(s),l&&i.push("number"==typeof(null==t?void 0:t.percent)?n("agentSession.context",{tokens:l,percent:t.percent}):l),i.length>0?i.join(" \xb7 "):null}function lv(e){if(!e)return{};let t={};for(let[n,a]of Object.entries(e)){let e=lf(null==a?void 0:a.model,null==a?void 0:a.reasoningEffort);e&&(t[n]=e)}return t}function ly(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 V.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 lj=(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:p,isSaving:g,handleSave:b,handleCancel:v,startEditing:y}=o,j=(0,c.c)("worktree"),w=(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,eT.l)(s.path),N(!0),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>N(!1),em.pX)}catch(e){}},[s.path]),M=(0,i.useCallback)(async()=>{try{await (0,eT.l)(s.repositoryPath),S(!0),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>S(!1),em.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:j("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:j("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":j("detail.copyRepositoryPath"),title:C?j("detail.copied"):j("detail.copyRepositoryPath"),children:C?(0,r.jsx)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ew.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:j("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":j("detail.copyWorktreePath"),title:k?j("detail.copied"):j("detail.copyPath"),children:k?(0,r.jsx)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ew.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:j("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":j("detail.worktreeStatusLabel"),children:lx.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:j(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:j("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:j("actions.edit")})]}),x?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:f,onChange:e=>p(e.target.value),placeholder:j("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:g,className:"px-4 py-2 bg-accent-600 text-white rounded-lg hover:bg-accent-700 disabled:opacity-50 text-sm font-medium",children:g?j("actions.saving"):j("actions.save")}),(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:v,disabled:g,className:"px-4 py-2 bg-muted text-foreground rounded-lg hover:bg-border disabled:opacity-50 text-sm font-medium",children:w("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:j("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:j("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:j("detail.lastUpdated")}),(0,r.jsx)("p",{className:"text-sm text-foreground",children:new Date(s.updatedAt).toLocaleString()})]}),(0,r.jsx)(e9,{version:lh,className:l}),(0,r.jsx)(ts,{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:j("detail.logs")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"text-sm text-accent-600 hover:text-accent-800",children:d?j("detail.hide"):j("detail.show")})]}),d&&(0,r.jsx)(e4,{worktreeId:a})]})]})}),lw=(0,i.memo)(function(e){var t,n,a,s;let{worktreeName:l,repositoryName:o,description:d,status:u,gitStatus:f,onBackClick:p,onInfoClick:g,hasUpdate:b,worktreeStatus:v,onWorktreeStatusChange:y,sessionStatusByCli:j,sessionStatusByInstance:w,instances:N,activeInstanceId:C,onActiveInstanceChange:S,onAgentDragStart:T,onAgentDragEnd:E,onKillSession:I,verificationChip:M,agentSessionByInstance:A}=e,L=(0,c.c)("worktree"),R=(0,eX.Ym)(),P=(0,c.c)("common"),D=eZ.sb[u],F=D?L(D):void 0,[O,z]=(0,i.useState)(null),_=null==N?void 0:N.find(e=>e.id===C),B=!!C&&null!=(s=null!=(a=null==w||null==(t=w[C])?void 0:t.isRunning)?a:_?null==j||null==(n=j[_.cliTool])?void 0:n.isRunning:void 0)&&s,V=(0,i.useCallback)((e,t)=>{e.dataTransfer.setData(td,t),e.dataTransfer.effectAllowed="move",z(t),null==T||T(t)},[T]),W=(0,i.useCallback)(()=>{z(null),null==E||E()},[E]),H=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:p,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":L("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:L("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:F}),(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:L("git.uncommittedChanges"),children:"*"})]}),H&&(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:H})]})]})]}),M&&(0,r.jsx)("div",{className:"min-w-0 max-w-[360px]",children:M})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[N&&N.length>0&&(()=>{var e,t,n,a;let s=(0,e2.Uw)(N.map(e=>{var t;return{item:e,status:(0,ti.kA)(null!=(t=null==w?void 0:w[e.id])?t:null==j?void 0:j[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,o=N.some(e=>{var t,n;return(null==(t=null!=(n=null==w?void 0:w[e.id])?n:null==j?void 0:j[e.cliTool])?void 0:t.awaitingInstruction)===!0});return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0","data-testid":"desktop-agent-status-row",children:[s.map(e=>{var t;if("overflow"===e.slot)return null;let n=e.item,a=(0,to.sw)(n),s=L("detail.statusPill",{label:a,status:P("status.".concat(e.status))}),l=null==w?void 0:w[n.id],i=null==A?void 0:A[n.id],o=lf(null==l?void 0:l.model,null==l?void 0:l.reasoningEffort,null==i||null==(t=i.session)?void 0:t.agent),c=o?L("detail.statusPillWithModel",{label:a,status:P("status.".concat(e.status)),model:o}):s,d=lb(null==i?void 0:i.session,null==i?void 0:i.context,L,R),u=d?L("detail.statusPillWithUsage",{base:c,usage:d}):c,m=lp(null==l?void 0:l.eventSource,L),x=m?L("detail.statusPillWithSource",{base:u,source:m}):u,f=e.isActive,p={draggable:!0,onDragStart:e=>V(e,n.id),onDragEnd:W},g=O===n.id?" opacity-50 cursor-grabbing":"";return"pill"===e.slot?(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==S?void 0:S(n.id),...p,"aria-label":x,title:x,"aria-pressed":f,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(g),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:s})]},n.id):(0,r.jsx)(e0.m_,{content:x,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==S?void 0:S(n.id),...p,"aria-label":x,"aria-pressed":f,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(f?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(g),children:(0,r.jsx)(h.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0})})},n.id)}),l.length>0&&(0,r.jsxs)(e1.rI,{children:[(0,r.jsx)(e1.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":L("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)(e1.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=L("detail.statusPill",{label:(0,to.sw)(t),status:P("status.".concat(e.status))});return(0,r.jsxs)(e1._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)})})]}),o&&(0,r.jsx)("span",{"data-testid":"desktop-awaiting-instruction-badge",className:"flex-shrink-0 rounded-full bg-success-subtle px-1.5 py-0.5 text-[10px] font-medium leading-4 text-success-foreground",title:L("awaitingInstruction.label"),children:L("awaitingInstruction.badge")})]})})(),I&&B&&(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":L("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),P("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":L("detail.worktreeStatusLabel"),children:lx.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:L(e.labelKey)},e.labelKey)})}),(0,r.jsx)(tm.g,{}),(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",onClick:g,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":L("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:L("detail.info")}),b&&(0,r.jsx)(k,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":L("tabs.updateAvailable")})]})]})]})}),lk=(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=ly(n,l,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(tl.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)(lj,{worktreeId:t,worktree:n,cardClassName:"bg-muted rounded-lg p-4",descriptionEditor:h,showLogs:o,onToggleLogs:()=>d(!o),onWorktreeUpdate:l})})}):null}),lN=(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")})]})})}),lC=(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")})]})})}),lS=(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,p=(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]),g=(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:g,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)(T,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(nH.f,{onResize:p,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)(T,{componentName:"TerminalPane",children:n})})]})})});var lT=n(9540),lE=n(92001),lI=n(39332),lM=n(11047),lA=n(16485),lL=n(78192),lR=n(39324),lP=n(80298),lD=n(55867);let lF=[{id:"files",labelKey:"activityBar.files",icon:lE.A},{id:"git",labelKey:"activityBar.git",icon:lI.A},{id:"notes",labelKey:"activityBar.notes",icon:lM.A},{id:"schedules",labelKey:"activityBar.schedules",icon:lA.A},{id:"agent",labelKey:"activityBar.agent",icon:lL.A},{id:"timer",labelKey:"activityBar.timer",icon:lR.A},{id:"todo",labelKey:"activityBar.todo",icon:lP.A},{id:"skills",labelKey:"activityBar.skills",icon:aF.A},{id:"verification",labelKey:"activityBar.verification",icon:r2.A},{id:"env",labelKey:"activityBar.env",icon:lD.A}],lO=new Set(lF.map(e=>e.id)),lz="files",l_="__closed__";function lB(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var lV=n(32916);let lW=(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,lV.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)%lF.length;null==(r=l.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+lF.length)%lF.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[lF.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)(e0.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)(lT.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:lF.map((e,a)=>{let i=e.icon,o=t===e.id,c=s(e.labelKey);return(0,r.jsx)(e0.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)})})]})}),lH="worktree-activity-pane",lU={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentSettingsPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},lK=(0,i.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:lH,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=lU[t];return(0,r.jsx)("div",{id:lH,"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)(T,{componentName:l,children:null!=s?s:null})})}),l$=(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)(eE.A,{className:"w-4 h-4"})})]})}),lq=[{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"]}],lG=lq.map(e=>e.extension),lJ=[".md",".html",".htm",".yaml",".yml"];eS.j6,eS.j6;var lY=n(40051);function lQ(){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 lX=(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)(lQ,{})}),lZ=(0,o.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(lQ,{})}),l0=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(lQ,{})}),l1=/^---\s*\nmarp:\s*true/;function l2(){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 l5(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 l4(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 p=async()=>{try{await (0,eT.l)(t),u(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>u(!1),em.pX)}catch(e){}},g=async()=>{if(s)try{await (0,eT.l)(s),h(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h(!1),em.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:p,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)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(ew.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:g,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)(et.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(en.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)(eI.A,{className:"w-4 h-4"}):(0,r.jsx)(eM.A,{className:"w-4 h-4"})})]})]})}function l3(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),p=x.length,g=Math.max(null!=o?o:p,p),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=eH.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=eH.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]),j=(null!=(t=null==s?void 0:s.length)?t:0)>0?s[null!=l?l:0]:-1,w=(0,no.Te)({count:g,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(g-1,e-1));w.scrollToIndex(t,{align:"center"})},[l,s,w,g]);let k=w.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,eP.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:p}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:h,"data-testid":"file-content-code",children:(0,r.jsx)("div",{style:{height:w.getTotalSize(),width:"100%",position:"relative"},children:k.map(e=>{let t=e.index+1,n=t-f,a=n>=0&&n<p,s=t===j,l=y.has(t),i=a?v(n):"";return(0,r.jsxs)("div",{"data-line":t,"data-index":e.index,ref:w.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)(lY.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function l6(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 l8(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,p]=(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:()=>p("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:()=>p("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)(l4,{filePath:s,isMaximized:d,onToggleMaximize:u,copyableContent:l})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===f?(0,r.jsx)(l6,{slides:t,fileName:n}):(0,r.jsx)(l0,{worktreeId:a,filePath:s,onSave:o,initialViewMode:"split",onDirtyChange:m,onOpenFile:h})})]})}function l9(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:eR.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(l4,{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 l7(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=eW(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(l4,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(l$,{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)(l3,{content:n.content,extension:"md",searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(l0,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function ie(e){var t,n;let{tab:a,content:s,worktreeId:l,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=eW(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)(l4,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:s.content,onSearch:u.openSearch}),u.searchOpen&&(0,r.jsx)(l$,{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)(l3,{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 it=(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,p=(0,c.c)("worktree"),g=(0,i.useRef)(p);g.current=p;let b=(0,i.useRef)(!1),[v,y]=(0,i.useState)(null),[j,w]=(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,af({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,eP.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)(()=>{w(e=>!e)},[]);(0,i.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&w(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]),(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,eP.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)||g.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:g.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||!l1.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)(l2,{});if(l.error)return(0,r.jsx)(l5,{error:l.error});if(!l.content)return null;let{content:T}=l;return T.isImage?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(l4,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eb.a,{src:T.content,alt:T.path,mimeType:T.mimeType})})]})}):T.isVideo?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(l4,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ev.u,{src:T.content,mimeType:T.mimeType})})]})}):T.isPdf?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(l4,{filePath:l.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lZ,{dataUri:T.content,filePath:l.path})})]})}):T.isHtml?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(l4,{filePath:l.path,isMaximized:j,onToggleMaximize:N,copyableContent:T.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(lX,{worktreeId:o,filePath:l.path,htmlContent:T.content,onFileSaved:h,onOpenFile:f})})]})}):"md"===T.extension?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(l8,{marpSlides:v,fileName:l.name,worktreeId:o,filePath:l.path,contentText:T.content,onFileSaved:h,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:f}):(0,r.jsx)(l7,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})}):!function(e){if(!e)return!1;let t=e.toLowerCase();return lJ.includes(t)}("."+T.extension)?(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)(ie,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):(0,r.jsx)(l9,{isMaximized:j,onToggle:N,filePath:l.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(l7,{tab:l,content:T,worktreeId:o,isMaximized:j,onToggleMaximize:N,onFileSaved:h,onDirtyChange:k,onOpenFile:f})})})});function ia(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 ir=(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)(eE.A,{className:"w-3 h-3"})})]})}),is=(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,p]=(0,i.useState)(!1),g=(0,i.useRef)(null),b=(0,i.useRef)(null),v=(0,i.useRef)({x:0,y:0}),[y,j]=(0,i.useState)({x:0,y:0}),w=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=>{g.current&&!g.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[f]),(0,i.useLayoutEffect)(()=>{let e=e=>{v.current=e,j(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:ia(n.left-v.current.x,n.width,window.innerWidth),y:ia(n.top-v.current.y,n.height,window.innerHeight)})},[f]);let C=(0,i.useCallback)(e=>{p(!1),null==h||h(e)},[h]),S=(0,i.useCallback)(()=>{p(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)(ir,{tab:e,isActive:t===n,onActivate:l,onClose:s},e.path))}),N.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:g,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)(tc.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:w&&(0,r.jsx)(it,{tab:w,worktreeId:a,onLoadContent:o,onLoadError:c,onSetLoading:d,onFileSaved:u,onDirtyChange:m,onOpenFile:x},w.path)})]})}),il=(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})}),ii=(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)(il,{line:e},t))})})})]})}),io="commandmate.worktree.filePanelCollapsed",ic="commandmate:filePanelStateChange";function id(){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(io);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(ic,e),()=>window.removeEventListener(ic,e)},[]);let a=(0,i.useCallback)(e=>{t(e);try{window.localStorage.setItem(io,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(ic,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,i.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let iu=(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:p,onDirtyChange:g,onMoveToFront:b,onOpenFile:v}=e,y=(0,c.c)("worktree"),j=(0,i.useRef)(null),[w,k]=(0,i.useState)(50),{collapsed:N,toggle:C}=id(),S=(0,i.useCallback)(e=>{let t=j.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(w,"%")}),[w]),E=(0,i.useMemo)(()=>({width:"".concat(100-w,"%")}),[w]),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:j,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:j,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)(nH.f,{onResize:S,orientation:"horizontal",ariaValueNow:w}),(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&&p?(0,r.jsx)(ii,{diff:x,filePath:f,onClose:p}):(0,r.jsx)(is,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:s,onClose:l,onActivate:o,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:h,onDirtyChange:g,onMoveToFront:b,onOpenFile:v})})]})]}):(0,r.jsx)("div",{className:"h-full",children:I})});var im=n(7125),ih=n(22509),ix=n(54485),ip=n(70198);let ig={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},ib=new Set(to.XH);function iv(e){return"".concat("commandmate:terminalSplits:").concat(e)}function iy(e){return"object"==typeof e&&null!==e}function ij(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:ig.splits.map(e=>({...e})),widths:[...ig.widths]}}function iw(e){let t=e.reduce((e,t)=>e+t,0);return t>0?e.map(e=>e/t):e.map(()=>1/e.length)}function ik(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?iw(e.widths):l.length<e.widths.length?iw(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),{splits:l,widths:n})}function iN(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(iv(e));if(!n)return ij(t);let a=JSON.parse(n),r=function(e){if(!iy(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(!iy(e))return null;let t=e.cliToolId;if("string"!=typeof t||!ib.has(t))return null;let n=e.instanceId,r="string"==typeof n&&(0,to.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:iw(r.widths)};return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),ij(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),ij(t)}}(e,t);return n?ik(a,t):a}let iC=(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:p,setSplitWidth:g,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:y,setFocusedSplitIndex:j}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,i.useState)(()=>iN(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(iN(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=>ik(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(iv(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:iw(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 p=(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},[]),g=(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:p,setSplitWidth:g,resetWidths:b,availableInstanceIds:v,focusedSplitIndex:s,setFocusedSplitIndex:y}}(t,n,a),w=(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}=nW(),{collapsed:T,toggle:E}=id(),I=!T,M=(0,i.useRef)(null),[A,L]=(0,i.useState)(!1),R=(0,i.useRef)(m.length),[P,D]=(0,i.useState)(null);(0,i.useEffect)(()=>{m.length>R.current&&D(m.length-1),R.current=m.length},[m.length]),(0,i.useEffect)(()=>{null==l||l(y)},[y,l]);let F=(0,i.useRef)(0),O=(0,i.useRef)(m);O.current=m,(0,i.useEffect)(()=>{if(!u||u.token===F.current)return;F.current=u.token;let{instanceId:e}=u,t=O.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void j(t);p(0,e)&&j(0)}},[u,p,j]),(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(),j(P),D(null)},[P,j]);let z=(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,g(l))},[h,g]),_=(0,i.useCallback)(()=>L(!0),[]),B=(0,i.useCallback)(()=>L(!1),[]),V=(0,i.useCallback)(()=>{b(),S(40)},[b,S]),W=m.length<3&&!A,H=m.length>1&&!A,U=m.length>1||N,K=(0,i.useMemo)(()=>m.map((e,t)=>()=>j(t)),[m,j]),$=(0,i.useMemo)(()=>m.map((e,t)=>e=>p(t,e)),[m,p]),q=(0,i.useMemo)(()=>m.map((e,t)=>e=>{var n,a;let r=(0,to.sw)(null!=(a=w.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}p(t,e)&&(null==d||d(e),null==o||o("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[m,p,o,d,w]);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:!W,"aria-disabled":!W,"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)(rf.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:f,disabled:!H,"aria-disabled":!H,"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)(im.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button",onClick:V,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)(ih.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)(ix.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)(ip.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:w.get(e.instanceId),availableInstances:v(t).map(e=>w.get(e)).filter(e=>void 0!==e),onInstanceChange:$[t],onFocus:K[t],isFocused:y===t,onDropInstance:q[t]})}),a?null:(0,r.jsx)(iS,{resizerIdx:t,ariaValueNow:h.length?h[t]/h.reduce((e,t)=>e+t,0)*100:50,onResize:z,onStart:_,onEnd:B,onDoubleClick:b})]},"split-".concat(t))})})]})});function iS(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)(nH.f,{onResize:c,orientation:"horizontal",ariaValueNow:n,onDoubleClick:o})})}function iT(e){if(!e)return null;let t=e.decisionId;return"string"==typeof t&&""!==t?t:null}let iE="\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(),iI="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",iM="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring";function iA(e){let{promptData:t,answering:n,onRespond:a,decisionId:s,onDismiss:l,labelId:o,cliToolName:d}=e,u=(0,c.c)("prompt"),[h,x]=(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}),[f,p]=(0,i.useState)(""),[g,b]=(0,i.useState)(!1),v=(0,i.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===h))?e:null},[t,h]),y=(null==v?void 0:v.requiresTextInput)===!0,j=n||g,w=(0,i.useCallback)(async e=>{if(!j){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]),k=(0,i.useCallback)(async()=>{if(!j&&null!==h){b(!0);try{let e=y&&f.trim()?f.trim():h.toString();await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s,h,y,f]),N=(0,i.useCallback)(async e=>{if(!j&&s){b(!0);try{await a(e,s)}catch(e){}finally{b(!1)}}},[j,a,s]);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:o,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:"?"}),d?u("confirmationFrom",{toolName:d}):u("confirmationFromClaude")]}),l&&(0,r.jsx)(m.$n,{variant:"ghost",type:"button",onClick:l,"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"})})})]}),S(t)&&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}),"multiple_choice"===t.type&&t.askUserQuestion&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ask-user-question-progress",children:t.askUserQuestion.questionCount>1?u("askUserQuestionProgress",{index:t.askUserQuestion.questionIndex+1,total:t.askUserQuestion.questionCount}):u("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:S(t)?t.question:u("unclassifiedTitle")}),j&&(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:u("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(iF,{promptData:t,disabled:j,onYes:()=>w("yes"),onNo:()=>w("no")}),"multiple_choice"===t.type&&(0,r.jsx)(iO,{promptData:t,disabled:j,selectedOption:h,onSelectOption:x,textInputValue:f,onTextInputChange:p,showTextInput:y,onSubmit:k}),!S(t)&&(0,r.jsx)(iL,{promptData:t,decisionId:s,disabled:j,onRespond:N})]})}function iL(e){var t,n,a,s,l;let{promptData:i,decisionId:o,disabled:d,onRespond:u}=e,m=(0,c.c)("prompt"),h=o&&null!=(n=i.decisionOptions)?n:null,x=function(e){if(null===iT(e)||Array.isArray(e.decisionOptions)&&e.decisionOptions.length>0)return null;let t=e.askUserQuestion;if(!t||"string"!=typeof t.question||""===t.question||!Array.isArray(t.labels)||0===t.labels.length)return null;let n=t.labels.filter(e=>"string"==typeof e&&""!==e);if(n.length!==t.labels.length)return null;let a="number"==typeof t.questionCount?t.questionCount:1;return 1!==a?null:{question:t.question,labels:n,questionCount:a}}(i);return(0,r.jsxs)("div",{className:"space-y-2","data-testid":"unclassified-prompt-notice",children:[i.message&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:i.message}),i.askUserQuestion&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"unclassified-ask-user-question",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:i.askUserQuestion.question}),x?(0,r.jsx)(iD,{choices:x,disabled:d,onRespond:u}):(0,r.jsx)("ul",{className:"list-disc list-inside text-sm text-muted-foreground",children:i.askUserQuestion.labels.map(e=>(0,r.jsx)("li",{children:e},e))})]}),x?null:h&&h.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iR,{toolName:null!=(a=i.toolName)?a:null,patterns:null!=(s=i.patterns)?s:null,allowAlwaysLabel:null!=(l=null==(t=h.find(e=>"always"===e.reply))?void 0:t.label)?l:null}),(0,r.jsx)(iP,{options:h,disabled:d,onRespond:u})]}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:m("unclassifiedInstruction",{command:m("unclassifiedRespondCommand")})})]})}function iR(e){let{toolName:t,patterns:n,allowAlwaysLabel:a}=e,s=null!==n&&n.length>0;return t||s?(0,r.jsxs)("div",{className:"space-y-1","data-testid":"structured-decision-subject",children:[t&&(0,r.jsx)("p",{className:"text-sm font-medium text-foreground font-mono break-all","data-testid":"structured-decision-tool",children:t}),s&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a&&(0,r.jsx)("span",{"data-testid":"structured-decision-patterns-label",children:a}),(0,r.jsx)("ul",{className:"mt-0.5 flex flex-wrap gap-1","data-testid":"structured-decision-patterns",children:n.map(e=>(0,r.jsx)("li",{className:"font-mono break-all bg-muted border border-border rounded px-1.5 py-0.5",children:e},e))})]})]}):null}function iP(e){let{options:t,disabled:n,onRespond:a}=e,s=(0,c.c)("prompt");return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",role:"group","aria-label":s("selectAnOption"),"data-testid":"structured-decision-actions",children:t.map(e=>(0,r.jsxs)(m.$n,{variant:"ghost",type:"button",disabled:n,onClick:()=>a(String(e.number)),"data-testid":"structured-decision-option-".concat(e.number),className:"".concat(iE," ").concat(3===e.number?iM:iI),children:[e.number,". ",e.label]},e.number))})}function iD(e){let{choices:t,disabled:n,onRespond:a}=e,s=(0,c.c)("prompt"),l=(0,i.useId)(),[o,d]=(0,i.useState)(null),u=(0,i.useCallback)(e=>{let t=o===e,a=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(a)},[o,n]);return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"structured-question-actions",children:[(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:s("selectAnOption")}),(0,r.jsx)(m.z6,{name:l,value:null!=o?String(o):"",onValueChange:e=>d(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:u(t+1),children:[(0,r.jsx)(m.CU,{value:String(t+1),className:"mt-1"}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)("span",{className:"font-medium",children:[t+1,". ",e]})})]},"".concat(t+1,"-").concat(e)))})]}),(0,r.jsx)("button",{type:"button","data-testid":"structured-question-submit",onClick:()=>{null!==o&&a(String(o))},disabled:n||null===o,className:"w-full ".concat(iE," ").concat(iI),children:s("submit")})]})}function iF(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(iE," ").concat(iI," ").concat(i?"primary default highlighted":""),u="".concat(iE," ").concat(o?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":iM);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 iO(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.description&&(0,r.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e.description})]})]},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(iE," ").concat(iI),children:x("submit")})]})}let iz=(0,i.memo)(function(e){let t,{promptData:n,messageId:a,decisionId:s,visible:l,answering:o,onRespond:c,onDismiss:d,cliToolName:u}=e,{shouldRender:m,animationClass:h}=M({visible:l&&null!==n,duration:200}),x=(0,i.useId)();if(!m||!n)return null;let f=(t="opacity-100","animate-fade-in"===h?t="opacity-100 transform translate-y-0":"animate-fade-out"===h&&(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(h," ").concat(t));return(0,r.jsx)(T,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":x,"aria-modal":"true",className:f,children:(0,r.jsx)(iA,{promptData:n,answering:o,onRespond:c,decisionId:s,onDismiss:d,labelId:x,cliToolName:u})})})});var i_=n(35619),iB=n(93141);let iV=(0,i.memo)(function(e){var t,n,a;let{worktreeId:s,cliToolId:l,instanceId:o,diff:d,disabled:u=!1}=e,h=(0,c.c)("worktree"),x=(0,m.SC)(),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),j=(null==d?void 0:d.revertedMessageId)!=null,w=(0,i.useMemo)(()=>{var e,t;return j?null!=(e=null==d?void 0:d.revertedFiles)?e:[]:null!=(t=null==d?void 0:d.files)?t:[]},[j,d]),k=(0,i.useCallback)(async e=>{b(null),p(e);try{let t=await fetch("/api/worktrees/".concat(s,"/opencode/diff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:null!=o?o:l})}),n=await t.json().catch(()=>({}));if(409===t.status&&"SESSION_BUSY"===n.code)return void b("busy");if(!t.ok)return void b("failed");!1===n.applied&&b("noop")}catch(e){b("failed")}finally{p(null)}},[s,l,o]),N=(0,i.useCallback)(async()=>{await x({title:h("opencodeDiff.revertConfirmTitle"),description:h("opencodeDiff.revertConfirmBody",{count:w.length}),confirmLabel:h("opencodeDiff.revertConfirmLabel"),variant:"danger"})&&await k("revert")},[x,h,w.length,k]),C=(0,i.useCallback)(async()=>{await x({title:h("opencodeDiff.unrevertConfirmTitle"),description:h("opencodeDiff.unrevertConfirmBody",{count:w.length}),confirmLabel:h("opencodeDiff.unrevertConfirmLabel")})&&await k("unrevert")},[x,h,w.length,k]);return"opencode"!==l?null:d&&(d.files.length>0||d.revertedFiles.length>0)?(0,r.jsxs)("div",{className:"border-t border-border bg-muted/30 px-3 py-2 text-xs","data-testid":"opencode-turn-diff-panel",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(i_.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-medium text-foreground",children:j?h("opencodeDiff.revertedTitle"):h("opencodeDiff.title")}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j?h("opencodeDiff.revertedSubtitle",{count:w.length}):h("opencodeDiff.subtitle",{count:w.length})}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1",children:[null!==f?(0,r.jsx)(m.y$,{size:"sm"}):null,j?(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:C,disabled:u||null!==f,children:[(0,r.jsx)(iB.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),h("opencodeDiff.unrevert")]}):(0,r.jsxs)(m.$n,{variant:"ghost",size:"sm",onClick:N,disabled:u||null!==f,children:[(0,r.jsx)(nf.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),h("opencodeDiff.revert")]})]})]}),null!==g?(0,r.jsx)("p",{className:"mt-1 text-danger-foreground",role:"status",children:h("opencodeDiff.".concat(g))}):null,(0,r.jsx)("ul",{className:"mt-1 space-y-0.5",children:w.map((e,t)=>{var n,a;let s=null!=(n=e.file)?n:h("opencodeDiff.unnamedFile"),l=function(e){let t=[];return e.additions>0&&t.push("+".concat(e.additions)),e.deletions>0&&t.push("−".concat(e.deletions)),t.join(" ")}(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[null!==e.patch&&null!==e.file?(0,r.jsx)("button",{type:"button",className:"truncate text-info underline-offset-2 hover:underline",onClick:()=>y(e),title:h("opencodeDiff.openDiff",{file:s}),children:s}):(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:s}),null!==e.status?(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:h("opencodeDiff.status.".concat(e.status))}):null,""!==l?(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:l}):null]},"".concat(null!=(a=e.file)?a:"unnamed","-").concat(t))})}),(0,r.jsx)(m.Jh,{isOpen:null!==v,onClose:()=>y(null),title:null!=(t=null==v?void 0:v.file)?t:void 0,size:"xl",children:null!==v?(0,r.jsx)(ii,{diff:null!=(n=v.patch)?n:"",filePath:null!=(a=v.file)?a:"",onClose:()=>y(null)}):null})]}):null});var iW=n(91758);function iH(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),[p,g]=(0,i.useState)(!1),b=(0,i.useRef)(null),v=e=>l(rw[e].replace("autoYes.",""));return(0,i.useEffect)(()=>{t&&(h(""),f(null),g(!1))},[t]),(0,i.useEffect)(()=>{if(!p)return;let e=e=>{b.current&&!b.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]),(0,i.useEffect)(()=>{if(!m.trim())return void f(null);let e=rk(m.trim());if(e.valid)f(null);else{var t;f(null!=(t=e.error)?t:l("invalidRegexPattern"))}},[m,l]),(0,r.jsx)(tl.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:rj.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:()=>g(!p),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:"?"}),p&&(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 iU=(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,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1);(0,i.useEffect)(()=>{if(!t||!n){x(""),w(!1);return}w(!1);let e=!1,a=()=>(x(rN(n)),n-Date.now()<=0&&!e&&(e=!0,w(!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;p('Auto responded: "'.concat(s,'"'));let e=setTimeout(()=>p(null),em.I2);return()=>clearTimeout(e)},[s]);let k=t&&!j,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)(iW.d,{checked:k,onCheckedChange:N,disabled:g,"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,to.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)(iH,{isOpen:v,onConfirm:C,onCancel:S,cliToolName:(0,to.f_)(l,"")})]})});function iK(e){let t=new Set;for(let n of e)"user"===n.role&&t.add(n.id);return t}function i$(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 iq(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 iG=(0,i.memo)(function(e){var t,n,a,s,l,o;let{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:h,instance:x,availableInstances:f,onInstanceChange:p,onFocus:g,disabled:b=!1,pendingInsertText:v,onInsertConsumed:y,onMessageSent:j,cliStatus:w="idle",autoYes:k,history:N,onDropInstance:C,draggedInstanceId:T,onRequestSessionEnd:E,agentModel:I,onAgentSessionChange:M}=e,A=null!=h?h:m,L=null!=(n=k.enabled)&&n,R=null!=(a=k.expiresAt)?a:null,P=null!=(s=k.lastAutoResponse)?s:null,D=k.onToggle,F=null!=(l=null==N?void 0:N.showArchived)&&l,O=null==N?void 0:N.onShowArchivedChange,z=null==N?void 0:N.historyDisplayLimit,_=null==N?void 0:N.onHistoryDisplayLimitChange,B=null!=(o=null==N?void 0:N.historyUserOnly)&&o,W=null==N?void 0:N.onHistoryUserOnlyChange,H=null==N?void 0:N.onInsertToMessage,U=null==N?void 0:N.onFilePathClick,K=null==N?void 0:N.showToast,$=(0,c.c)("worktree"),q=(0,eX.Ym)(),{terminal:G,prompt:J,agentSession:Y,setAutoScroll:Q,setPromptAnswering:X,clearPrompt:Z,refresh:ee}=nl({worktreeId:d,cliToolId:m,instanceId:A,enabled:!b}),{messages:et,isLoading:en,refresh:ea}=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,t6.xM)(),f=null!=a?a:n,p=(0,i.useRef)(0),g=(0,i.useRef)(n);g.current=n;let b=(0,i.useRef)(f);b.current=f;let v=(0,i.useCallback)(async()=>{let e=++p.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(p.current!==e||g.current!==n||b.current!==f)return;c(i.map(e=>({...e,timestamp:new Date(e.timestamp)}))),u(!1)}catch(t){if(p.current!==e||g.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),j=(0,i.useRef)(y);return(0,i.useEffect)(()=>{j.current!==y&&(j.current=y,p.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===g.current)&&v()})},[l,t,x,v]),{messages:o,isLoading:d,refresh:(0,i.useCallback)(()=>v(),[v])}}({worktreeId:d,cliToolId:m,instanceId:A,limit:z,includeArchived:F,enabled:!b}),er=(0,i.useCallback)((e,t)=>V.y.sendMessage(d,e,t),[d]),{messages:es,sendOptimistic:el,retry:ei,discard:eo}=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),p=(0,i.useCallback)(e=>{let t=x.current.get(e);void 0!==t&&(clearTimeout(t),x.current.delete(e))},[]),g=(0,i.useCallback)(e=>{p(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)},[p,s]),b=(0,i.useCallback)(async e=>{g(e.tempId);try{var t;await m.current(e.content,e.options),null==(t=u.current)||t.call(u)}catch(t){p(e.tempId),o(t=>t.map(t=>t.tempId===e.tempId?{...t,status:"error"}:t))}},[g,p]),v=(0,i.useCallback)((e,t)=>{let n={tempId:"pending-".concat(h.current++),content:e,options:t,timestamp:new Date,status:"sending",baselineUserIds:iK(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:iK(c.current)};o(t=>t.map(t=>t.tempId===e?n:t)),b(n)},[b]),j=(0,i.useCallback)(e=>{let t=d.current.find(t=>t.tempId===e);return p(e),o(t=>t.filter(t=>t.tempId!==e)),null==t?void 0:t.content},[p]);return(0,i.useEffect)(()=>{let{reconciledTempIds:e,consumedServerIds:t}=i$(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(p),o(t=>t.filter(t=>!e.has(t.tempId))))},[n,p]),(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}=i$(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:j}}({worktreeId:d,serverMessages:et,sendFn:er,onSent:ea}),{visible:ec,width:ed,toggle:em,setWidth:eh}=nW(),ex=i.useRef(null),ef=(0,i.useCallback)(e=>{let t=ex.current;if(!t)return;let n=t.offsetWidth;0!==n&&eh(ed+e/n*100)},[ed,eh]),eg="opencode"===m||"copilot"===m,{compactTuiLayoutPadding:eb,preservePaintedPanelRows:ev}=(0,i.useMemo)(()=>tF(m),[m]),ey=(0,i.useCallback)(e=>Q(e),[Q]),ej=(0,i.useCallback)(e=>{ee(),ea(),null==j||j(e)},[ee,ea,j]),ew=(0,i.useCallback)(e=>{let t=eo(e);t&&(null==H||H(t))},[eo,H]),ek=(0,i.useCallback)(async(e,t)=>{X(!0);try{let n=t?{decisionId:t,answer:e,cliTool:m,...A&&A!==m?{instanceId:A}:{}}:iq(e,m,S(J.data)?J.data:null,A),a=await fetch(t?"/api/worktrees/".concat(d,"/respond"):"/api/worktrees/".concat(d,"/prompt-response"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw Error("Failed to send prompt response: ".concat(a.status));Z(),await ee()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{X(!1)}},[d,m,A,J.data,X,Z,ee]),eN=(0,i.useCallback)(()=>{Z()},[Z]),eC=G.isSelectionListActive,eS=J.visible&&!L,eT=iT(J.data),eI=G.isUnclassifiedActive&&!eC&&!J.visible,eM=tH(G.composerText),eA=tG(m,G.realtimeSnippet||G.output),eL=(0,i.useMemo)(()=>(0,r.jsx)(n1,{messages:es,worktreeId:d,onFilePathClick:null!=U?U:()=>{},isLoading:en,className:"h-full",showToast:K,onInsertToMessage:H,onRetryPending:ei,onDiscardPending:ew,showArchived:F,onShowArchivedChange:O,historyDisplayLimit:z,onHistoryDisplayLimitChange:_,historyUserOnly:B,onHistoryUserOnlyChange:W,onCollapse:em,splitIndex:u,cliToolId:m}),[es,ei,ew,d,U,en,K,H,F,O,z,_,B,W,em,u,m]),eR=(0,i.useMemo)(()=>(0,r.jsx)(tz,{output:G.output,isActive:G.isRunning,attaching:G.attaching,isThinking:G.isThinking,autoScroll:G.autoScroll,onScrollChange:ey,disableAutoFollow:eg,compactTuiLayoutPadding:eb,preservePaintedPanelRows:ev}),[G.output,G.isRunning,G.attaching,G.isThinking,G.autoScroll,ey,eg,eb,ev]),eP=(0,i.useMemo)(()=>(0,r.jsxs)("div",{ref:ex,className:"flex h-full min-h-0 w-full",children:[ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:nQ(u),"data-testid":"split-history-slot-".concat(u),"aria-label":"History pane",style:{width:"".concat(ed,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:eL}),(0,r.jsx)(nH.f,{onResize:ef,orientation:"horizontal",ariaValueNow:ed})]}):(0,r.jsx)("div",{"data-testid":"split-history-expand-bar-".concat(u),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(u),"aria-label":$("terminal.showHistory"),title:$("terminal.showHistory"),"aria-expanded":"false",onClick:em,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:$("terminal.historyLabel")})]})}),(0,r.jsx)("div",{className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:eR})]}),[ec,ed,eL,ef,em,eR,u,$]),eD=(0,i.useMemo)(()=>(0,r.jsxs)("div",{className:"space-y-2",children:[eC?(0,r.jsx)(ep,{worktreeId:d,cliToolId:m,instanceId:A,onKeysSent:ee,showPagerKeys:G.isPagerActive}):null,eI?(0,r.jsx)(tW,{worktreeId:d,cliToolId:m,instanceId:A,onKeysSent:ee}):null,eM?(0,r.jsx)(tU,{worktreeId:d,cliToolId:m,instanceId:A,composerText:G.composerText,onActionSent:ee}):null,eA?(0,r.jsx)(tJ,{cliToolId:m,frame:G.realtimeSnippet||G.output}):null,eS?(0,r.jsx)(iz,{promptData:J.data,messageId:J.messageId,decisionId:eT,visible:J.visible,answering:J.answering,onRespond:ek,onDismiss:eN,cliToolName:(0,to.oo)(m)}):null,G.isRunning?(0,r.jsx)(t3,{worktreeId:d,cliToolId:m,instanceId:A,hasAgentSession:null!==Y.session,onKeysSent:ee}):null,(0,r.jsx)(iV,{worktreeId:d,cliToolId:m,instanceId:A,diff:Y.diff,disabled:!G.isRunning}),(0,r.jsx)(eu,{worktreeId:d,onMessageSent:ej,onOptimisticSend:el,cliToolId:m,instanceId:A,isSessionRunning:G.isRunning,pendingInsertText:null!=v?v:null,onInsertConsumed:y,splitIndex:u,onFocus:g,isProcessing:G.isRunning,showToast:K,autoYesSlot:(0,r.jsx)(iU,{enabled:L,expiresAt:null!=R?R:null,onToggle:D,lastAutoResponse:null!=P?P:null,cliToolName:m,inline:!0})})]}),[eC,eS,eI,eM,eA,G.realtimeSnippet,G.output,Y.session,G.composerText,G.isPagerActive,d,m,A,ee,J.data,J.messageId,eT,J.visible,J.answering,ek,eN,ej,el,G.isRunning,v,y,u,g,L,R,P,D,K,Y.diff]),eF=(0,to.sw)(null!=x?x:{cliTool:m}),eO=(0,i.useCallback)(()=>{null==E||E({cliToolId:m,instanceId:A,label:eF})},[E,m,A,eF]),ez=(0,i.useMemo)(()=>{if(!E||!G.isRunning)return null;let e=$("terminal.endSessionFor",{name:eF});return(0,r.jsx)("button",{type:"button",onClick:eO,"aria-label":e,title:e,"data-testid":"terminal-end-session-button-".concat(u),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)(eE.A,{size:14,"aria-hidden":"true"})})},[E,G.isRunning,$,eF,eO,u]);(0,i.useEffect)(()=>{null==M||M(A,Y)},[M,A,Y]);let e_=lf(I,null,null==(t=Y.session)?void 0:t.agent),eB=lb(Y.session,Y.context,$,q),eV=function(e,t,n,a){let r=[];(null==e?void 0:e.title)&&r.push(n("agentSession.titleLabel",{title:e.title})),(null==e?void 0:e.agent)&&r.push(n("agentSession.agentLabel",{agent:e.agent}));let s=lg(null==e?void 0:e.cost,a,4);s&&r.push(n("agentSession.costLabel",{cost:s}));let l=function(e){if(!e)return null;if(null!==e.total)return e.total;let t=[e.input,e.output,e.reasoning,e.cacheRead,e.cacheWrite].filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===t.length?null:t.reduce((e,t)=>e+t,0)}(null==e?void 0:e.tokens);if(null!==l&&r.push(n("agentSession.spentLabel",{tokens:new Intl.NumberFormat(a).format(l)})),"number"==typeof(null==t?void 0:t.tokens)){let e=new Intl.NumberFormat(a).format(t.tokens);r.push("number"==typeof t.limit&&"number"==typeof t.percent?n("agentSession.contextLabel",{tokens:e,limit:new Intl.NumberFormat(a).format(t.limit),percent:t.percent}):n("agentSession.contextUnknownLabel",{tokens:e}))}return r.length>0?r.join("\n"):null}(Y.session,Y.context,$,q);return(0,r.jsx)(tu,{worktreeId:d,splitIndex:u,cliToolId:m,instanceId:A,instance:x,availableInstances:f,onInstanceChange:p,headerExtras:ez,status:w,agentModel:e_,agentUsage:eB,agentUsageDetail:eV,onFocus:g,attaching:G.attaching,terminal:eP,footer:eD,onDropInstance:C,draggedInstanceId:T})}),iJ=(0,i.memo)(function(e){var t;let{task:n,latestRun:a,latestRunGates:s,onOpen:l,className:o=""}=e,d=(0,c.c)("worktree"),u=(0,i.useMemo)(()=>{if(!n)return"";let e=[d("verification.chip.taskReason",{title:n.title,status:d("task.status.".concat(n.status))})];if(a){if(e.push(d("verification.chip.runReason",{verdict:d("verification.runStatus.".concat(a.status)),runId:a.id})),s&&s.length>0){let t=s.filter(e=>r8.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:s.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e.join(" \xb7 ")},[n,a,s,d]);return n?(0,r.jsxs)("button",{type:"button",onClick:l,"data-testid":"verification-status-chip","aria-label":u,title:u,className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-surface-2 px-2 py-1 text-xs text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation ".concat(o).trim(),children:[(0,r.jsx)(r2.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"truncate font-medium","data-testid":"verification-chip-title",children:(t=n.title,t.length<=36?t:"".concat(t.slice(0,35),"…"))}),(0,r.jsx)(r5.E,{variant:r4[n.status],className:"flex-shrink-0 px-1.5 py-0","data-testid":"verification-chip-task-status",children:d("task.status.".concat(n.status))}),(0,r.jsx)(r5.E,{variant:a?r3[a.status]:"gray",className:"flex-shrink-0 px-1.5 py-0 font-mono","data-testid":"verification-chip-run-status",children:a?d("verification.chip.resultBadge",{verdict:d("verification.runStatus.".concat(a.status))}):d("verification.chip.dash")})]}):null}),iY=(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)(rm.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)(eE.A,{className:"w-4 h-4"})})]})});var iQ=n(58734);let iX=(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,p]=(0,i.useState)(new Set([""])),[g,b]=(0,i.useState)([]),[v,j]=(0,i.useState)(!1),[w,k]=(0,i.useState)(new Set),N=l.includes("/")?l.substring(0,l.lastIndexOf("/")):"";(0,i.useEffect)(()=>{t&&(x(N),p(new Set([""])),b([]),C())},[t,s]);let C=(0,i.useCallback)(async()=>{j(!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{j(!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=>{p(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}(g,e);t&&!t.loaded&&await S(e)},[g,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=w.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)(nu.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(iQ.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)(tl.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"})}):g.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 iZ(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let i0=(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=iZ(d,m);e&&a(e)},[d,m,a]),p=(0,i.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),f())},[f]),g=iZ(d,m),b=n?"".concat(n,"/").concat(g):g;return(0,r.jsx)(tl.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:p,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:lJ.map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),g&&(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:!g,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")})]})]})})}),i1=(0,i.memo)(function(e){var t,n,a,s,l;let{worktreeId:o,worktree:d,worktreeName:u,worktreeStatus:m,instances:h,rosterReady:x,activeInstanceId:f,setActiveInstanceId:p,hasUpdate:g,lastAutoResponse:b,activeActivity:v,onActivityToggle:y,onActivityOpen:j,verification:w,onBackClick:k,onInfoClick:N,onWorktreeStatusChange:C,pendingInsertTextMap:S,setFocusedSplitIndex:E,handleInsertToSplit:I,handleInsertConsumed:M,handleInsertToMessage:A,autoYesStateMap:L,makeAutoYesToggleHandler:R,showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onMessageSent:B,onFilePathClick:V,showToast:W,tabsState:H,tabsActions:U,onLoadContent:K,onLoadError:$,onSetLoading:q,onFilePanelSave:G,onDirtyChange:J,onOpenFile:Y,diffContent:Q,diffFilePath:X,onCloseDiff:Z,fileSearch:ee,fileTreeRefresh:et,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onFileTreeReset:ec,onDiffSelect:ed,onAgentInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:eh,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:ef,isInfoModalOpen:ep,onInfoModalClose:eg,onWorktreeUpdate:eb,fileInputRef:ev,onFileInputChange:ey,onKillSession:ej,onRequestSessionEnd:ew,killTarget:ek,isKillPending:eN,onKillCancel:eC,onKillConfirm:eS,moveTarget:eT,isMoveDialogOpen:eE,onMoveCancel:eI,onMoveConfirm:eM,showNewFileDialog:eA,newFileParentPath:eL,onNewFileConfirm:eR,onNewFileCancel:eP,killDialogTitle:eD,killDialogWarning:eF,cancelLabel:eO,endLabel:ez}=e,e_=(0,c.c)("worktree"),[eB,eV]=i.useState(null),eW=(0,i.useCallback)(e=>eV(e),[]),eH=(0,i.useCallback)(()=>eV(null),[]),eU=(0,i.useMemo)(()=>lv(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[eK,e$]=(0,i.useState)({}),eq=(0,i.useCallback)((e,t)=>{e$(n=>n[e]===t?n:{...n,[e]:t})},[]),[eG,eJ]=i.useState(null),eY=i.useRef(0),eQ=(0,i.useCallback)(e=>{p(e),eY.current+=1,eJ({instanceId:e,token:eY.current})},[p]),eX=(0,i.useCallback)(()=>{j("verification")},[j]),eZ=(0,i.useCallback)(e=>{var t,n,a,s,l,i,c,u,m,h;let{splitIndex:x,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:j,onFocus:w,onDropInstance:k}=e,N=null!=(c=S.get(x))?c:null,C=L.get(g),T=null!=(u=null==C?void 0:C.enabled)&&u,E=null!=(m=null==C?void 0:C.expiresAt)?m:null,A=(0,ti.kA)(null!=(h=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[g])?h:null==d||null==(n=d.sessionStatusByCli)?void 0:n[f]);return(0,r.jsx)(iG,{worktreeId:o,splitIndex:x,cliToolId:f,instanceId:g,instance:v,availableInstances:y,onInstanceChange:e=>{j(e),0===x&&p(e)},onFocus:w,pendingInsertText:N,onInsertConsumed:()=>M(x),onMessageSent:B,cliStatus:A,onAgentSessionChange:eq,agentModel:lf(null==d||null==(s=d.sessionStatusByInstance)||null==(a=s[g])?void 0:a.model,null==d||null==(i=d.sessionStatusByInstance)||null==(l=i[g])?void 0:l.reasoningEffort),autoYes:{enabled:T,expiresAt:E,lastAutoResponse:b,onToggle:R(f,g)},history:{showArchived:P,onShowArchivedChange:D,historyDisplayLimit:F,onHistoryDisplayLimitChange:O,historyUserOnly:z,onHistoryUserOnlyChange:_,onInsertToMessage:e=>I(x,e),onFilePathClick:V,showToast:W},onDropInstance:k,draggedInstanceId:eB,onRequestSessionEnd:ew})},[o,S,L,M,B,p,b,R,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,V,W,I,P,D,F,O,z,_,eB,ew,eq]),e0=(0,i.useMemo)(()=>(0,r.jsx)(iC,{worktreeId:o,instances:h,rosterReady:x,renderPane:eZ,onFocusedSplitChange:E,showToast:W,onActiveInstanceChange:p,headerInstanceSelection:eG}),[o,h,x,eZ,E,W,p,eG]),e1=(0,i.useMemo)(()=>(0,r.jsx)(iu,{terminal:e0,terminalHeader:null,fileTabs:H,worktreeId:o,onCloseTab:U.closeTab,onActivateTab:U.activateTab,onLoadContent:K,onLoadError:$,onSetLoading:q,onFileSaved:G,diffContent:Q,diffFilePath:X,onCloseDiff:Z,onDirtyChange:J,onMoveToFront:U.moveToFront,onOpenFile:Y}),[e0,H,o,U.closeTab,U.activateTab,K,$,q,G,Q,X,Z,J,U.moveToFront,Y]),e2=(0,i.useMemo)(()=>(0,r.jsx)(lW,{active:v,onToggle:y}),[v,y]),e5=(0,i.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(ak,{query:ee.query,mode:ee.mode,isSearching:ee.isSearching,error:ee.error,onQueryChange:ee.setQuery,onModeChange:ee.setMode,onClear:ee.clearSearch}),(0,r.jsx)(av,{worktreeId:o,onFileSelect:en,onNewFile:ea,onNewDirectory:er,onRename:es,onDelete:el,onUpload:ei,onMove:eo,onResetView:ec,refreshTrigger:et,pollingEnabled:"files"===v,searchQuery:ee.query,searchMode:ee.mode,searchResults:null==(e=ee.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(ld,{worktreeId:o,onDiffSelect:ed,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:A,className:"h-full"}),notes:(0,r.jsx)(aM,{worktreeId:o,className:"h-full",onInsertToMessage:A}),schedules:(0,r.jsx)(rn,{worktreeId:o,className:"h-full",onInsertToMessage:A,instances:h}),agent:(0,r.jsx)(rp,{worktreeId:o,instances:h,onInstancesChange:eu,vibeLocalModel:em,onVibeLocalModelChange:eh,vibeLocalContextWindow:ex,onVibeLocalContextWindowChange:ef,modelByInstance:eU}),timer:(0,r.jsx)(rM,{worktreeId:o,instances:h}),todo:(0,r.jsx)(aD,{worktreeId:o,className:"h-full"}),skills:(0,r.jsx)(r1,{worktreeId:o,className:"h-full"}),verification:(0,r.jsx)(su,{state:w,className:"h-full"}),env:(0,r.jsx)(sO,{worktreeId:o,className:"h-full"})}},[o,d,v,ee.query,ee.mode,ee.isSearching,ee.error,ee.setQuery,ee.setMode,ee.clearSearch,null==(t=ee.results)?void 0:t.results,en,ea,er,es,el,ei,eo,ec,et,ed,A,h,eu,em,eh,ex,ef,eU,w]),e4=(0,i.useMemo)(()=>null===v?null:(0,r.jsx)(lK,{active:v,activities:e5}),[v,e5]);return(0,r.jsx)(T,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[e2,(0,r.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 min-w-0",children:[(0,r.jsx)(lw,{worktreeName:u,repositoryName:null!=(s=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?s:e_("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onBackClick:k,onInfoClick:N,hasUpdate:g,worktreeStatus:null!=(l=null==d?void 0:d.status)?l:null,onWorktreeStatusChange:C,sessionStatusByCli:null==d?void 0:d.sessionStatusByCli,sessionStatusByInstance:null==d?void 0:d.sessionStatusByInstance,instances:h,activeInstanceId:f,onActiveInstanceChange:eQ,onAgentDragStart:eW,onAgentDragEnd:eH,onKillSession:ej,agentSessionByInstance:eK,verificationChip:(0,r.jsx)(iJ,{task:w.task,latestRun:w.latestRun,latestRunGates:null!==w.selectedRun&&w.selectedRun.id===(null==(n=w.latestRun)?void 0:n.id)?w.selectedRun.gates:null,onOpen:eX})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(iY,{isBranchMismatch:d.gitStatus.isBranchMismatch,currentBranch:d.gitStatus.currentBranch,initialBranch:d.gitStatus.initialBranch}),(0,r.jsx)("div",{className:"flex-1 min-h-0 min-w-0",children:(0,r.jsx)(lS,{activityPane:e4,rightPane:(0,r.jsx)(n$,{terminal:e1})})})]}),(0,r.jsx)(lk,{worktreeId:o,worktree:d,isOpen:ep,onClose:eg,onWorktreeUpdate:eb}),(0,r.jsx)("input",{ref:ev,type:"file",accept:lG.join(","),onChange:ey,className:"hidden","aria-label":e_("detail.uploadFile")}),(0,r.jsx)(tl.a,{isOpen:null!==ek,onClose:eC,title:eD,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eF}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eC,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:eO}),(0,r.jsx)("button",{type:"button",onClick:eS,disabled:eN,"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:ez})]})]})}),eT&&(0,r.jsx)(iX,{isOpen:eE,onClose:eI,onConfirm:eM,worktreeId:o,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(i0,{isOpen:eA,parentPath:eL,onConfirm:eR,onCancel:eP})]})})});to.oo;var i2=n(51434);let i5={data:null,messageId:null,visible:!1,answering:!1},i4={mode:"split",mobileActivePane:"terminal",leftPaneTab:"history",splitRatio:.5,leftPaneCollapsed:!1,activityBar:{active:"files"},historyPane:{visible:!0,width:25,collapsed:!1}},i3={type:null,message:null,retryable:!1,retryCount:0};function i6(){return{phase:"idle",prompt:{...i5},layout:{...i4},error:{...i3},messages:[],wsConnected:!1}}function i8(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:{...i5}};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:{...i3}};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 i9=n(66966);function i7(e,t){try{window.localStorage.setItem(lB(e),null!=t?t:l_)}catch(e){}}function oe(e,t){return e instanceof Error&&e.message?e.message:t}function ot(e){return e instanceof DOMException&&"AbortError"===e.name}let on="commandmate:file-tabs:";function oa(e){let t=e.split("/");return t[t.length-1]||e}function or(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 os={tabs:[],activeIndex:null};var ol=n(63001);let oi="commandmate:showArchived",oo="activeCliTab-",oc="activeInstanceId-";function od(){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 ou=(0,o.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(od,{})}),om=()=>{},oh=["terminal","history","files","memo","info"],ox=(0,i.memo)(function(e){var t,n,a,l,o,u,m;let{worktreeId:f}=e,{activeActivity:p,activeCliTab:b,activeInstanceId:v,activeTab:y,agentInstances:j,autoYesEnabled:w,autoYesExpiresAt:k,autoYesStateMap:N,diffContent:E,diffFilePath:I,disableAutoFollow:M,displayedInstances:A,editorFilePath:R,error:D,fetchCurrentOutput:F,fileInputRef:O,fileSearch:z,fileTreeRefresh:_,handleActivityOpen:W,handleActivityToggle:H,handleAgentInstancesChange:U,handleAutoYesToggle:K,handleBackClick:$,handleCloseDiff:q,handleDelete:G,handleDiffSelect:J,handleDirtyChange:Y,handleEditorClose:Q,handleEditorSave:X,handleFileInputChange:Z,handleFilePanelSave:ee,handleFilePathClick:et,handleFileSelect:en,handleHistoryDisplayLimitChange:ea,handleHistoryUserOnlyChange:er,handleInfoClick:es,handleInfoModalClose:ei,handleInsertConsumed:eo,handleInsertConsumedSingle:ec,handleInsertToMessage:ed,handleInsertToSplit:em,handleKillCancel:eh,handleKillConfirm:ex,openKillConfirm:ef,openActiveKillConfirm:eb,killTarget:ev,isKillPending:ey,handleLoadContent:ej,handleLoadError:ew,handleMessageSent:ek,handleMobileFileViewerClose:eN,handleMobileTabChange:eC,handleMove:eS,handleMoveCancel:eT,handleMoveConfirm:eE,handleNewDirectory:eI,handleNewFile:eM,handleNewFileCancel:eA,handleNewFileConfirm:eL,handleOpenFile:eR,handlePromptDismiss:eD,handlePromptRespond:eF,handleRename:eO,handleRetry:ez,handleSetLoading:e_,handleShowArchivedChange:eB,handleUpload:eV,handleVibeLocalContextWindowChange:eW,handleVibeLocalModelChange:eH,handleWorktreeStatusChange:eU,hasUpdate:eK,historyDisplayLimit:e$,historySubTab:eq,historyUserOnly:eG,isEditorMaximized:eJ,isInfoModalOpen:eY,isMobile:eX,isMoveDialogOpen:eZ,isSelectionListActive:e0,isPagerActive:e1,lastAutoResponse:e2,loading:e4,makeAutoYesToggleHandler:e6,mobileFileViewerPath:e8,mobileSelectedAgents:e9,moveTarget:e7,newFileParentPath:te,openMobileDrawer:tt,pendingInsertText:tn,pendingInsertTextMap:ta,rosterReady:tr,setActiveInstanceId:ts,setFocusedSplitIndex:tc,setHistorySubTab:td,setIsEditorMaximized:tu,setWorktree:tm,showArchived:th,showNewFileDialog:tx,showToast:tf,state:tp,tCommon:tg,tWorktree:tb,tabsActions:tv,tabsState:ty,resetFileTreeView:tj,toggleInstanceVisible:tw,verification:tk,vibeLocalContextWindow:tN,vibeLocalModel:tC,visibleInstanceIds:tS,worktree:tT,worktreeName:tE,worktreeStatus:tI}=function(e){var t,n,a,r,l,o,d,u,m,h;let{worktreeId:f}=e,p=(0,s.useRouter)(),g=(0,el.a)(),b=(0,i.useRef)(g);b.current=g;let{openMobileDrawer:v}=(0,lV.VF)(),{state:y,actions:j}=function(){let[e,t]=(0,i.useReducer)(i8,void 0,i6),{value:n,setValue:a}=(0,tZ.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}}(),w=(0,c.c)("worktree"),k=(0,c.c)("error"),N=(0,c.c)("common"),C=(0,c.c)("autoYes"),T=(0,eg.SC)(),E=(0,i9.rC)(),I=null!=(l=null==E?void 0:E.worktrees.find(e=>e.id===f))?l:null,[M,A]=(0,i.useState)(I),[L,R]=(0,i.useState)(null===I),[P,D]=(0,i.useState)(null),[F,O]=(0,i.useState)(0),z=(0,i.useRef)(null!==I),[_,B]=(0,i.useState)(!1),[W,H]=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:oa(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=or(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=or(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=or(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:oa(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:oa(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return os;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=or(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 os;default:return t}},os),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(on+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(on+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),[U,K]=(0,i.useState)(null),[$,q]=(0,i.useState)(null),[G,J]=(0,i.useState)(!1),[Y,Q]=(0,i.useState)(new Map),[X,Z]=(0,i.useState)(null),[ee,et]=(0,i.useState)(!1),[en,ea]=(0,i.useState)(!1),[er,es]=(0,i.useState)(!1),ei=(0,i.useRef)(!1),[eo,ec]=(0,i.useState)(null),[ed,eu]=(0,i.useState)(ol.fJ),em=(0,i.useRef)(ed);em.current=ed;let[eh,ex]=(0,i.useState)(()=>(0,to.lu)(ol.fJ)),ef=(0,i.useRef)(eh);ef.current=eh;let[ep,eb]=(0,i.useState)(null),ev=ep===f,[ey,ej]=(0,i.useState)(null),[ew,ek]=(0,i.useState)(null),[eN,eC]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(oo+f);if(e&&(0,to.hR)(e))return e}catch(e){}return ol.fJ[0]}),eS=(0,i.useCallback)(e=>{eC(e);try{window.localStorage.setItem(oo+f,e)}catch(e){}},[f]),eT=(0,i.useRef)(eN);eT.current=eN;let[eE,eI]=(0,i.useState)(()=>{try{let e=window.localStorage.getItem(oc+f);if(e&&(0,to.n6)(e))return e;let t=window.localStorage.getItem(oo+f);if(t&&(0,to.hR)(t))return t}catch(e){}return ol.fJ[0]}),eM=(0,i.useCallback)(e=>{eI(e);try{window.localStorage.setItem(oc+f,e)}catch(e){}let t=ef.current.find(t=>t.id===e);t&&eS(t.cliTool)},[f,eS]),eA=(0,i.useRef)(eE);eA.current=eE;let eL=(0,i.useRef)(0),eR=(0,i.useRef)(0),eD=(0,i.useRef)(0),eF=null!=(o=null==(t=Y.get(eE))?void 0:t.enabled)&&o,eO=null!=(d=null==(n=Y.get(eE))?void 0:n.expiresAt)?d:null,[ez,e_]=(0,i.useState)(0),[eB,eV]=(0,i.useState)(!1),[eW,eH]=(0,i.useState)(""),{active:eU,setActive:eK,toggle:e$}=function(e){let[t,n]=(0,i.useState)(lz),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(lB(e));if(t===l_)return null;if(t&&"string"==typeof t&&lO.has(t))return t}catch(e){}return lz}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,i.useCallback)(e=>{n(e),i7(r.current,e)},[]),toggle:(0,i.useCallback)(e=>{if(a.current===e){n(null),i7(r.current,null);return}n(e),i7(r.current,e)},[])}}(f),{historySubTab:eq,setHistorySubTab:eG,showArchived:eJ,handleShowArchivedChange:eY,historyUserOnly:eQ,handleHistoryUserOnlyChange:eX,historyDisplayLimit:eZ,handleHistoryDisplayLimitChange:e0}=function(){let[e,t]=(0,i.useState)("message"),[n,a]=(0,i.useState)(()=>"true"===localStorage.getItem(oi)),r=(0,i.useCallback)(e=>{a(e),localStorage.setItem(oi,String(e))},[]),[s,l]=(0,i.useState)(()=>{try{return"true"===localStorage.getItem(nY)}catch(e){return!1}}),o=(0,i.useCallback)(e=>{l(e);try{localStorage.setItem(nY,String(e))}catch(e){}},[]),[c,d]=(0,i.useState)(()=>{try{let e=localStorage.getItem(nG);if(null===e)return 50;let t=parseInt(e,10);return nJ(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(nG,String(e))}catch(e){}},[])}}(),e1=(0,i.useRef)(eJ);(0,i.useEffect)(()=>{e1.current=eJ},[eJ]);let e2=(0,i.useRef)(eZ);(0,i.useEffect)(()=>{e2.current=eZ},[eZ]);let{pendingInsertTextMap:e4,pendingInsertText:e6,setFocusedSplitIndex:e8,handleInsertToMessage:e9,handleInsertToSplit:e7,handleInsertConsumed:te,handleInsertConsumedSingle:tt}=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:tn,diffFilePath:ta,handleDiffSelect:tr,handleCloseDiff:ts}=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)},[])}}(g),tl=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),[p,g]=(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),g(null)},[v]),j=(0,i.useCallback)(()=>{s(""),o(""),f(null),g(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),w=(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),g(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;g(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),g(null))},[c]),{query:r,mode:c,isSearching:u,results:h,error:p,setQuery:y,setMode:d,clearSearch:j,filterByName:w,getMatchedPaths:k}}({worktreeId:f}),ti=(0,i.useRef)(!1),tc=(0,i.useRef)(f);(0,i.useEffect)(()=>{tc.current!==f&&(j.clearMessages(),ti.current=!1,Q(new Map),tc.current=f)},[f,j]);let td=(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(A(a),a.selectedAgents){let e=em.current;a.selectedAgents.length===e.length&&a.selectedAgents.every((t,n)=>t===e[n])||eu(a.selectedAgents)}if(a.agentInstances){let e=ef.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)||ex(t),eb(f)}return"vibeLocalModel"in a&&ej(null!=(e=a.vibeLocalModel)?e:null),"vibeLocalContextWindow"in a&&ek(null!=(t=a.vibeLocalContextWindow)?t:null),a}catch(e){return D(e instanceof Error?e.message:"Unknown error"),null}},[f]),tu=(0,i.useCallback)(async()=>{let e=eT.current,t=b.current,n=eA.current,a=++eL.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),e1.current&&r.set("includeArchived","true"),r.set("limit",String(e2.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(eL.current!==a||eT.current!==e||t&&eA.current!==n)return;j.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(eL.current!==a||eT.current!==e||t&&eA.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[f,j]),tm=(0,i.useCallback)(async()=>{let e=eT.current,t=b.current,n=eA.current,a=++eR.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(eR.current!==a||eT.current!==e||t&&eA.current!==n||d.cliToolId&&d.cliToolId!==e)return;if(d.isPromptWaiting&&d.promptData?j.showPrompt(d.promptData,"prompt-".concat(Date.now())):!d.isPromptWaiting&&y.prompt.visible&&j.clearPrompt(),ea(null!=(r=d.isSelectionListActive)&&r),es(null!=(s=d.isPagerActive)&&s),Z(null!=(l=d.lastServerResponseTimestamp)?l:null),et(null!=(i=d.serverPollerActive)&&i),d.autoYes){let a=ei.current,r=d.autoYes,s=t?n:e;Q(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),ei.current=r.enabled,a&&!d.autoYes.enabled&&("stop_pattern_matched"===d.autoYes.stopReason||"consecutive_errors"===d.autoYes.stopReason)&&ec(d.autoYes.stopReason)}}catch(r){if(eR.current!==a||eT.current!==e||t&&eA.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[f,j,y.prompt.visible]),th=(0,i.useCallback)(async()=>{let e=++eD.current;try{let a=await fetch("/api/worktrees/".concat(f,"/auto-yes"));if(!a.ok)return;let r=await a.json();if(eD.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})}Q(l)}catch(t){if(eD.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[f]),{visibleInstances:tx,visibleInstanceIds:tf,toggleInstanceVisible:tp}=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(rc(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)(()=>rd(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(rc(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=rd(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([...rd(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:f,roster:eh}),tg=g?tx:eh,tb=(0,i.useMemo)(()=>Array.from(new Set(tx.map(e=>e.cliTool))),[tx]),tv=g?tb:ed;(0,i.useEffect)(()=>{0!==tg.length&&(tg.some(e=>e.id===eE)||eM(tg[0].id))},[tg,eE,eM]),(0,i.useEffect)(()=>{let e=tg.find(e=>e.id===eE);e&&e.cliTool!==eN&&eS(e.cliTool)},[tg,eE,eN,eS]);let ty="opencode"===eN||"copilot"===eN,tj=(0,i.useCallback)(e=>{eu(e)},[]),tw=(0,i.useCallback)(e=>{ex(e),eb(f)},[f]),tk=(0,i.useCallback)(e=>{ej(e)},[]),tN=(0,i.useCallback)(e=>{ek(e)},[]),tC=(0,i.useRef)(eN);(0,i.useEffect)(()=>{tC.current!==eN&&(tC.current=eN,j.clearMessages(),j.clearPrompt(),ea(!1),tu(),tm())},[eN,j,tu,tm]),(0,i.useEffect)(()=>{tu()},[eJ,tu]),(0,i.useEffect)(()=>{tu()},[eZ,tu]);let{showToast:tS}=(0,e5.dj)(),tT=(0,i.useCallback)(()=>{tS("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[tS]),tE=(0,i.useCallback)(e=>{g?K(e):"limit_reached"===H.openFile(e)&&tT()},[g,H,tT]),tI=(0,i.useCallback)(e=>{g?K(e):"limit_reached"===H.openFile(e)&&tT()},[g,H,tT]),tM=(0,i.useCallback)(e=>{"limit_reached"===H.openFile(e)&&tT()},[H,tT]),tA=(0,i.useCallback)(()=>{K(null)},[]),tL=(0,i.useCallback)(e=>{e_(e=>e+1)},[]),tR=(0,i.useCallback)(()=>{q(null)},[]),tP=(0,i.useCallback)(()=>{tl.clearSearch(),H.closeAllTabs(),K(null),q(null)},[tl,H]),tD=(0,i.useCallback)(e=>{e_(e=>e+1)},[]),tF=(0,i.useCallback)(e=>{e$(e)},[e$]),tO=(0,i.useCallback)(e=>{eK(e)},[eK]),tz=(0,i.useCallback)(()=>{p.push("/")},[p]),t_=(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();A(e)}}catch(e){}},[f]),tB=(0,i.useCallback)(()=>{B(!0)},[]),tV=(0,i.useCallback)(()=>{B(!1)},[]),tW=(0,i.useCallback)(async e=>{j.setPromptAnswering(!0);try{let t=iq(e,eN,S(y.prompt.data)?y.prompt.data:null,b.current?eA.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));j.clearPrompt(),await tm()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{j.setPromptAnswering(!1)}},[f,j,tm,eN,y.prompt.data]),tH=(0,i.useCallback)(()=>{j.clearPrompt()},[j]),tU=(0,i.useCallback)(e=>{j.setMobileActivePane(e)},[j]),tK=(0,i.useCallback)(()=>{tu(),tm()},[tu,tm]),t$=(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();Q(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===eA.current&&(ei.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[f]),tq=(0,i.useCallback)(e=>t$(eN,eE)(e),[t$,eN,eE]),[tG,tJ]=(0,i.useState)(null),[tY,tQ]=(0,i.useState)(!1),tX=(0,i.useRef)(!1),t0=(0,i.useCallback)(e=>{tJ(e)},[]),t1=(0,i.useCallback)(()=>{let e=eA.current,t=eT.current,n=(0,to.O6)(ef.current,e,t);tJ({cliToolId:t,instanceId:e,label:n})},[]),t2=(0,i.useCallback)(async()=>{if(!tG||tX.current)return;tX.current=!0,tQ(!0);let e=()=>{tG.instanceId===eA.current&&(j.clearMessages(),j.clearPrompt())};try{await V.y.killSession(f,tG.cliToolId,tG.instanceId),e(),await td(),tJ(null)}catch(t){t instanceof V.hD&&404===t.status?(e(),await td(),tJ(null)):tS(w("session.failedToKill"),"error")}finally{tX.current=!1,tQ(!1)}},[tG,f,j,td,tS,w]),t5=(0,i.useCallback)(()=>{tX.current||tJ(null)},[]),t4=(0,i.useCallback)(e=>{eH(e),eV(!0)},[]),t3=(0,i.useCallback)(async e=>{eV(!1);let t=eW?"".concat(eW,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eP.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");e_(e=>e+1)}catch(e){window.alert(k("fileOps.failedToCreateFile"))}},[f,eW,k]),t6=(0,i.useCallback)(()=>{eV(!1)},[]),t8=(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,eP.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(k("fileOps.failedToCreateDirectory"))}},[f,k]),t9=(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,eP.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):"";H.onFileRenamed(e,"".concat(t).concat(n)),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(k("fileOps.failedToRename"))}},[f,H,k]),t7=(0,i.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await T({description:N("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,eP.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");($===e||(null==$?void 0:$.startsWith("".concat(e,"/"))))&&q(null),H.onFileDeleted(e),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(k("fileOps.failedToDelete"))}},[f,$,H,N,k,T]);(0,i.useEffect)(()=>{"stop_pattern_matched"===eo?(tS(C("stopPatternMatched"),"info"),ec(null)):"consecutive_errors"===eo&&(tS(C("consecutiveErrorsStopped"),"warning"),ec(null))},[eo,tS,C]);let{moveTarget:ne,isMoveDialogOpen:nt,handleMove:nn,handleMoveConfirm:na,handleMoveCancel:nr}=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,()=>e_(e=>e+1),e=>tS(e,"success"),e=>tS(e,"error")),ns=(0,i.useRef)(null),nl=(0,i.useRef)(""),ni=(0,i.useCallback)(e=>{var t;nl.current=e,null==(t=ns.current)||t.click()},[]),no=(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=nl.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 lG.includes(t)}(l))return void tS("Unsupported file type: ".concat(l,". Allowed: ").concat(lG.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return lq.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void tS("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,eP.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";tS(n,"error");return}let t=await e.json();tS("Uploaded: ".concat(t.filename),"success"),e_(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),tS("Upload failed. Please try again.","error")}},[f,tS]),{data:nc}=e3(),nd=null!=(u=null==nc?void 0:nc.hasUpdate)&&u,{lastAutoResponse:nu}=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||!S(r)||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,n){if(!n)return null;if("off"===n.mode)return{reason:"mode-off"};let a=function(e,t){if(0===t.length)return{outcome:"no-match"};let n=e.map(e=>e.length>2e4?e.slice(0,2e4):e);for(let e of t){if(e.length>200||!rk(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"}}(t,n.denyPatterns);return"match"===a.outcome?{reason:"deny-pattern",pattern:a.pattern}:"unusable"===a.outcome?{reason:"deny-pattern-unusable",pattern:a.pattern}:"safe"===n.mode?"yes_no"===e?null:{reason:"type-not-allowed"}:"allow-listed"===n.mode?n.allowPromptTypes.includes(e)?null:{reason:"type-not-allowed"}:null}(e.type,function(e){let t=[e.question];if(e.approvalTarget&&t.push(e.approvalTarget),"multiple_choice"===e.type)for(let n of e.options)t.push(n.label);else t.push(...e.options);return t}(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=iq(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:eN,isPromptWaiting:y.prompt.visible,promptData:y.prompt.data,autoYesEnabled:eF,lastServerResponseTimestamp:X,serverPollerActive:ee}),nm=(0,i.useCallback)(async()=>{D(null),R(!0),await td()&&await Promise.all([tu(),tm()]),R(!1)},[td,tu,tm]);!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:P,handleRetry:nm,fetchWorktree:td,fetchMessages:tu,fetchCurrentOutput:tm,setError:D}),(0,i.useEffect)(()=>{if(ti.current)return;let e=!0;return(async()=>{z.current||R(!0),await Promise.all([td(),tu(),tm()]),e&&(R(!1),ti.current=!0)})(),()=>{e=!1}},[td,tu,tm]);let nh=null!=(m=null==M||null==(r=M.sessionStatusByCli)||null==(a=r[eN])?void 0:a.isRunning)&&m;(0,i.useEffect)(()=>{if(L||P)return;let e=setInterval(async()=>{let e=[tm(),td()];g&&e.push(tu()),await Promise.all(e),O(e=>e+1)},nh?2e3:5e3);return()=>clearInterval(e)},[L,P,tm,td,tu,nh,g]),(0,i.useEffect)(()=>{th()},[f,ev,th]),(0,i.useEffect)(()=>{j.setLayoutMode(g?"tabs":"split")},[g,j]);let nx=(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"})(M,null!==y.error.type,eN),[M,y.error.type,eN]),nf=(0,i.useMemo)(()=>y.layout.mobileActivePane,[y.layout.mobileActivePane]),np=null!=(h=null==M?void 0:M.name)?h:"Unknown",ng=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_CONTENT",path:e,content:t})},[H]),nb=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_ERROR",path:e,error:t})},[H]),nv=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_LOADING",path:e,loading:t})},[H]),ny=(0,i.useCallback)((e,t)=>{H.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[H]),nj=function(e){var t,n,a;let{worktreeId:r,refreshToken:s=0,enabled:l=!0,limit:o=10}=e,[c,d]=(0,i.useState)(null),[u,m]=(0,i.useState)([]),[h,x]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),[g,b]=(0,i.useState)(!0),[v,y]=(0,i.useState)(null),[j,w]=(0,i.useState)(null),[k,N]=(0,i.useState)(!1),[C,S]=(0,i.useState)(!1),[T,E]=(0,i.useState)(null),[I,M]=(0,i.useState)(0),A=(0,i.useRef)(0),L=(0,i.useRef)(0),R=(0,i.useRef)(!1),P=(0,i.useRef)(!1),D=(0,i.useRef)(!1),F=(0,i.useRef)(!1);P.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,i.useEffect)(()=>{if(A.current+=1,L.current=0,R.current=!1,!F.current){F.current=!0;return}d(null),m([]),x(null),p(null),b(!0),y(null),w(null),E(null)},[r]),(0,i.useEffect)(()=>{if(!l)return;let e=0===L.current,t=15e3*!P.current;if(!e&&Date.now()-L.current<t||R.current)return;let n=A.current;R.current=!0,L.current=Date.now(),(async()=>{try{let[e,t]=await Promise.all([st(r),sn(r,o)]);if(n!==A.current)return;d(e),m(t),y(null)}catch(e){if(n!==A.current||ot(e))return;y(oe(e,"Failed to load verification data"))}finally{R.current=!1,n===A.current&&b(!1)}})()},[r,s,I,l,o]);let O=null!=(n=null!=h?h:null==(t=u[0])?void 0:t.id)?n:null,z=(0,i.useMemo)(()=>{var e,t;if(null===O)return null;let n=u.find(e=>e.id===O);return(null==n?void 0:n.status)==="running"?"".concat(O,":running:").concat(s,":").concat(I):"".concat(O,":").concat(null!=(e=null==n?void 0:n.status)?e:"unlisted",":").concat(null!=(t=null==n?void 0:n.finishedAt)?t:"")},[O,u,s,I]);(0,i.useEffect)(()=>{if(!l||null===O){p(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await sa(r,O,e.signal);if(t)return;p(n),w(null===n?"not-found":null)}catch(e){if(t||ot(e))return;p(null),w(oe(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,l,z]);let _=(0,i.useCallback)(()=>{L.current=0,M(e=>e+1)},[]),B=(0,i.useCallback)(e=>{x(e)},[]),V=(0,i.useCallback)(async()=>{if(!D.current){D.current=!0,S(!0),E(null);try{let e=await sr(r);x(e),L.current=0,M(e=>e+1)}catch(t){let e=t instanceof r9&&409===t.status;E({kind:e?"conflict":"error",message:oe(t,"Failed to start verification"),runningRunId:t instanceof r9?t.runningRunId:null}),e&&(L.current=0,M(e=>e+1))}finally{D.current=!1,S(!1)}}},[r]);return{task:c,runs:u,latestRun:null!=(a=u[0])?a:null,selectedRunId:O,selectedRun:f,loading:g,error:v,detailError:j,detailLoading:k,rerunPending:C,rerunFailure:T,selectRun:B,refresh:_,rerun:V}}({worktreeId:f,refreshToken:F,enabled:!L&&!P});return{activeActivity:eU,activeCliTab:eN,activeInstanceId:eE,activeTab:nf,agentInstances:eh,autoYesEnabled:eF,autoYesExpiresAt:eO,autoYesStateMap:Y,diffContent:tn,diffFilePath:ta,disableAutoFollow:ty,displayedAgents:tv,displayedInstances:tg,editorFilePath:$,error:P,fetchCurrentOutput:tm,fileInputRef:ns,fileSearch:tl,fileTreeRefresh:ez,handleActivityOpen:tO,handleActivityToggle:tF,handleAgentInstancesChange:tw,handleAutoYesToggle:tq,handleBackClick:tz,handleCloseDiff:ts,handleDelete:t7,handleDiffSelect:tr,handleDirtyChange:ny,handleEditorClose:tR,handleEditorSave:tD,handleFileInputChange:no,handleFilePanelSave:tL,handleFilePathClick:tE,handleFileSelect:tI,handleHistoryDisplayLimitChange:e0,handleHistoryUserOnlyChange:eX,handleInfoClick:tB,handleInfoModalClose:tV,handleInsertConsumed:te,handleInsertConsumedSingle:tt,handleInsertToMessage:e9,handleInsertToSplit:e7,handleKillCancel:t5,handleKillConfirm:t2,openKillConfirm:t0,openActiveKillConfirm:t1,killTarget:tG,isKillPending:tY,handleLoadContent:ng,handleLoadError:nb,handleMessageSent:tK,handleMobileFileViewerClose:tA,handleMobileTabChange:tU,handleMove:nn,resetFileTreeView:tP,handleMoveCancel:nr,handleMoveConfirm:na,handleNewDirectory:t8,handleNewFile:t4,handleNewFileCancel:t6,handleNewFileConfirm:t3,handleOpenFile:tM,handlePromptDismiss:tH,handlePromptRespond:tW,handleRename:t9,handleRetry:nm,handleSelectedAgentsChange:tj,handleSetLoading:nv,handleShowArchivedChange:eY,handleUpload:ni,handleVibeLocalContextWindowChange:tN,rosterReady:ev,handleVibeLocalModelChange:tk,handleWorktreeStatusChange:t_,hasUpdate:nd,historyDisplayLimit:eZ,historySubTab:eq,historyUserOnly:eQ,isEditorMaximized:G,isInfoModalOpen:_,isMobile:g,isMoveDialogOpen:nt,isSelectionListActive:en,isPagerActive:er,lastAutoResponse:nu,loading:L,makeAutoYesToggleHandler:t$,mobileFileViewerPath:U,mobileSelectedAgents:tb,moveTarget:ne,newFileParentPath:eW,openMobileDrawer:v,pendingInsertText:e6,pendingInsertTextMap:e4,selectedAgents:ed,setActiveCliTab:eS,setActiveInstanceId:eM,setEditorFilePath:q,setFocusedSplitIndex:e8,setHistorySubTab:eG,setIsEditorMaximized:J,setWorktree:A,showArchived:eJ,showNewFileDialog:eB,showToast:tS,state:y,tCommon:N,tWorktree:w,tabsActions:H,tabsState:W,toggleInstanceVisible:tp,vibeLocalContextWindow:ew,verification:nj,vibeLocalModel:ey,visibleInstanceIds:tf,worktree:M,worktreeName:np,worktreeStatus:nx}}({worktreeId:f}),[tM,tA]=(0,i.useState)(!1),[tL,tR]=(0,i.useState)(null),tP=(0,i.useCallback)(e=>{"memo"!==e&&tR(null),eC(e)},[eC]),tD=(0,i.useCallback)(()=>{tR(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eC("memo")},[eC]),tF=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,t6.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:f,active:"terminal"===y}),{viewportHeight:tO}=(0,i2.C)(),tz=(0,i.useCallback)(e=>{let t=oh.indexOf(y);if(-1===t)return;let n=t+e;n<0||n>=oh.length||tP(oh[n])},[y,tP]),{ref:t_}=(0,L.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===y),onSwipeLeft:()=>tz(1),onSwipeRight:()=>tz(-1)});if(e4)return(0,r.jsx)(lN,{});if(D)return(0,r.jsx)(lC,{message:D,onRetry:ez});let tB=(0,to.O6)(j,v,b),tV=null!=(o=null==ev?void 0:ev.label)?o:tB,tW=null!=(m=null==(t=null!=(u=null==tT||null==(n=tT.sessionStatusByInstance)?void 0:n[v])?u:null==tT||null==(a=tT.sessionStatusByCli)?void 0:a[b])?void 0:t.isRunning)&&m;return eX?(0,r.jsx)(T,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=tO?"".concat(tO,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(g,{worktreeName:tE,repositoryName:null==tT?void 0:tT.repositoryName,status:tI,gitStatus:null==tT?void 0:tT.gitStatus,onBackClick:$,onMenuClick:tt})}),tk.task&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(iJ,{task:tk.task,latestRun:tk.latestRun,latestRunGates:null!==tk.selectedRun&&tk.selectedRun.id===(null==(l=tk.latestRun)?void 0:l.id)?tk.selectedRun.gates:null,onOpen:tD,className:"w-full justify-start"})}),(null==tT?void 0:tT.gitStatus)&&tT.gitStatus.isBranchMismatch&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(iY,{isBranchMismatch:tT.gitStatus.isBranchMismatch,currentBranch:tT.gitStatus.currentBranch,initialBranch:tT.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":tb("detail.agentInstanceSelection"),children:A.map(e=>{var t,n,a;let s=(0,ti.kA)(null!=(a=null==tT||null==(t=tT.sessionStatusByInstance)?void 0:t[e.id])?a:null==tT||null==(n=tT.sessionStatusByCli)?void 0:n[e.cliTool]),l=tg("status.".concat(s)),i=v===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:tb("detail.statusPill",{label:(0,to.sw)(e),status:l})}),(0,to.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tA(!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":tb("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:t_,children:(0,r.jsx)(lm,{activeTab:y,worktreeId:f,worktree:tT,messages:tp.messages,cliToolId:b,instanceId:v,onFilePathClick:et,onFileSelect:en,onWorktreeUpdate:tm,onNewFile:eM,onNewDirectory:eI,onRename:eO,onDelete:G,onUpload:eV,onMove:eS,onFileTreeReset:tj,refreshTrigger:_,fileSearch:z,showToast:tf,selectedAgents:e9,onSelectedAgentsChange:om,useInstanceManagement:!0,instances:j,onInstancesChange:U,visibleInstanceIds:tS,onToggleInstanceVisible:tw,vibeLocalModel:tC,onVibeLocalModelChange:eH,vibeLocalContextWindow:tN,onVibeLocalContextWindowChange:eW,disableAutoFollow:M,historySubTab:eq,onHistorySubTabChange:td,onDiffSelect:J,onInsertToMessage:ed,showArchived:th,onShowArchivedChange:eB,historyDisplayLimit:e$,onHistoryDisplayLimitChange:ea,historyUserOnly:eG,onHistoryUserOnlyChange:er,verification:tk,toolsSubTabRequest:tL})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[e0&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(ep,{worktreeId:f,cliToolId:b,instanceId:v,onKeysSent:F,showPagerKeys:e1})}),(0,r.jsx)("div",{className:"p-2",children:(0,r.jsx)(eu,{worktreeId:f,onMessageSent:ek,cliToolId:b,instanceId:v,isSessionRunning:tW,pendingInsertText:tn,onInsertConsumed:ec,autoYesSlot:(0,r.jsx)(iU,{enabled:w,expiresAt:k,onToggle:K,lastAutoResponse:e2,cliToolName:b,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(C,{activeTab:y,onTabChange:tP,hasNewOutput:tF,hasPrompt:tp.prompt.visible,hasUpdate:eK,inFlow:!0}),!w&&(0,r.jsx)(P,{promptData:tp.prompt.data,visible:tp.prompt.visible,answering:tp.prompt.answering,onRespond:eF,onDismiss:eD,cliToolName:(0,to.oo)(b)}),(0,r.jsx)(B,{open:tM,onClose:()=>tA(!1),onSearch:()=>window.dispatchEvent(new CustomEvent("terminal-search-open")),onEnd:eb,endDisabled:!tW}),(0,r.jsx)(eQ,{isOpen:null!==e8,onClose:eN,worktreeId:f,filePath:null!=e8?e8:"",onFileSaved:X,onOpenFile:et}),(0,r.jsx)("input",{ref:O,type:"file",accept:lG.join(","),onChange:Z,className:"hidden","aria-label":tb("detail.uploadFile")}),(0,r.jsx)(tl.a,{isOpen:null!==ev,onClose:eh,title:tb("session.confirmEnd",{tool:tV}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tb("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eh,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tg("cancel")}),(0,r.jsx)("button",{type:"button",onClick:ex,disabled:ey,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:tg("end")})]})]})}),e7&&(0,r.jsx)(iX,{isOpen:eZ,onClose:eT,onConfirm:eE,worktreeId:f,sourcePath:e7.path,sourceType:e7.type}),(0,r.jsx)(i0,{isOpen:tx,parentPath:te,onConfirm:eL,onCancel:eA})]})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i1,{worktreeId:f,worktree:tT,worktreeName:tE,worktreeStatus:tI,instances:j,rosterReady:tr,activeInstanceId:v,setActiveInstanceId:ts,hasUpdate:eK,lastAutoResponse:e2,activeActivity:p,onActivityToggle:H,onActivityOpen:W,verification:tk,onBackClick:$,onInfoClick:es,onWorktreeStatusChange:eU,pendingInsertTextMap:ta,setFocusedSplitIndex:tc,handleInsertToSplit:em,handleInsertConsumed:eo,handleInsertToMessage:ed,autoYesStateMap:N,makeAutoYesToggleHandler:e6,showArchived:th,onShowArchivedChange:eB,historyDisplayLimit:e$,onHistoryDisplayLimitChange:ea,historyUserOnly:eG,onHistoryUserOnlyChange:er,onMessageSent:ek,onFilePathClick:et,showToast:tf,tabsState:ty,tabsActions:tv,onLoadContent:ej,onLoadError:ew,onSetLoading:e_,onFilePanelSave:ee,onDirtyChange:Y,onOpenFile:eR,diffContent:E,diffFilePath:I,onCloseDiff:q,fileSearch:z,fileTreeRefresh:_,onFileSelect:en,onNewFile:eM,onNewDirectory:eI,onRename:eO,onDelete:G,onUpload:eV,onMove:eS,onFileTreeReset:tj,onDiffSelect:J,onAgentInstancesChange:U,vibeLocalModel:tC,onVibeLocalModelChange:eH,vibeLocalContextWindow:tN,onVibeLocalContextWindowChange:eW,isInfoModalOpen:eY,onInfoModalClose:ei,onWorktreeUpdate:tm,fileInputRef:O,onFileInputChange:Z,onKillSession:eb,onRequestSessionEnd:ef,killTarget:ev,isKillPending:ey,onKillCancel:eh,onKillConfirm:ex,moveTarget:e7,isMoveDialogOpen:eZ,onMoveCancel:eT,onMoveConfirm:eE,showNewFileDialog:tx,newFileParentPath:te,onNewFileConfirm:eL,onNewFileCancel:eA,killDialogTitle:tb("session.confirmEnd",{tool:tV}),killDialogWarning:tb("session.endWarning"),cancelLabel:tg("cancel"),endLabel:tg("end")}),R&&(0,r.jsx)(tl.a,{isOpen:!0,onClose:Q,title:R.split("/").pop()||tb("fileViewer.editor"),size:"full",disableClose:eJ,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(ou,{worktreeId:f,filePath:R,onClose:Q,onSave:X,onMaximizedChange:tu})})})]})});function of(){let e=(0,s.useParams)().id;return(0,r.jsx)(l.GV,{children:(0,r.jsx)(ox,{worktreeId:e})})}},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},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),p=(0,a.useRef)(!0),g=(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)(()=>(p.current=!0,()=>{p.current=!1,f.current&&clearTimeout(f.current)}),[]);let b=(0,a.useCallback)(async e=>{if(!p.current)return;c(!0),u(null);let t=null,n=0;for(;n<=l;)try{if(await h.current(e),p.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))}}p.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!==g.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),p=(0,r.useRef)(0),g=(0,r.useRef)(null),b="horizontal"===n,v=(0,r.useCallback)(e=>{e.preventDefault(),f(!0),p.current=c(e,b)},[b]),y=(0,r.useCallback)(e=>{1===e.touches.length&&(f(!0),p.current=c(e,b))},[b]),j=(0,r.useCallback)(e=>{if(!x)return;let n=c(e,b);t(n-p.current),p.current=n},[x,b,t]),w=(0,r.useCallback)(e=>{if(!x||1!==e.touches.length)return;let n=c(e,b);t(n-p.current),p.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",j),document.addEventListener("mouseup",k),document.addEventListener("touchmove",w),document.addEventListener("touchend",k),document.body.style.userSelect="none",document.body.style.cursor=b?"col-resize":"row-resize"),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",w),document.removeEventListener("touchend",k),document.body.style.userSelect="",document.body.style.cursor=""}),[x,j,k,w,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:g,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")}}}},e=>{e.O(0,[6481,6809,4909,2770,790,4974,8566,9948,1191,5542,3968,6402,3361,6381,5229,2751,2053,1188,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);
|