commandmate 0.40.1 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +281 -281
- package/.next/app-path-routes-manifest.json +20 -20
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +9 -9
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/release-notes/route_client-reference-manifest.js +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/auth/login/route_client-reference-manifest.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_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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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-reference/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/direct-input/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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/notes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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]/tasks/route_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +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]/cancel/route_client-reference-manifest.js +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_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- 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_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_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +10 -10
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +20 -20
- package/.next/server/chunks/4443.js +1 -1
- package/.next/server/chunks/5164.js +1 -1
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/650.js +1 -1
- package/.next/server/chunks/8581.js +2 -2
- package/.next/server/chunks/8728.js +1 -1
- package/.next/server/chunks/9627.js +30 -24
- package/.next/server/chunks/9882.js +3 -3
- 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/static/chunks/{2407-d750620d0511e94f.js → 2407-7bd75de2f6be3692.js} +1 -1
- package/.next/static/chunks/{4768-979c8a03bed218e7.js → 4768-fc0aa1d0891cac08.js} +1 -1
- package/.next/static/chunks/530.578854fdd5d91542.js +1 -0
- package/.next/static/chunks/{8606-9a381b996f9b6834.js → 8606-79c36d4c204bbd38.js} +1 -1
- package/.next/static/chunks/app/{layout-3d3fcc8aac7b3bb5.js → layout-51fa91ea833c97fc.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-1e6300dd50cd9a4d.js +1 -0
- package/.next/static/chunks/{webpack-7e5907979c182510.js → webpack-49ade0526854dd4e.js} +1 -1
- package/.next/trace +13 -13
- package/dist/server/src/lib/auto-yes-poller.js +72 -1
- package/dist/server/src/lib/db/chat-db.js +38 -0
- package/dist/server/src/lib/detection/cli-patterns.js +11 -0
- package/dist/server/src/lib/detection/selection-shape.js +76 -0
- package/dist/server/src/lib/detection/tools/antigravity/detect.js +64 -0
- package/dist/server/src/lib/detection/tools/claude/detect.js +28 -1
- package/dist/server/src/lib/detection/tools/codex/cli-patterns.js +51 -0
- package/dist/server/src/lib/detection/tools/codex/detect.js +21 -2
- package/dist/server/src/lib/detection/tools/command-code/detect.js +14 -3
- package/dist/server/src/lib/polling/antigravity-permission-receipts.js +113 -0
- package/dist/server/src/lib/polling/response-checker.js +73 -4
- package/dist/server/src/lib/session/current-output-builder.js +25 -0
- package/dist/server/src/lib/session/layer-disagreement.js +108 -0
- package/dist/server/src/types/sidebar.js +1 -0
- package/package.json +1 -1
- package/release-notes/0.41.0.json +29 -0
- package/release-notes/0.41.1.json +16 -0
- package/.next/static/chunks/530.e31cc754677fed0f.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-a91e812ad9d94697.js +0 -1
- /package/.next/static/{JfzIPPhL-ikSVcJYOKgfD → _fBjTkjoWfOqdjl2SeMIN}/_buildManifest.js +0 -0
- /package/.next/static/{JfzIPPhL-ikSVcJYOKgfD → _fBjTkjoWfOqdjl2SeMIN}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1479],{3199:(e,t,n)=>{"use strict";n.d(t,{Vt:()=>s,aN:()=>l,zK:()=>u,I_:()=>i,JY:()=>o,sd:()=>c,kj:()=>d});let a=/^[a-zA-Z0-9][a-zA-Z0-9\-._/:]*$/,r=/^[a-zA-Z0-9][a-zA-Z0-9\-._]*$/,s=new Set(["copilot","opencode"]),l=new Set(["opencode"]);function i(e){let t=e.trim();if(!t)return{cliToolId:"claude",model:void 0};let{tokens:n,error:a}=function(e){let t=[],n="",a=!1,r=null;for(let s of e){if(r){s===r?r=null:n+=s;continue}if('"'===s||"'"===s){r=s,a=!0;continue}if(/\s/.test(s)){a&&(t.push(n),n="",a=!1);continue}n+=s,a=!0}return r?{tokens:[],error:"CLI Tool column has an unterminated quote"}:(a&&t.push(n),{tokens:t})}(t);if(a)return{cliToolId:t.split(/\s+/)[0],error:a};let r=n[0];return 1===n.length?{cliToolId:r,model:void 0}:s.has(r)?l.has(r)?function(e,t){let n={cliToolId:e},a=new Set,r=(e,n)=>{let a=t[n+1];return void 0===a||a.startsWith("-")?null:a};for(let s=0;s<t.length;s++){let l=t[s];if(a.has(l))return{cliToolId:e,error:"".concat(e,' option "').concat(l,'" is repeated')};switch(l){case"--model":case"-m":{let t=r(l,s);if(null===t)return{cliToolId:e,error:"".concat(e,' option "').concat(l,'" needs a value')};a.add("--model"),a.add("-m"),n.model=t,s++;break}case"--agent":{let t=r(l,s);if(null===t)return{cliToolId:e,error:"".concat(e,' option "').concat(l,'" needs a value')};a.add(l),n.agent=t,s++;break}case"--variant":{let t=r(l,s);if(null===t)return{cliToolId:e,error:"".concat(e,' option "').concat(l,'" needs a value')};a.add(l),n.variant=t,s++;break}case"--title":{let t=r(l,s);if(null===t)return{cliToolId:e,error:"".concat(e,' option "').concat(l,'" needs a value')};a.add(l),n.title=t,s++;break}case"--continue":case"-c":a.add("--continue"),a.add("-c"),n.continueSession=!0;break;default:return{cliToolId:e,error:"".concat(e," only supports: ").concat("opencode [--model <provider/model>] [--agent <name>] [--variant <name>] [--continue] [--title <text>]")}}}return n}(r,n.slice(1)):3===n.length&&"--model"===n[1]?{cliToolId:r,model:n[2]}:{cliToolId:r,error:"".concat(r," only supports: ").concat(r," --model <modelName>")}:{cliToolId:r,error:'CLI Tool "'.concat(r,'" does not support additional options')}}function o(e){return/[\x00-\x1f\x7f]/.test(e)?{valid:!1,reason:"Model name contains control characters"}:""===e.trim()?{valid:!1,reason:"Model name must not be empty"}:a.test(e)?e.length>128?{valid:!1,reason:"Model name exceeds ".concat(128," characters")}:{valid:!0}:{valid:!1,reason:"Model name contains invalid characters"}}function c(e,t){return/[\x00-\x1f\x7f]/.test(e)?{valid:!1,reason:"opencode ".concat(t," contains control characters")}:""===e.trim()?{valid:!1,reason:"opencode ".concat(t," must not be empty")}:r.test(e)?e.length>64?{valid:!1,reason:"opencode ".concat(t," exceeds ").concat(64," characters")}:{valid:!0}:{valid:!1,reason:"opencode ".concat(t," contains invalid characters")}}function d(e){return/[\x00-\x1f\x7f]/.test(e)?{valid:!1,reason:"opencode title contains control characters"}:""===e.trim()?{valid:!1,reason:"opencode title must not be empty"}:e.startsWith("-")?{valid:!1,reason:'opencode title must not start with "-"'}:e.includes("|")?{valid:!1,reason:'opencode title must not contain "|"'}:e.length>200?{valid:!1,reason:"opencode title exceeds ".concat(200," characters")}:{valid:!0}}function u(e){let t=[],n=i(e);if(n.error&&t.push(n.error),n.model){let e=o(n.model);e.valid||t.push(e.reason)}if(n.agent){let e=c(n.agent,"agent");e.valid||t.push(e.reason)}if(n.variant){let e=c(n.variant,"variant");e.valid||t.push(e.reason)}if(n.title){let e=d(n.title);e.valid||t.push(e.reason)}return{result:n,errors:t}}},4138:(e,t,n)=>{"use strict";n.d(t,{q:()=>s});var a=n(12115),r=n(9900);function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:r.pX,[t,n]=(0,a.useState)(!1),s=(0,a.useRef)(null);return(0,a.useEffect)(()=>()=>{null!==s.current&&(clearTimeout(s.current),s.current=null)},[]),{copied:t,markCopied:(0,a.useCallback)(()=>{n(!0),null!==s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n(!1)},e)},[e]),reset:(0,a.useCallback)(()=>{null!==s.current&&(clearTimeout(s.current),s.current=null),n(!1)},[])}}},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:x,onSwipeEnd:f}=e,h=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)},[]),I=(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]),T=(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(h){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==x||x({deltaX:n,deltaY:a})},[i,l,o,h,d,g,b,x]),E=(0,a.useCallback)(e=>{var a;if(!i||!N.current)return void j(!1);let o=h&&(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==f||f()},[i,l,h,g,b,t,n,r,s,f]),A=(0,a.useCallback)(()=>{N.current&&(N.current=null,C.current=null,j(!1),null==f||f())},[f]);return(0,a.useEffect)(()=>{let e=v.current;if(e)return e.addEventListener("touchstart",I),e.addEventListener("touchmove",T),e.addEventListener("touchend",E),e.addEventListener("touchcancel",A),()=>{e.removeEventListener("touchstart",I),e.removeEventListener("touchmove",T),e.removeEventListener("touchend",E),e.removeEventListener("touchcancel",A)}},[I,T,E,A]),{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"})})}},20252:(e,t,n)=>{Promise.resolve().then(n.bind(n,64725))},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),x=(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:x("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:x("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:x("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:x("pdfPreview.download")})]})]})}return(0,a.jsx)("iframe",{src:c,sandbox:l,title:x("pdfPreview.title",{path:n}),className:"w-full h-full border-0 bg-white","data-testid":"pdf-preview-iframe"})}let c=o},43424:(e,t,n)=>{"use strict";n.d(t,{OO:()=>l,cx:()=>r,hO:()=>s});let a="commandmate.lastOpenedWorktreeId";function r(){try{return window.localStorage.getItem(a)||null}catch(e){return null}}function s(e){if(e)try{window.localStorage.setItem(a,e)}catch(e){}}function l(e){let{lastOpenedId:t,worktreeIds:n}=e;return t&&n.includes(t)?"/worktrees/".concat(encodeURIComponent(t)):"/sessions"}},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}}},56639:(e,t,n)=>{"use strict";n.d(t,{iA:()=>d});var a=n(12115),r=n(69352);let s=["http:","https:","data:","blob:","//","/","#","mailto:","javascript:"],l=/^\s*<!doctype/i;function i(e){return new DOMParser().parseFromString(e,"text/html")}var o=n(76246);async function c(e,t){try{let n=await fetch("/api/worktrees/".concat(e,"/files/").concat((0,o.o)(t)));if(!n.ok)return null;let a=await n.json();if(!a||"object"!=typeof a)return null;let{isImage:r,content:s}=a;if(!0!==r||"string"!=typeof s||!s.startsWith("data:"))return null;return s}catch(e){return null}}function d(e,t,n){let[o,d]=(0,a.useState)(null),u=(0,a.useMemo)(()=>(function(e,t){let n=i(e),a=new Set,l=[];for(let e of Array.from(n.querySelectorAll("img[src]"))){var o;let n=null!=(o=e.getAttribute("src"))?o:"";if(a.has(n)||!function(e){if(!e)return!1;let t=e.toLowerCase();return!s.some(e=>t.startsWith(e))}(n))continue;let i=(0,r.WU)(t,n);null!==i&&(a.add(n),l.push({src:n,resolvedPath:i}))}return l})(n,t).slice(0,50),[n,t]);return((0,a.useEffect)(()=>{if(0===u.length)return;let a=!1;return Promise.all(u.map(t=>{let{resolvedPath:n}=t;return c(e,n)})).then(r=>{if(a)return;let s=new Map,o=0;r.forEach((e,t)=>{null!==e&&(o+e.length>2e7||(o+=e.length,s.set(u[t].src,e)))}),d({worktreeId:e,filePath:t,htmlContent:n,html:function(e,t){if(0===t.size)return e;let n=i(e);for(let e of Array.from(n.querySelectorAll("img[src]"))){var a;let n=t.get(null!=(a=e.getAttribute("src"))?a:"");void 0!==n&&e.setAttribute("src",n)}let r=n.documentElement.outerHTML;return l.test(e)?"<!DOCTYPE html>\n".concat(r):r}(n,s)})}).catch(()=>{}),()=>{a=!0}},[e,t,n,u]),o&&o.worktreeId===e&&o.filePath===t&&o.htmlContent===n)?o.html:n}},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),x=(0,a.useRef)(n),f=(0,a.useRef)(i),h=(0,a.useRef)(null),p=(0,a.useRef)(!0),g=(0,a.useRef)(t);(0,a.useEffect)(()=>{m.current=t},[t]),(0,a.useEffect)(()=>{x.current=n},[n]),(0,a.useEffect)(()=>{f.current=i},[i]),(0,a.useEffect)(()=>(p.current=!0,()=>{p.current=!1,h.current&&clearTimeout(h.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 x.current(e),p.current){var a;c(!1),u(null),null==(a=f.current)||a.call(f)}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)(()=>{h.current&&(clearTimeout(h.current),h.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(),h.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})},64725:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>oJ});var a,r=n(95155),s=n(12115),l=n(20063),i=n(67909),o=n(18955),c=n(37772),d=n(3005),u=n(48407),m=n(48481),x=n(76471),f=n(92614),h=n(64269);let p=(0,s.memo)(function(e){let{path:t,className:n="w-6 h-6"}=e;return(0,r.jsx)("svg",{className:n,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:t})})}),g={menu:"M4 6h16M4 12h16M4 18h16",search:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"};function b(e){let{worktreeName:t,repositoryName:n,status:a,statusUnclassified:s,gitStatus:l,onMenuClick:i}=e,c=(0,o.c)("common"),d=(0,o.c)("worktree"),b=(0,o.c)("commandPalette"),{setOpen:v}=(0,f.C)(),y=(0,x.Mq)(a,s);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:i&&(0,r.jsx)(u.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-menu-button",onClick:i,"aria-label":c("menu"),className:"p-2 -ml-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(p,{path:g.menu})})}),(0,r.jsxs)("div",{className:"flex-1 flex items-center justify-center min-w-0 px-2",children:[(0,r.jsx)(m.m,{"data-testid":"status-indicator",status:a,size:"sm",label:y?c(x.rH):void 0,className:y?"mr-2 ".concat(x.Jd):"mr-2","data-unclassified":y?"true":void 0}),(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}),l&&"(unknown)"!==l.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:l.currentBranch,"data-testid":"mobile-branch-name",children:(0,h.W5)(l.currentBranch,20)}),l.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:d("git.uncommittedChanges"),children:"*"})]})]})]})]}),(0,r.jsx)("div",{className:"w-10 flex-shrink-0 flex items-center justify-end",children:(0,r.jsx)(u.$n,{variant:"ghost",type:"button","data-testid":"mobile-header-command-palette-trigger",onClick:()=>v(!0),"aria-label":b("mobileTrigger"),title:b("mobileTrigger"),className:"p-2 -mr-2 rounded-full hover:bg-muted transition-colors dark:text-foreground",children:(0,r.jsx)(p,{path:g.search})})})]})})}var v=n(22479),y=n(26983),j=n(70198),w=n(53842),k=n(23327);function N(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 C=[{id:"terminal",labelKey:"tabs.terminal",icon:(0,r.jsx)(v.A,{size:20,"aria-hidden":"true"})},{id:"history",labelKey:"tabs.history",icon:(0,r.jsx)(y.A,{size:20,"aria-hidden":"true"})},{id:"files",labelKey:"tabs.files",icon:(0,r.jsx)(j.A,{size:20,"aria-hidden":"true"})},{id:"memo",labelKey:"tabs.memo",icon:(0,r.jsx)(w.A,{size:20,"aria-hidden":"true"})},{id:"info",labelKey:"tabs.info",icon:(0,r.jsx)(k.A,{size:20,"aria-hidden":"true"})}];function S(e){let{activeTab:t,onTabChange:n,hasNewOutput:a=!1,hasPrompt:l=!1,hasUpdate:i=!1,onSearchParamsChange:c,inFlow:d=!1}=e,u=(0,o.c)("worktree"),m=(0,s.useRef)([]),x=(0,s.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]),f=(0,s.useCallback)(e=>{n(e),null==c||c("memo"===e?"notes":e)},[n,c]),h=(0,s.useCallback)((e,t)=>{var n;let a=null;switch(e.key){case"ArrowRight":case"ArrowDown":a=(t+1)%C.length;break;case"ArrowLeft":case"ArrowUp":a=(t-1+C.length)%C.length;break;case"Home":a=0;break;case"End":a=C.length-1;break;default:return}e.preventDefault(),null==(n=m.current[a])||n.focus(),f(C[a].id)},[f]),p=(0,s.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")}),l&&(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,l,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:C.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:()=>f(e.id),onKeyDown:e=>h(e,n),className:x(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&&i&&(0,r.jsx)(N,{"data-testid":"info-update-badge",className:"absolute top-1 right-1","aria-label":u("tabs.updateAvailable")})]},e.id))})}var I=n(68276),T=n(87364);let E={fadeIn:"animate-fade-in",fadeOut:"animate-fade-out",none:""};function A(e){let{visible:t,duration:n=200}=e,[a,r]=(0,s.useState)(t?"visible":"hidden"),l=(0,s.useRef)(null),i=(0,s.useRef)(t);(0,s.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,s.useEffect)(()=>{let e=i.current;i.current=t,l.current&&(clearTimeout(l.current),l.current=null);let a=e=>{l.current=setTimeout(()=>{r(e),l.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,s.useMemo)(()=>{switch(a){case"fade-in":return E.fadeIn;case"fade-out":return E.fadeOut;default:return E.none}},[a]),isAnimating:c}}var M=n(92539),R=n(8269);let L=[/^[^\S\n]*type\s+something\b/i];function P(e){return!0===e.requiresTextInput&&L.some(t=>t.test(e.label))}function D(e){var t,n;return"multiple_choice"!==e.type||!0===e.multiSelect?null:null!=(n=null==(t=e.options.find(e=>e.isDefault))?void 0:t.number)?n:null}function F(e){return"multiple_choice"!==e.type||!0!==e.multiSelect?[]:e.options.filter(e=>!0===e.checked).map(e=>e.number)}let O={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"},z=(0,s.memo)(function(e){let{promptData:t,visible:n,answering:a,onRespond:l,onDismiss:i,cliToolName:o}=e,{shouldRender:c,animationClass:d}=A({visible:n&&null!==t,duration:300}),u=(0,s.useId)(),m=n&&null!==t,x=(0,M.r)({active:m}),[f,h]=(0,s.useState)(0);(0,s.useEffect)(()=>{n||h(0)},[n]);let p=(0,s.useCallback)(e=>{let{deltaY:t}=e;h(t>0?t:0)},[]),g=(0,s.useCallback)(()=>{null==i||i()},[i]),b=(0,s.useCallback)(()=>{h(0)},[]),{ref:v}=(0,R.hU)({axis:"vertical",threshold:100,enabled:m,onSwipeMove:p,onSwipeDown:g,onSwipeEnd:b}),y=(0,s.useCallback)(e=>{x.current=e,v.current=e},[x,v]),j=(0,s.useCallback)(()=>{i&&i()},[i]),w=(0,s.useCallback)(e=>{e.stopPropagation()},[]);if(!c||!t)return null;let k="animate-fade-out"===d;return(0,r.jsxs)(T.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:f>0?"translateY(".concat(f,"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)(_,{promptData:t,answering:a,onRespond:l,labelId:u,cliToolName:o})})]})]})});function _(e){let{promptData:t,answering:n,onRespond:a,labelId:l,cliToolName:i}=e,c=(0,o.c)("prompt"),[d,m]=(0,s.useState)(()=>D(t)),[x,f]=(0,s.useState)(()=>F(t)),[h,p]=(0,s.useState)(""),[g,b]=(0,s.useState)(!1),v=function(e){let t=[e.question];if("multiple_choice"===e.type){var n,a;for(let r of(t.push(String(null!=(a=null==(n=e.askUserQuestion)?void 0:n.questionIndex)?a:"")),e.options))t.push("".concat(r.number,":").concat(r.label))}return t.join("\0")}(t),[y,j]=(0,s.useState)(v);v!==y&&(j(v),m(D(t)),f(F(t)),p(""));let w="multiple_choice"===t.type&&!0===t.multiSelect?t.options:null,k=(0,s.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===d))?e:null},[t,d]),N=(0,s.useMemo)(()=>(null!=w?w:[]).filter(e=>x.includes(e.number)&&P(e)).length,[w,x]),C=null!==w?N>0:null!==k&&P(k),S=n||g,T=(0,s.useCallback)((e,t)=>{f(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},[]),E=(0,s.useCallback)(async e=>{if(!S){b(!0);try{await a(e)}catch(e){}finally{b(!1)}}},[S,a]),A=(0,s.useCallback)(async()=>{if(!S&&null!==d){b(!0);try{let e=C&&h.trim()?h.trim():d.toString();await a(e)}catch(e){}finally{b(!1)}}},[S,a,d,C,h]),M=(0,s.useCallback)(async()=>{if(S)return;let e=[...x].sort((e,t)=>e-t);if(0===e.length)return;let t=C?h.trim():e.join(",");if(""!==t){b(!0);try{await a(t)}catch(e){}finally{b(!1)}}},[S,a,x,C,h]);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{id:l,className:"text-lg font-semibold text-foreground",children:i?c("confirmationFrom",{toolName:i}):c("confirmationFromClaude")}),(0,I.XF)(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}),S&&(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)(u.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:c("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(B,{promptData:t,disabled:S,onYes:()=>E("yes"),onNo:()=>E("no")}),"multiple_choice"===t.type&&null!==w&&(0,r.jsx)(U,{promptData:t,disabled:S,checkedNumbers:x,onToggleOption:T,textInputValue:h,onTextInputChange:p,showTextInput:C,onSubmit:M}),"multiple_choice"===t.type&&null===w&&(0,r.jsx)(V,{promptData:t,disabled:S,selectedOption:d,onSelectOption:m,textInputValue:h,onTextInputChange:p,showTextInput:C,onSubmit:A})]})}let B=(0,s.memo)(function(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,o.c)("prompt"),i="yes"===t.defaultOption,c="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(O.base," ").concat(O.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(O.base," ").concat(c?O.defaultSelected:O.secondary),children:l("no")})]})}),V=(0,s.memo)(function(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:l,textInputValue:i,onTextInputChange:c,showTextInput:d,onSubmit:m}=e,x=(0,s.useId)(),f=(0,o.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:f("selectAnOption")}),(0,r.jsx)(u.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>l(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)(u.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:f("default")})]})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:i,onChange:e=>c(e.target.value),disabled:n,placeholder:f("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:m,disabled:n||null===a,className:"w-full ".concat(O.base," ").concat(O.primary),children:f("submit")})]})}),U=(0,s.memo)(function(e){let{promptData:t,disabled:n,checkedNumbers:a,onToggleOption:l,textInputValue:i,onTextInputChange:c,showTextInput:d,onSubmit:m}=e,x=(0,s.useId)(),f=(0,o.c)("prompt"),h=0===a.length,p=d&&""===i.trim();return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"multi-select-prompt-actions",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"multi-select-hint",children:f("multiSelectHint")}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAllThatApply")}),(0,r.jsx)("div",{role:"group","aria-label":f("selectAllThatApply"),className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a.includes(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)(u.Sc,{checked:t,onCheckedChange:t=>l(e.number,!0===t),disabled:n,className:"mt-1","data-testid":"multi-select-option-".concat(e.number),"aria-label":"".concat(e.number,". ").concat(e.label)}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)("span",{className:"font-medium text-foreground",children:[e.number,". ",e.label]})})]},e.number)})})]}),d&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{htmlFor:"multi-text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"multi-text-input-".concat(x),type:"text",value:i,onChange:e=>c(e.target.value),disabled:n,placeholder:f("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","data-testid":"multi-select-submit",onClick:m,disabled:n||h||p,className:"w-full ".concat(O.base," ").concat(O.primary),children:f("submit")})]})});var H=n(86651),K=n(11047),W=n(76482),q=n(84926),$=n(37586),G=n(24033),J=n(97624),Y=n(37354),Q=n(54014),X=n(75676),Z=n(26232),ee=n(41898),et=n(66966),en=n(83012);let ea="application/x-commandmate-agent-instance",er=[{mode:"terminal",labelKey:"surfaceMode.showTerminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.showChat",icon:$.A}],es="session-note-open";function el(e,t){let n=(0,et.rC)(),a=null==n?void 0:n.worktrees,r=null==n?void 0:n.refresh,l=(0,s.useMemo)(()=>(function(e,t,n){var a;let r=null==e?void 0:e.find(e=>e.id===t),s=null==r||null==(a=r.sessionNotes)?void 0:a[n];return s&&"string"==typeof s.text&&0!==s.text.length?{text:s.text,updatedAt:"number"==typeof s.updatedAt?s.updatedAt:0}:null})(a,e,t),[a,e,t]),[i,o]=(0,s.useState)(null);(0,s.useEffect)(()=>{o(null)},[e,t]),(0,s.useEffect)(()=>{var e,t;if(null===i)return;let n=null===i.value?null===l:null!==l&&l.text===i.value.text,a=(null==l?void 0:l.text)!==(null==(e=i.base)?void 0:e.text)||(null==l?void 0:l.updatedAt)!==(null==(t=i.base)?void 0:t.updatedAt);(n||a)&&o(null)},[i,l]);let c=(0,s.useCallback)(n=>{let a=n.replace(/\s+/g," ").trim();Array.from(a).length>100||(o({value:a.length>0?{text:a,updatedAt:Date.now()}:null,base:l}),(async()=>{try{if(!(await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/instances/notes"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instanceId:t,text:a})})).ok)return void o(null);await (null==r?void 0:r())}catch(e){o(null)}})())},[t,r,l,e]);return{note:i?i.value:l,save:c}}function ei(e){let{initialText:t,onCommit:n,onCancel:a,ariaLabel:l,placeholder:i,testId:o}=e,[c,d]=(0,s.useState)(t),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e,t;null==(e=u.current)||e.focus(),null==(t=u.current)||t.select()},[]);let m=(0,s.useCallback)(e=>{if("Enter"===e.key){if(e.nativeEvent.isComposing)return;e.preventDefault(),n(c);return}"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},[a,n,c]);return(0,r.jsx)("input",{ref:u,type:"text",value:c,maxLength:100,placeholder:i,"aria-label":l,"data-testid":o,onChange:e=>d(e.target.value),onKeyDown:m,className:"w-full rounded border border-border bg-surface px-2 py-1 text-xs text-surface-foreground placeholder:text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"})}let eo=(0,s.memo)(function(e){var t;let{worktreeId:n,splitIndex:a,cliToolId:l,instanceId:i,instance:c,availableInstances:d,onInstanceChange:u,status:f="idle",statusUnclassified:h=!1,agentModel:p,agentUsage:g,agentUsageDetail:b,onFocus:v,attaching:y=!1,headerExtras:j,surfaceMode:w=X.wf,onSurfaceModeChange:k,isMaximized:N=!1,onToggleMaximize:C,terminal:S,footer:I,bodyRef:T,style:E,onDropInstance:A,draggedInstanceId:M}=e,R=(0,o.c)("worktree"),L=(0,o.c)("common"),P=(0,x.Mq)(f,h),[D,F]=(0,s.useState)(null),{note:O,save:z}=el(n,i),[_,B]=(0,s.useState)(!1);(0,s.useEffect)(()=>{B(!1)},[n,i]);let V=(0,s.useCallback)(()=>B(!0),[]),U=(0,s.useCallback)(()=>B(!1),[]),H=(0,s.useCallback)(e=>{z(e),B(!1)},[z]),W=(0,s.useCallback)(()=>{setTimeout(()=>B(!0),0)},[]),q=null!=A,$=(0,s.useCallback)(()=>null==M||d.some(e=>e.id===M)?"allowed":"forbidden",[M,d]),et=(0,s.useCallback)(e=>{if(!q)return;e.preventDefault();let t=$();e.dataTransfer.dropEffect="forbidden"===t?"none":"move",F(e=>e===t?e:t)},[q,$]),es=(0,s.useCallback)(e=>{if(!q)return;e.preventDefault();let t=$();F(e=>e===t?e:t)},[q,$]),eo=(0,s.useCallback)(()=>{q&&F(null)},[q]),ec=(0,s.useCallback)(e=>{if(!q)return;e.preventDefault(),F(null);let t=e.dataTransfer.getData(ea);t&&(null==A||A(t))},[q,A]),ed=(0,s.useCallback)(()=>{window.dispatchEvent(new CustomEvent("terminal-search-open"))},[]),eu=(0,s.useCallback)(()=>{v()},[v]),em="Terminal split ".concat(a+1),ex=(0,Q.sw)(null!=c?c:{cliTool:l}),ef=R("terminal.selectInstance",{split:em}),eh=R("terminal.searchOutput",{split:em}),ep=R("sessionNote.editLabel",{split:em}),eg=O?(0,en.Uq)(new Date(O.updatedAt)):"",eb=O?R("sessionNote.label",{note:O.text,time:eg}):"";return(0,r.jsxs)("div",{role:"region","aria-label":em,"data-testid":"terminal-split-pane-".concat(a),"data-split-index":a,style:E,className:"flex flex-col min-w-0 h-full rounded-lg overflow-hidden border border-border bg-surface".concat(null===D?" focus-within:ring-1 focus-within:ring-accent-500/30":"").concat("allowed"===D?" ring-2 ring-accent-400":"forbidden"===D?" ring-2 ring-red-300 cursor-not-allowed":""),onFocusCapture:eu,onMouseDown:v,onDragOver:et,onDragEnter:es,onDragLeave:eo,onDrop:ec,children:[(0,r.jsxs)("div",{className:"relative px-2 py-1 flex items-center gap-2 bg-surface-2 border-b border-border flex-shrink-0",children:[(0,r.jsxs)(Z.rI,{children:[(0,r.jsxs)(Z.ty,{"data-testid":"cli-selector-".concat(a),"aria-label":ef,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)(m.m,{status:f,size:"sm","aria-hidden":!0,"data-testid":"split-status-indicator-".concat(a),label:P?L(x.rH):void 0,className:P?x.Jd:void 0,"data-unclassified":P?"true":void 0}),(0,r.jsx)("span",{className:"truncate",children:ex}),(0,r.jsx)(G.A,{size:14,"aria-hidden":"true",className:"flex-shrink-0 opacity-70"})]}),(0,r.jsxs)(Z.SQ,{align:"start",className:"min-w-[10rem]",children:[(0,r.jsx)(Z.Hr,{value:i,onValueChange:u,children:d.map(e=>(0,r.jsx)(Z.Ht,{value:e.id,children:(0,Q.sw)(e)},e.id))}),(0,r.jsx)(Z.mB,{}),(0,r.jsxs)(Z._2,{"data-testid":"split-session-note-menu-item-".concat(a),onSelect:W,children:[(0,r.jsx)(K.A,{size:14,"aria-hidden":"true",className:"opacity-70"}),R("sessionNote.menuItem")]})]})]}),k?(0,r.jsx)("div",{role:"group","aria-label":R("surfaceMode.groupLabel",{split:em}),"data-testid":"surface-mode-toggle-".concat(a),className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-border bg-surface p-0.5",children:er.map(e=>{let{mode:t,labelKey:n,icon:s}=e,l=w===t,i=R(n);return(0,r.jsx)(ee.m_,{content:i,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:()=>k(t),"aria-pressed":l,"aria-label":i,"data-testid":"surface-mode-".concat(t,"-").concat(a),className:"flex items-center justify-center rounded px-1.5 py-0.5 touch-manipulation transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(l?"bg-accent-500/15 text-accent-600 dark:text-accent-400":"text-muted-foreground hover:bg-muted hover:text-surface-foreground"),children:(0,r.jsx)(s,{size:14,"aria-hidden":"true"})})},t)})}):null,p&&(0,r.jsx)("span",{"data-testid":"split-agent-model-".concat(a),title:R("agentModel.modelLabel",{model:p}),className:"min-w-0 truncate text-[11px] leading-none text-muted-foreground ".concat(O?"max-w-[5rem] shrink-[4]":"max-w-[10rem]"),children:p}),g&&(0,r.jsx)("span",{"data-testid":"split-agent-usage-".concat(a),title:null!=b?b:R("agentSession.chipLabel",{usage:g}),className:"min-w-0 max-w-[10rem] truncate text-[11px] leading-none tabular-nums text-muted-foreground",children:g}),O&&(0,r.jsxs)("button",{type:"button",onClick:V,"aria-label":ep,title:eb,"data-testid":"split-session-note-".concat(a),className:"flex min-w-0 max-w-[16rem] shrink items-center gap-1 rounded px-1 py-0.5 text-[11px] leading-none text-muted-foreground hover:bg-muted-foreground/10 hover:text-surface-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,r.jsx)(K.A,{size:11,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:O.text}),(0,r.jsx)("span",{"data-testid":"split-session-note-time-".concat(a),className:"shrink-0 tabular-nums opacity-70",children:eg})]}),j,(0,r.jsx)(ee.m_,{content:eh,placement:"bottom",className:"ml-auto",children:(0,r.jsx)("button",{type:"button",onClick:ed,"aria-label":eh,"data-testid":"terminal-search-button-".concat(a),className:"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"})})})}),C?(0,r.jsx)(ee.m_,{content:"".concat(N?R("terminal.restoreSplits"):R("terminal.maximizeSplit",{split:em})," — ").concat(R("terminal.maximizeShortcutHint")),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsx)("button",{type:"button",onClick:C,"aria-pressed":N,"aria-label":N?R("terminal.restoreSplits"):R("terminal.maximizeSplit",{split:em}),"data-testid":"toggle-maximize-".concat(a),className:"flex flex-shrink-0 items-center justify-center px-1.5 py-0.5 text-muted-foreground hover:text-surface-foreground hover:bg-muted-foreground/10 rounded transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:N?(0,r.jsx)(J.A,{size:14,"aria-hidden":"true"}):(0,r.jsx)(Y.A,{size:14,"aria-hidden":"true"})})}):null,_?(0,r.jsxs)("div",{"data-testid":"split-session-note-editor-".concat(a),className:"absolute inset-x-2 top-full z-30 mt-1 rounded-md border border-border bg-surface p-2 shadow-lg",children:[(0,r.jsx)(ei,{initialText:null!=(t=null==O?void 0:O.text)?t:"",onCommit:H,onCancel:U,ariaLabel:ep,placeholder:R("sessionNote.placeholder"),testId:"split-session-note-input-".concat(a)}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:R("sessionNote.hint")})]}):null]}),(0,r.jsxs)("div",{ref:T,className:"flex-1 min-h-0 relative","data-testid":"split-body-".concat(a),children:[y?(0,r.jsxs)("div",{"data-testid":"terminal-attach-skeleton-".concat(a),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 ",ex," session..."]}):null,S]}),(0,r.jsx)("div",{className:"flex-shrink-0 border-t border-border p-2 bg-surface-2",children:I})]})}),ec={tab:"directInputKeyboard.unavailableTab",chat:"directInputKeyboard.unavailableChat",session:"directInputKeyboard.unavailableSession"};function ed(e){let{open:t,onClose:n,onSearch:a,searchTarget:l="terminal",onEnd:i,endDisabled:c=!1,onDirectInput:d,directInputUnavailableReason:u=null}=e,m=(0,o.c)("worktree"),x=(0,s.useId)(),f=(0,s.useId)(),h=(0,M.r)({active:t}),p=(0,s.useCallback)(()=>{a(),n()},[a,n]),g=(0,s.useCallback)(()=>{i(),n()},[i,n]),b=(0,s.useCallback)(()=>{window.dispatchEvent(new CustomEvent(es)),n()},[n]),v=(0,s.useCallback)(()=>{d&&null===u&&(n(),d())},[d,u,n]);return((0,s.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:h,"data-testid":"mobile-terminal-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:m("terminal.moreActions")}),(0,r.jsxs)("div",{className:"px-2 pb-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-search",onClick:p,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)(H.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),m("chat"===l?"chatTranscript.openSearch":"terminal.searchTerminal")]}),(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-session-note",onClick:b,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)(K.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),m("sessionNote.menuItem")]}),d?(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-direct-input",onClick:v,"aria-label":m("directInputKeyboard.menuItem"),"aria-disabled":null!==u||void 0,"aria-describedby":null!==u?f:void 0,className:"flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left text-sm text-foreground transition-colors touch-manipulation ".concat(null!==u?"":"hover:bg-muted"),children:[(0,r.jsx)(W.A,{size:18,"aria-hidden":"true",className:"shrink-0 text-muted-foreground ".concat(null!==u?"opacity-40":"")}),(0,r.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,r.jsx)("span",{className:null!==u?"opacity-40":void 0,children:m("directInputKeyboard.menuItem")}),null!==u?(0,r.jsx)("span",{id:f,"data-testid":"actions-sheet-direct-input-reason",className:"text-xs text-muted-foreground",children:m(ec[u])}):null]})]}):null,(0,r.jsxs)("button",{type:"button","data-testid":"actions-sheet-end",onClick:g,disabled:c,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)(q.A,{size:18,"aria-hidden":"true"}),m("terminal.endSession")]})]})]})]}):null}var eu=n(65229),em=n(9900);let ex=["Enter","Escape","Tab","BTab","BSpace","DC","Up","Down","Left","Right","Home","End","PageUp","PageDown","C-a","C-b","C-c","C-d","C-e","C-f","C-g","C-h","C-i","C-j","C-k","C-l","C-m","C-n","C-o","C-p","C-q","C-r","C-s","C-t","C-u","C-v","C-w","C-x","C-y","C-z"];function ef(e){return"string"==typeof e&&ex.includes(e)}let eh={Enter:"Enter",Escape:"Escape",Backspace:"BSpace",Delete:"DC",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown"};function ep(e,t,n,a){let[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),c=(0,s.useRef)([]),d=(0,s.useRef)(!1),u=(0,s.useRef)(0),m=(0,s.useRef)(!0),x=(0,s.useRef)(null),f=(0,s.useRef)(a);(0,s.useEffect)(()=>{f.current=a},[a]),(0,s.useEffect)(()=>(m.current=!0,()=>{m.current=!1,null!==x.current&&(clearTimeout(x.current),x.current=null)}),[]);let h=(0,s.useCallback)((e,t)=>{!e.settled&&(e.settled=!0,e.resolve(t),u.current-=1,0===u.current&&m.current&&o(!1))},[]),p=(0,s.useCallback)(()=>{let a=()=>{if(d.current)return;let r=c.current.splice(0,32);if(0===r.length)return;d.current=!0;let s=r.map(e=>e.event),i=n&&n!==t?{cliToolId:t,events:s,instanceId:n}:{cliToolId:t,events:s};fetch("/api/worktrees/".concat(encodeURIComponent(e),"/direct-input"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>{if(!e.ok)throw Error("direct-input responded ".concat(e.status));for(let{ticket:e}of(d.current=!1,r))null!==e&&(e.remaining-=1,0===e.remaining&&h(e,!0));if(c.current.length>0)return void a();m.current&&(null!==x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{var e;x.current=null,null==(e=f.current)||e.call(f)},em.LK))}).catch(()=>{d.current=!1;let e=c.current;for(let{ticket:t}of(c.current=[],[...r,...e]))null!==t&&h(t,!1);m.current&&l("directInput.error")})};a()},[e,t,n,h]);return{send:(0,s.useCallback)(e=>{if(0!==e.length){for(let t of(l(null),e))c.current.push({event:t,ticket:null});p()}},[p]),error:r,sendAndWait:(0,s.useCallback)(e=>0===e.length?Promise.resolve(!0):(l(null),new Promise(t=>{let n={remaining:e.length,settled:!1,resolve:t};for(let t of(u.current+=1,o(!0),e))c.current.push({event:t,ticket:n});p()})),[p]),isSending:i}}function eg(e,t,n,a,r){return r?{kind:"named",id:e,label:t,key:n,repeats:a,swipeUp:r}:{kind:"named",id:e,label:t,key:n,repeats:a}}let eb=[[eg("esc","ESC","Escape",!1),eg("enter","ENTER","Enter",!1),eg("bs","BS","BSpace",!0,{key:"DC",label:"DEL"}),eg("home","HOME","Home",!1),eg("up","↑","Up",!0),eg("end","END","End",!1),eg("pgup","PGUP","PageUp",!0)],[eg("tab","TAB","Tab",!1),{kind:"modifier",id:"ctrl",label:"CTRL"},{kind:"modifier",id:"shift",label:"SHIFT"},eg("left","←","Left",!0),eg("down","↓","Down",!0),eg("right","→","Right",!0),eg("pgdn","PGDN","PageDown",!0)]];function ev(e){return[...e].map(e=>({kind:"char",char:e,span:1}))}function ey(e,t,n){return[e,...ev(t),{kind:"char",char:" ",span:4},...ev(n)]}let ej={alpha:[ev("qwertyuiop"),ev("asdfghjkl-"),ev("zxcvbnm,./"),ey({kind:"page",target:"symbol",label:"123",span:2},"_:","'?")],symbol:[ev("1234567890"),ev("!@#$%^&*()"),ev("~`|\\[]{}<>"),ey({kind:"page",target:"alpha",label:"ABC",span:2},"+=",';"')]},ew={Escape:"ESC",Enter:"ENTER",BSpace:"BS",DC:"DEL",Home:"HOME",End:"END",PageUp:"PGUP",PageDown:"PGDN",Up:"↑",Down:"↓",Left:"←",Right:"→",Tab:"TAB",BTab:"⇧TAB"},ek=/^[a-z]$/;function eN(e,t){if(null===t)return"named"===e.type?{type:"key",key:e.key}:{type:"text",text:e.char};if("ctrl"===t.modifier){if("char"!==e.type||!ek.test(e.char))return null;let t="C-".concat(e.char);return ef(t)?{type:"key",key:t}:null}return"named"===e.type?"Tab"===e.key?{type:"key",key:"BTab"}:null:ek.test(e.char)?{type:"text",text:e.char.toUpperCase()}:null}function eC(e){return e.length>=32}function eS(e,t){let{sending:n,staged:a,modifier:r}=t;if(n)return!1;switch(e.kind){case"press":return!eC(a)&&null!==eN(e.press,r);case"page":return null===r;case"modifier":return!0}}function eI(e){null!==e.timer&&clearTimeout(e.timer),null!==e.interval&&clearInterval(e.interval),e.timer=null,e.interval=null}let eT={WebkitTouchCallout:"none",WebkitTapHighlightColor:"transparent",WebkitUserSelect:"none"},eE={1:"col-span-1",2:"col-span-2",4:"col-span-4"},eA="flex h-11 min-w-[44px] shrink-0 items-center justify-center px-2 text-xs font-medium touch-manipulation select-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring aria-disabled:opacity-40",eM={normal:"border-border bg-surface text-foreground",pressed:"border-accent-500 bg-accent-500/30 text-foreground",oneShot:"border-accent-500 bg-accent-500/20 text-accent-600 dark:text-accent-400",locked:"border-accent-600 bg-accent-600 text-white underline underline-offset-2"};function eR(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:l,onClose:i}=e,c=(0,o.c)("worktree"),d=(0,s.useId)(),{sendAndWait:u,isSending:m}=ep(t,n,a,l),[x,f]=(0,s.useState)([]),h=(0,s.useRef)([]),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useRef)(!1),[y,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)("alpha"),[N,C]=(0,s.useState)(!1),[S,I]=(0,s.useState)(null),T=(0,s.useRef)(null),E=(0,s.useRef)(!0),A=(0,s.useRef)(null);(0,s.useEffect)(()=>{E.current=!0;let e=document.activeElement;return e instanceof HTMLElement&&e.blur(),()=>{E.current=!1;let e=T.current;null!==e&&eI(e),T.current=null}},[]),(0,s.useEffect)(()=>{let e=e=>{let t=T.current;null!==t&&t.pointerId===e.pointerId&&(eI(t),T.current=null,I(null))};return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[]),(0,s.useEffect)(()=>{let e=A.current;e&&(e.scrollLeft=e.scrollWidth)},[x]);let M=eC(x),R=function(e){let t=[];for(let n of e){let e=t[t.length-1];if("key"===n.type&&(null==e?void 0:e.event.type)==="key"&&e.event.key===n.key){t[t.length-1]={...e,count:e.count+1};continue}t.push({label:"key"===n.type?function(e){let t=ew[e];return void 0!==t?t:"^".concat(e.slice(2).toUpperCase())}(n.key):n.text,count:1,event:n})}return t}(x),L=x.length,P=()=>({sending:v.current,staged:h.current,modifier:b.current}),D={sending:m,staged:x,modifier:p};function F(e){h.current=e,f(e),C(!1)}function O(e){b.current=e,g(e),null!==e&&(j(!0),k("alpha"))}function z(e){var t;if(v.current)return!1;let n=eN(e,b.current);if(null===n)return!1;let a=function(e,t){if(eC(e))return null;let n=e[e.length-1];return"text"===t.type&&(null==n?void 0:n.type)==="text"&&n.text.length+t.text.length<=4096?[...e.slice(0,-1),{type:"text",text:n.text+t.text}]:[...e,t]}(h.current,n);if(null===a)return!1;F(a);let r=null===(t=b.current)||t.locked?t:null;return r!==b.current&&O(r),!0}function _(e,t){if(eS(e,P()))switch(e.kind){case"press":z(t&&e.swipe?e.swipe:e.press);return;case"modifier":var n,a;O((n=b.current,a=e.modifier,(null==n?void 0:n.modifier)===a?null:{modifier:a,locked:!1}));return;case"page":k(e.target);return}}function B(e){eI(e),T.current=null,I(null)}function V(e){let{keyId:t,testId:n,action:a,label:s,ariaLabel:l,spanClass:i,faceClass:o="",hint:c}=e,d=eS(a,D),u="modifier"===a.kind&&(null==p?void 0:p.modifier)===a.modifier?p.locked?"locked":"oneShot":S===t?"pressed":"normal";return(0,r.jsxs)("button",{type:"button","data-testid":n,"aria-label":l,"aria-disabled":!d||void 0,"aria-pressed":"modifier"===a.kind?(null==p?void 0:p.modifier)===a.modifier:void 0,"data-modifier-state":"modifier"===a.kind?(null==p?void 0:p.modifier)===a.modifier?p.locked?"locked":"one-shot":"off":void 0,className:"".concat("relative flex h-11 min-w-0 items-stretch p-0.5 touch-none select-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"," ").concat(i),...{onPointerDown(e){if(e.preventDefault(),0!==e.button||null!==T.current||!eS(a,P()))return;let n=e.currentTarget;try{var r;null==(r=n.setPointerCapture)||r.call(n,e.pointerId)}catch(e){}let s=n.getBoundingClientRect(),l={pointerId:e.pointerId,action:a,start:{x:e.clientX,y:e.clientY},rect:{left:s.left,top:s.top,right:s.right,bottom:s.bottom},longPressed:!1,timer:null,interval:null};T.current=l,I(t);try{"undefined"!=typeof navigator&&"function"==typeof navigator.vibrate&&navigator.vibrate(10)}catch(e){}"modifier"===a.kind?l.timer=setTimeout(()=>{l.timer=null,l.longPressed=!0,O({modifier:a.modifier,locked:!0})},450):"press"===a.kind&&a.repeats&&(l.timer=setTimeout(()=>{l.timer=null,l.longPressed=!0,z(a.press)&&(l.interval=setInterval(()=>{z(a.press)||eI(l)},80))},450))},onPointerUp(e){var t,n,a;let r=T.current;if(null===r||r.pointerId!==e.pointerId||(B(r),r.longPressed))return;let s="press"===r.action.kind&&void 0!==r.action.swipe,l=(t=r.start,n={x:e.clientX,y:e.clientY},a=r.rect,s&&t.y-n.y>=24?"swipe":n.x>=a.left&&n.x<=a.right&&n.y>=a.top&&n.y<=a.bottom?"tap":"none");"none"!==l&&_(r.action,"swipe"===l)},onPointerCancel(e){let t=T.current;null!==t&&t.pointerId===e.pointerId&&B(t)},onClick(e){0===e.detail&&_(a,!1)}},children:[(0,r.jsxs)("span",{"aria-hidden":void 0!==l||void 0,className:"relative flex flex-1 items-center justify-center rounded-md border ".concat(eM[u]," ").concat(d?"":"opacity-40"," ").concat(o),children:[s,c?(0,r.jsx)("span",{"aria-hidden":"true",className:"absolute right-1 top-0.5 text-[9px] leading-none text-muted-foreground",children:c}):null]}),S===t?(0,r.jsx)("span",{"aria-hidden":"true","data-testid":"direct-key-bubble",className:"pointer-events-none absolute bottom-full left-1/2 z-40 mb-1 -translate-x-1/2 whitespace-nowrap rounded-md border border-border bg-surface px-3 py-1.5 font-mono text-xl text-foreground shadow-lg",children:s}):null]},t)}function U(e){var t;let n=c("directInputKeyboard.keys.".concat(e.id));return"modifier"===e.kind?V({keyId:e.id,testId:"direct-key-".concat(e.id),action:{kind:"modifier",modifier:e.id},label:e.label,ariaLabel:n,spanClass:"col-span-1",faceClass:"text-xs font-semibold"}):V({keyId:e.id,testId:"direct-key-".concat(e.id),action:{kind:"press",press:{type:"named",key:e.key},swipe:e.swipeUp?{type:"named",key:e.swipeUp.key}:void 0,repeats:e.repeats},label:e.label,ariaLabel:n,spanClass:"col-span-1",faceClass:"text-xs font-semibold",hint:null==(t=e.swipeUp)?void 0:t.label})}let H=(null==p?void 0:p.modifier)==="shift";function K(e){var t,n;let a=null!=(t=eE[e.span])?t:"col-span-1";if("page"===e.kind)return V({keyId:"page-".concat(e.target),testId:"direct-key-page",action:{kind:"page",target:e.target},label:e.label,ariaLabel:c("symbol"===e.target?"directInputKeyboard.keys.toSymbols":"directInputKeyboard.keys.toAlpha"),spanClass:a,faceClass:"text-xs font-semibold"});let r=" "===e.char,s=r?"␣":H&&/^[a-z]$/.test(e.char)?e.char.toUpperCase():e.char;return V({keyId:"char-".concat(e.char),testId:(n=e.char,"direct-key-char-".concat(n.codePointAt(0))),action:{kind:"press",press:{type:"char",char:e.char},repeats:!1},label:s,ariaLabel:r?c("directInputKeyboard.keys.space"):void 0,spanClass:a,faceClass:"font-mono text-sm"})}async function W(){if(v.current||N||0===h.current.length)return;v.current=!0;let e=T.current;null!==e&&B(e);let t=await u(h.current);v.current=!1,E.current&&(t?(h.current=[],f([])):C(!0))}let q=!m&&L>0;return(0,r.jsxs)("div",{role:"group","aria-label":c("directInputKeyboard.groupLabel"),"data-testid":"mobile-direct-input-keyboard","data-modifier":null===p?"none":"".concat(p.modifier).concat(p.locked?"-locked":""),className:"select-none bg-surface-2 text-foreground",style:eT,children:[(0,r.jsx)("div",{role:"status",children:M?(0,r.jsx)("p",{"data-testid":"direct-input-full",className:"bg-warning-subtle px-3 py-1.5 text-xs text-warning-foreground",children:c("directInputKeyboard.full",{max:32})}):null}),(0,r.jsx)("div",{role:"alert",children:N?(0,r.jsxs)("div",{"data-testid":"direct-input-failed",className:"flex items-center gap-2 bg-danger-subtle pl-3 text-xs text-danger-foreground",children:[(0,r.jsx)("p",{className:"flex-1 py-1.5",children:c("directInputKeyboard.sendFailed")}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-failed-ok",onClick:()=>C(!1),className:"".concat(eA," text-danger-foreground"),children:c("directInputKeyboard.acknowledge")})]}):null}),(0,r.jsxs)("div",{role:"group","aria-label":c("directInputKeyboard.confirmRowLabel"),"aria-busy":!!m||void 0,"data-testid":"direct-input-confirm-row",className:"flex h-11 items-stretch bg-surface",children:[(0,r.jsx)("button",{type:"button","data-testid":"direct-input-toggle-chars","aria-expanded":y,"aria-controls":y?d:void 0,"aria-label":c(y?"directInputKeyboard.hideChars":"directInputKeyboard.showChars"),onClick:()=>j(e=>!e),className:"".concat(eA," ").concat(y?"text-accent-600 dark:text-accent-400":"text-muted-foreground"),children:"ABC"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center",children:[(0,r.jsx)("ul",{ref:A,"aria-label":c("directInputKeyboard.stagedLabel"),"data-testid":"direct-input-chips",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 scrollbar-hide",children:R.map((e,t)=>{let n="text"===e.event.type?e.label.replace(/ /g,"␣"):e.label,a=e.count>1?"".concat(n,"\xd7").concat(e.count):n;return(0,r.jsx)("li",{"data-testid":"direct-input-chip","aria-label":e.count>1?c("directInputKeyboard.chipRepeat",{key:n,count:e.count}):void 0,className:"shrink-0 whitespace-nowrap rounded border border-border bg-surface-2 px-1.5 py-0.5 font-mono text-xs text-foreground",children:a},t)})}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-clear","aria-label":c("directInputKeyboard.clearAll"),"aria-disabled":!q||void 0,onClick:function(){v.current||0===h.current.length||F([])},className:"".concat(eA," text-muted-foreground"),children:(0,r.jsx)(eu.A,{size:16,"aria-hidden":"true"})})]}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-undo","aria-label":c("directInputKeyboard.undoAria"),"aria-disabled":!q||void 0,onClick:function(){v.current||0===h.current.length||F(function(e){let t=e[e.length-1];if(void 0===t)return[];let n=e.slice(0,-1);if("text"===t.type){let e=[...t.text];if(e.length>1)return[...n,{type:"text",text:e.slice(0,-1).join("")}]}return n}(h.current))},className:"".concat(eA," text-foreground"),children:c("directInputKeyboard.undo")}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-send","aria-label":c("directInputKeyboard.sendAria",{count:L}),"aria-disabled":!(q&&!N)||void 0,onClick:()=>void W(),className:"".concat(eA," bg-accent-600 text-white"),children:c("directInputKeyboard.send",{count:L})}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-close","aria-label":c("directInputKeyboard.closeAria"),onClick:i,className:"".concat(eA," text-muted-foreground"),children:c("directInputKeyboard.close")}),(0,r.jsx)("span",{className:"sr-only","aria-live":"polite","data-testid":"direct-input-count",children:c("directInputKeyboard.stagedCount",{count:L})})]}),(0,r.jsx)("div",{role:"group","aria-label":c("directInputKeyboard.specialKeysLabel"),"data-testid":"direct-input-special-keys",children:eb.map((e,t)=>(0,r.jsx)("div",{className:"grid grid-cols-7",children:e.map(U)},t))}),y?(0,r.jsx)("div",{id:d,role:"group","aria-label":c("directInputKeyboard.charKeysLabel"),"data-testid":"direct-input-char-panel","data-page":w,children:ej[w].map((e,t)=>(0,r.jsx)("div",{className:"grid grid-cols-10",children:e.map(K)},"".concat(w,"-").concat(t)))}):null]})}var eL=n(73333),eP=n(60734),eD=n(31166),eF=n(36402),eO=n(17846),ez=n(69264),e_=n(27307),eB=n(24027),eV=n(5917),eU=n(75426),eH=n(51963),eK=n(39867);let eW="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 eq(e){let{open:t,onClose:n,onSearch:a,onCopyContent:l,onCopyPath:i,downloadUrl:c,downloadName:d,contentCopied:u,pathCopied:m}=e,x=(0,o.c)("worktree"),f=(0,s.useId)(),h=(0,M.r)({active:t}),p=(0,s.useCallback)(()=>{a(),n()},[a,n]),g=(0,s.useCallback)(()=>{l(),n()},[l,n]),b=(0,s.useCallback)(()=>{i(),n()},[i,n]);return((0,s.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:h,"data-testid":"mobile-file-actions-sheet",role:"dialog","aria-modal":"true","aria-labelledby":f,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:f,className:"px-4 pb-2 text-sm font-medium text-muted-foreground",children:x("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:eW,children:[(0,r.jsx)(H.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.searchInFile")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-content",onClick:g,className:eW,children:[u?(0,r.jsx)(eV.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(eU.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFileContent")]}),(0,r.jsxs)("button",{type:"button","data-testid":"file-actions-sheet-copy-path",onClick:b,className:eW,children:[m?(0,r.jsx)(eV.A,{size:18,"aria-hidden":"true",className:"text-success"}):(0,r.jsx)(eH.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.copyFilePath")]}),(0,r.jsxs)("a",{"data-testid":"download-file-button",href:c,download:d,onClick:n,className:eW,"aria-label":x("actions.downloadFile"),children:[(0,r.jsx)(eK.A,{size:18,"aria-hidden":"true",className:"text-muted-foreground"}),x("actions.downloadFile")]})]})]})]}):null}var e$=n(11063);let eG=[{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"]}],eJ=eG.map(e=>e.extension),eY=[".md",".html",".htm",".yaml",".yml",".txt"];function eQ(e){if(!e)return!1;let t=e.toLowerCase();return eY.includes(t)}e$.j6,e$.j6;var eX=n(60322),eZ=n(99708),e0=n(57828),e1=n(18514),e2=n(59854),e4=n(76246),e5=n(56639),e3=n(78660);function e6(e){let[t,n]=(0,s.useState)(!1),[a,r]=(0,s.useState)(""),[l,i]=(0,s.useState)(""),[o,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(0),m=(0,s.useRef)(null),x=(0,s.useRef)(null),f=(0,s.useCallback)(()=>{n(!0),setTimeout(()=>{var e;return null==(e=m.current)?void 0:e.focus()},50)},[]),h=(0,s.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),p=(0,s.useCallback)(()=>{n(!1),r(""),i(""),c([]),u(0),h()},[h]);(0,s.useEffect)(()=>{if(!a||a.length<e3.E2){i(""),h();return}return h(),x.current=setTimeout(()=>{i(a)},e3.e1),h},[a,h]),(0,s.useEffect)(()=>{if(!l||l.length<e3.E2||!e){c([]),u(0);return}let t=e.split("\n"),n=l.toLowerCase(),a=[];t.forEach((e,t)=>{e.toLowerCase().includes(n)&&a.push(t+1)}),c(a),u(0)},[l,e]);let g=(0,s.useCallback)(()=>{0!==o.length&&u(e=>(e+1)%o.length)},[o.length]),b=(0,s.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:f,closeSearch:p,nextMatch:g,prevMatch:b,setSearchQuery:r}}var e9=n(4138),e8=n(90487);function e7(){let e=(0,o.c)("worktree");return(0,r.jsxs)("div",{className:"flex h-full items-center justify-center bg-surface text-muted-foreground",children:[(0,r.jsx)(u.y$,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}n(1226);let te=(0,i.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(e7,{})}),tt="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",tn=/^---\s*\nmarp:\s*true/;function ta(e){let{searchInputRef:t,searchQuery:n,searchMatches:a,searchCurrentIdx:s,onQueryChange:l,onPrev:i,onNext:c,onClose:d}=e,u=(0,o.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.nativeEvent.isComposing||(e.shiftKey?i():c())},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:c,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)(eu.A,{className:"w-4 h-4"})})]})}let tr="\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 ts(e){let{worktreeId:t,htmlContent:n,filePath:a}=e,[l,i]=(0,s.useState)("preview"),[c,d]=(0,s.useState)("safe"),u=(0,s.useRef)(new Set),m=(0,o.c)("worktree"),x=(0,eF.SC)(),f=(0,s.useCallback)(async e=>{if("interactive"===e&&!u.current.has(a)){if(!await x({description:m("htmlPreview.interactiveModeConfirm")}))return;u.current.add(a)}d(e)},[a,x,m]),h=(0,e5.iA)(t,a,n),p=(0,s.useMemo)(()=>"interactive"!==c?h:h.includes("</body>")?h.replace("</body>","".concat(tr,"</body>")):h+tr,[h,c]);(0,s.useEffect)(()=>{if("interactive"!==c)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)},[c]);let g=(0,s.useMemo)(()=>{try{return e8.A.highlight(n,{language:"html",ignoreIllegals:!0}).value}catch(e){return e8.A.highlightAuto(n).value}},[n]),b=(0,s.useMemo)(()=>Array.from({length:n.split("\n").length},(e,t)=>t+1),[n]),v=(0,s.useMemo)(()=>g.split("\n"),[g]);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:()=>i(e),className:"px-3 py-1 text-xs font-medium rounded-md transition-colors ".concat(l===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?m("fileViewer.tabSource"):m("fileViewer.tabPreview")},e))}),(0,r.jsx)("div",{className:"flex gap-1",children:["safe","interactive"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>f(e),className:"px-2 py-1 text-xs font-medium rounded-md transition-colors ".concat(c===e?"safe"===e?"bg-success-subtle text-success-foreground":"bg-warning-subtle text-warning-foreground":"text-muted-foreground hover:bg-muted"),children:"safe"===e?m("fileViewer.sandboxSafe"):m("fileViewer.sandboxInteractive")},e))})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto min-h-0",children:"source"===l?(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:b.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=v[n])?t:""}})})})]},e)})})}):(0,r.jsx)("iframe",{srcDoc:p,sandbox:e$.Ko[c],title:m("htmlPreview.title",{path:a}),className:"w-full h-full border-0 bg-white"},"".concat(a,"-").concat(c))})]})}function tl(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}let ti=(0,s.memo)(function(e){var t;let{isOpen:n,onClose:a,worktreeId:l,filePath:i,onFileSaved:d,onOpenFile:m}=e,[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),{copied:v,markCopied:y,reset:j}=(0,e9.q)(),{copied:w,markCopied:k}=(0,e9.q)(),[N,C]=(0,s.useState)(null),[S,I]=(0,s.useState)(0),[T,E]=(0,s.useState)(!1),[A,M]=(0,s.useState)("viewer"),[R,L]=(0,s.useState)(!1),[P,D]=(0,s.useState)(null),[F,O]=(0,s.useState)(!1),z=(0,s.useRef)(null),_=(0,o.c)("worktree"),B=(0,eF.SC)(),V=x?null!=P?P:x.content:void 0,{searchOpen:U,searchQuery:K,searchMatches:W,searchCurrentIdx:q,searchInputRef:$,openSearch:G,closeSearch:Q,nextMatch:X,prevMatch:Z,setSearchQuery:ee}=e6(V),et=(0,s.useMemo)(()=>!!((null==x?void 0:x.content)&&!x.isImage&&!x.isVideo&&!x.isPdf),[x]),en=null!=(t=null==x?void 0:x.extension.toLowerCase())?t:"",ea="md"===en,er=!!(x&&!x.readOnly&&!x.isHtml&&eQ(".".concat(en))),es=ea?A:U?"viewer":"editor",el=(0,s.useCallback)(async()=>{if(et&&V)try{await (0,eX.l)(V),y()}catch(e){}},[et,V,y]),ei=(0,s.useCallback)(async()=>{try{await (0,eX.l)(i),k()}catch(e){}},[i,k]),eo=(0,s.useCallback)(()=>{E(e=>!e)},[]);(0,s.useEffect)(()=>{if(0===W.length||!z.current)return;let e=W[q],t=z.current.querySelector('[data-line="'.concat(e,'"]'));t&&"function"==typeof t.scrollIntoView&&t.scrollIntoView({block:"center",behavior:"smooth"})},[q,W]),(0,s.useEffect)(()=>{if(!T||er)return;let e=e=>{"Escape"===e.key&&E(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T,er]),(0,s.useEffect)(()=>{if(!n||!i){f(null),b(null),j(),M("viewer"),L(!1),D(null),O(!1),Q();return}M("viewer"),L(!1),D(null),O(!1),(async()=>{p(!0),b(null);try{let t=await fetch("/api/worktrees/".concat(l,"/files/").concat((0,e4.o)(i)));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)||_("fileViewer.loadError");throw Error(a)}let n=await t.json();f(n)}catch(e){b(e instanceof Error?e.message:_("fileViewer.loadError"))}finally{p(!1)}})()},[n,l,i]),(0,s.useEffect)(()=>{C(null),I(0),x&&"md"===x.extension&&tn.test(x.content)&&!(x.content.length>1e6)&&(async()=>{try{let e=await fetch("/api/worktrees/".concat(l,"/marp-render"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdownContent:x.content})});if(e.ok){let t=await e.json();C(t.slides)}}catch(e){}})()},[x,l]);let ec=!!(N&&N.length>0),ed=(0,s.useCallback)(e=>{D(e)},[]),em=(0,s.useCallback)((e,t)=>{f(e=>e?{...e,content:t}:e),D(t),null==d||d(e)},[d]),ex=(0,s.useCallback)(async()=>{(!F||await B({description:_("editor.unsavedCloseConfirm"),variant:"danger"}))&&a()},[F,B,_,a]);(0,s.useEffect)(()=>{if(!er||R)return;let e=e=>{"Escape"===e.key&&(U?Q():T?E(!1):ex())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[er,R,U,T,ex]);let[ef,eh]=(0,s.useState)("");(0,s.useEffect)(()=>{ea&&"viewer"===es&&void 0!==V&&eh(V)},[ea,es,V]),(0,s.useEffect)(()=>{if(!er||!n)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[er,n]);let ep=(0,s.useMemo)(()=>{if(!x||void 0===V||x.isImage||x.isVideo||x.isHtml||x.isPdf)return null;let e=Array.from({length:V.split("\n").length},(e,t)=>t+1);try{return{lineNumbers:e,highlightedHtml:e8.A.highlight(V,{language:x.extension,ignoreIllegals:!0}).value}}catch(t){return{lineNumbers:e,highlightedHtml:e8.A.highlightAuto(V).value}}},[x,V]),eg=()=>x?x.isImage?(0,r.jsx)(eO.a,{src:x.content,alt:x.path,mimeType:x.mimeType}):x.isVideo?(0,r.jsx)(ez.u,{src:x.content,mimeType:x.mimeType}):x.isPdf?(0,r.jsx)("div",{className:"h-full min-h-[40vh]",children:(0,r.jsx)(e_.PdfPreview,{dataUri:x.content,filePath:i,variant:"download"})}):x.isHtml?(0,r.jsx)(ts,{worktreeId:l,htmlContent:x.content,filePath:i}):eb():null,eb=()=>{if(!ep)return null;let e=new Set(W),t=W.length>0?W[q]:-1,n=ep.highlightedHtml.split("\n");return(0,r.jsx)("div",{ref:z,children:(0,r.jsx)("table",{className:"text-sm w-full border-collapse",children:(0,r.jsx)("tbody",{children:ep.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)})})})})},ev="/api/worktrees/".concat(l,"/files/").concat((0,e4.o)(i),"?download=1"),ey=i?i.split("/").pop()||i:"",ej=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.jsxs)("a",{"data-testid":"download-file-button",href:ev,download:ey,className:e,"aria-label":_("actions.downloadFile"),title:_("actions.download"),children:[(0,r.jsx)(eK.A,{className:"w-3.5 h-3.5"}),t&&(0,r.jsx)("span",{children:_("actions.download")})]})},ew=()=>(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:ei,className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.copyFilePath"),title:_("actions.copyPath"),children:w?(0,r.jsx)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eH.A,{className:"w-3.5 h-3.5"})}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:i})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[et&&(0,r.jsx)("button",{onClick:G,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.searchInFile"),title:_("actions.search"),children:(0,r.jsx)(H.A,{className:"w-3.5 h-3.5"})}),et&&(0,r.jsx)("button",{"data-testid":"copy-content-button",onClick:el,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":_("actions.copyFileContent"),title:_("actions.copyContent"),children:v?(0,r.jsx)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eU.A,{className:"w-3.5 h-3.5"})}),ej("p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"),(0,r.jsx)("button",{onClick:eo,className:"p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground","aria-label":T?_("actions.exitFullscreen"):_("actions.fullscreen"),title:T?_("actions.exitFullscreen"):_("actions.fullscreen"),children:T?(0,r.jsx)(J.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(Y.A,{className:"w-3.5 h-3.5"})})]})]}),ek=()=>(null==x?void 0:x.readOnly)&&x.readOnlyReason?(0,r.jsx)(tl,{reason:x.readOnlyReason}):null,eN=()=>(0,r.jsx)(ta,{searchInputRef:$,searchQuery:K,searchMatches:W,searchCurrentIdx:q,onQueryChange:ee,onPrev:Z,onNext:X,onClose:Q});if(er&&x&&!h&&!g){let e=e=>"flex min-h-[44px] items-center justify-center gap-1 rounded-md px-2 text-xs font-medium touch-manipulation transition-colors ".concat(e?"bg-surface shadow-sm text-accent-600 dark:text-accent-400":"text-muted-foreground hover:text-foreground");return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-testid":"markdown-file-screen",role:"dialog","aria-modal":"true","aria-label":i,className:"fixed inset-0 flex h-[100dvh] flex-col bg-surface",style:{zIndex:e2.M.MAXIMIZED_EDITOR},children:[T?(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:eo,"aria-pressed":!0,"aria-label":_("actions.exitFullscreen"),className:tt,children:(0,r.jsx)(J.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ex(),"aria-label":_("actions.close"),className:tt,children:(0,r.jsx)(eu.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:i}),ea&&(0,r.jsxs)("div",{"data-testid":"markdown-file-mode-switch",role:"group","aria-label":_("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"===A,onClick:()=>M("viewer"),className:e("viewer"===A),children:[(0,r.jsx)(e0.A,{className:"h-4 w-4"}),_("fileViewer.modeViewer")]}),(0,r.jsxs)("button",{type:"button","data-testid":"markdown-file-mode-editor","aria-pressed":"editor"===A,onClick:()=>M("editor"),className:e("editor"===A),children:[(0,r.jsx)(e1.A,{className:"h-4 w-4"}),_("fileViewer.modeEditor")]})]}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-actions-trigger",onClick:()=>L(!0),"aria-label":_("fileViewer.moreActions"),className:tt,children:(0,r.jsx)(c.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-maximize",onClick:eo,"aria-pressed":!1,"aria-label":_("actions.fullscreen"),className:tt,children:(0,r.jsx)(Y.A,{className:"h-5 w-5"})}),(0,r.jsx)("button",{type:"button","data-testid":"markdown-file-close",onClick:()=>void ex(),"aria-label":_("actions.close"),className:tt,children:(0,r.jsx)(eu.A,{className:"h-5 w-5"})})]}),U&&(0,r.jsx)("div",{className:"flex-shrink-0",children:eN()}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)("div",{className:"viewer"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:U?(0,r.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:eb()}):ec?N?(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:()=>I(e=>Math.max(0,e-1)),disabled:0===S,className:"min-h-[44px] px-3 text-sm rounded-md bg-muted disabled:opacity-50 hover:bg-muted/80 transition-colors touch-manipulation",children:_("actions.prev")}),(0,r.jsxs)("span",{className:"text-sm text-muted-foreground",children:[S+1," / ",N.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>I(e=>Math.min(N.length-1,e+1)),disabled:S===N.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:_("actions.next")})]}),(0,r.jsx)("iframe",{srcDoc:N[S],sandbox:"",title:_("fileViewer.slideTitle",{name:i,number:S+1}),className:"w-full flex-1 border-0"})]}):null:ea?(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)(eB.G8,{content:ef,currentFilePath:i,worktreeId:l,onOpenFile:m})}):null}),(0,r.jsx)("div",{"data-testid":"markdown-file-editor",className:"editor"===es?"flex min-h-0 flex-1 flex-col":"hidden",children:(0,r.jsx)(te,{worktreeId:l,filePath:i,initialContent:x.content,embedded:!0,onSave:em,onDirtyChange:O,onContentChange:ed,onOpenFile:m},i)})]}),(0,r.jsx)(eq,{open:R,onClose:()=>L(!1),onSearch:()=>{M("viewer"),G()},onCopyContent:el,onCopyPath:ei,downloadUrl:ev,downloadName:ey,contentCopied:v,pathCopied:w})]})})}return T&&x&&!h&&!g?(0,r.jsxs)("div",{className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:e2.M.MAXIMIZED_EDITOR},children:[ew(),ek(),U&&eN(),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:eg()})]}):(0,r.jsx)(u.Jh,{isOpen:n,onClose:a,title:i,size:"xl",children:(0,r.jsxs)("div",{className:"max-h-[60vh] sm:max-h-[70vh] flex flex-col",children:[h&&(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:_("fileViewer.loading")})]}),g&&(0,r.jsxs)("div",{className:"bg-danger-subtle border border-danger-border rounded-lg p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-danger-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-sm text-danger-foreground",children:g})]}),(0,r.jsx)("div",{className:"mt-3",children:ej("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)})]}),x&&!h&&!g&&(0,r.jsxs)("div",{className:"bg-muted rounded-lg overflow-hidden flex flex-col min-h-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex-shrink-0",children:[ew(),ek(),U&&eN()]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:eg()})]})]})})});var to=n(36809),tc=n(46892),td=n(50857),tu=n(94442),tm=n(80344);function tx(e){let{worktreeId:t}=e,[n,a]=(0,s.useState)([]),[l,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[m,x]=(0,s.useState)(!0),[f,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(0),[j,w]=(0,s.useState)("all"),[k,N]=(0,s.useState)(!1),{showToast:C}=(0,tu.dj)(),S=(0,o.c)("worktree");(0,s.useEffect)(()=>{(async()=>{try{x(!0),p(null);let e=await tm.y.getLogs(t);a(e)}catch(e){p((0,tm.hS)(e))}finally{x(!1)}})()},[t]);let I=(0,s.useMemo)(()=>"all"===j?n:n.filter(e=>e.toLowerCase().includes(j)),[n,j]),T=async e=>{try{x(!0),p(null);let n=await tm.y.getLogFile(t,e);d(n.content),i(e),b(""),y(0)}catch(e){p((0,tm.hS)(e))}finally{x(!1)}},E=(0,s.useCallback)(async()=>{if(l)try{N(!0);let e=await tm.y.getLogFile(t,l,{sanitize:!0});await (0,eX.l)(e.content),C(S("logViewer.copied"),"success")}catch(e){C(S("logViewer.exportError",{error:(0,tm.hS)(e)}),"error")}finally{N(!1)}},[t,l,C,S]),A=(0,s.useMemo)(()=>{let e;if(!g||!c)return[];let t=RegExp((0,h.Nt)(g),"gi"),n=[];for(;null!==(e=t.exec(c));)n.push({index:e.index,length:e[0].length});return n},[g,c]);(0,s.useEffect)(()=>{y(0)},[g]);let M=()=>{A.length>0&&y(e=>(e+1)%A.length)},R=()=>{A.length>0&&y(e=>(e-1+A.length)%A.length)},L=(0,s.useMemo)(()=>{if(!c||!g||0===A.length)return c;let e="",t=0;return A.forEach((n,a)=>{e+=(0,h.ZD)(c.substring(t,n.index));let r=c.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,h.ZD)(r),"</mark>"),t=n.index+n.length}),e+=(0,h.ZD)(c.substring(t))},[c,g,A,v]);return(0,s.useEffect)(()=>{A.length>0&&v>=0&&setTimeout(()=>{let e=document.querySelector('mark[data-match-index="'.concat(v,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)},[v,A.length]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(u.Zp,{padding:"md",children:[(0,r.jsx)(u.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)(u.ZB,{children:S("logViewer.title")}),(0,r.jsx)(u.Ex,{variant:"gray",children:I.length})]}),(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,r.jsx)(u.$n,{variant:"all"===j?"primary":"ghost",size:"sm",onClick:()=>w("all"),children:S("logViewer.all",{count:n.length})}),(0,r.jsx)(u.$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)(u.$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)(u.$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)(u.$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)(u.Wu,{children:[m&&0===n.length&&(0,r.jsx)("div",{className:"text-center py-4",children:(0,r.jsx)(u.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}),!m&&0===I.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})}),I.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:I.map(e=>(0,r.jsx)("button",{onClick:()=>T(e),className:"w-full text-left px-3 py-2 rounded text-sm font-mono transition-colors ".concat(l===e?"bg-accent-50 text-accent-700 border border-accent-200":"hover:bg-muted border border-transparent"),children:e},e))})]})]}),l&&(0,r.jsxs)(u.Zp,{padding:"md",children:[(0,r.jsx)(u.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)(u.ZB,{className:"font-mono text-base",children:l}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(u.$n,{variant:"ghost",size:"sm",onClick:E,disabled:!l||k,title:S("logViewer.copyTitle"),children:k?S("logViewer.exporting"):S("logViewer.export")}),(0,r.jsx)(u.$n,{variant:"ghost",size:"sm",onClick:()=>{i(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)(u.pd,{type:"text",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),e.shiftKey?R():M())},placeholder:S("logViewer.searchPlaceholder"),className:"w-full pr-20"}),A.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," / ",A.length]})]}),A.length>0&&(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(u.$n,{variant:"ghost",size:"sm",onClick:R,disabled:0===A.length,title:S("logViewer.prevMatch"),children:"↑"}),(0,r.jsx)(u.$n,{variant:"ghost",size:"sm",onClick:M,disabled:0===A.length,title:S("logViewer.nextMatch"),children:"↓"})]})]})]})}),(0,r.jsxs)(u.Wu,{children:[m&&(0,r.jsx)("div",{className:"text-center py-8",children:(0,r.jsx)(u.y$,{size:"xl",variant:"accent",className:"inline-block"})}),!m&&c&&(0,r.jsx)("div",{className:"bg-[#111827] text-[#f3f4f6] rounded p-4 overflow-x-auto max-h-[500px] scrollbar-thin",children:g&&A.length>0?(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",dangerouslySetInnerHTML:{__html:L||""}}):(0,r.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap",children:c})}),!m&&g&&0===A.length&&c&&(0,r.jsx)("div",{className:"text-center py-4 text-sm text-muted-foreground",children:S("logViewer.noMatches",{query:g})})]})]})]})}var tf=n(63470),th=n(79361);function tp(e){let{version:t,className:n}=e,a=(0,o.c)("worktree"),{checking:s}=(0,tf.Y)();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}),s&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"version-loading",children:"..."}),(0,r.jsx)(th.V,{})]})}let tg="https://github.com/Kewton/CommandMate",tb="".concat(tg,"/issues"),tv="".concat(tg,"/issues/new"),ty="".concat(tv,"?template=bug_report.md"),tj="".concat(tv,"?template=feature_request.md"),tw="".concat(tv,"?template=question.md");function tk(e){let{className:t}=e,n=(0,o.c)("worktree"),a=[{href:ty,label:n("feedback.bugReport")},{href:tj,label:n("feedback.featureRequest")},{href:tw,label:n("feedback.question")},{href:tb,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 tN=n(94465),tC=n(38606),tS=n(34681),tI=n(72137),tT=n(95707),tE=n(14006),tA=n(73190),tM=n(56827);function tR(e){return""!==(null!=e?e:"").trim()}function tL(e){let{worktreeId:t,cliToolId:n,instanceId:a,composerText:l,onActionSent:i}=e,c=(0,o.c)("worktree"),[d,u]=(0,s.useState)(!1),m=(0,tM.B)(t,n,a,i),x=(0,s.useCallback)(()=>{m(["Enter"])},[m]),f=(0,s.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(()=>{i&&setTimeout(i,em.LK)}).catch(e=>{console.error("Failed to clear composer:",e)}).finally(()=>{u(!1)})},[t,n,a,i]);if(!tR(l))return null;let h=l.length>300?"".concat(l.slice(0,300),"…"):l;return(0,r.jsxs)("div",{"data-testid":"unsent-composer-bar",role:"region","aria-label":c("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:c("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:h}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,r.jsx)("button",{type:"button",onClick:x,"aria-label":c("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:c("unsentComposer.run")}),(0,r.jsx)("button",{type:"button",onClick:f,disabled:d,"aria-label":c("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:c("unsentComposer.clear")})]})]})}var tP=n(51515),tD=n(813),tF=n(16342);let tO=/^([^\S\n]*)╹(▀{4,})/,tz=/^([^\S\n]*)[│┃]/;function t_(e,t){return"opencode"===e&&null!==function(e){let t=(0,tP.aJ)(e).split("\n"),n=-1,a=-1,r=-1;for(let e=0;e<t.length;e++){let s=tO.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=tz.exec(i);if(!e||e[1].length!==a)continue}let o=i.slice((0,tF.sh)(i,r)).trim();""!==o&&(s+=1,""===l&&(l=(0,tD.D)(o,200,"…[truncated]")))}return s<2?null:{id:"opencode_sidebar",matchedText:l,boxRight:r,rows:s}}(null!=t?t:"")}function tB(e){let{cliToolId:t,frame:n}=e,a=(0,o.c)("worktree");return(0,s.useMemo)(()=>t_(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}var tV=n(40240),tU=n(29260),tH=n(32771),tK=n(308),tW=n(80635),tq=n(52407);let t$=(0,s.createContext)({register:()=>{},insertToComposer:()=>{}}),tG=(0,s.createContext)(null);function tJ(e){var t;return null!=(t=e.instanceId)?t:e.cliToolId}function tY(e){let{onInsertToComposer:t,children:n}=e,[a,l]=(0,s.useState)(null),i=(0,s.useRef)(t);i.current=t;let o=(0,s.useCallback)(e=>{var t;null==(t=i.current)||t.call(i,e)},[]),c=(0,s.useMemo)(()=>({register:l,insertToComposer:o}),[o]);return(0,r.jsx)(t$.Provider,{value:c,children:(0,r.jsx)(tG.Provider,{value:a,children:n})})}function tQ(e){let t=(0,s.useContext)(tG);if(null!==t&&t.target.cliToolId===e.cliToolId&&tJ(t.target)===tJ(e))return t.send}var tX=n(9708),tZ=n(26788),t0=n(60199),t1=n(52703),t2=n(51021),t4=n(68394),t5=n(17683);let t3=[{mode:"terminal",labelKey:"surfaceMode.terminal",icon:v.A},{mode:"chat",labelKey:"surfaceMode.chat",icon:$.A}],t6="top-16",t9=[t2.Mx,"m"],t8="/model",t7=(0,s.memo)(function(e){let{modelLabel:t,usage:n,usageDetail:a,recentChange:s,note:l,onEditNote:i,onOpenPicker:c,onDismissChange:d}=e,u=(0,o.c)("worktree"),m=null!==s,x=u("agentModel.sessionRow",{model:null!=t?t:""}),f=l?(0,en.Uq)(new Date(l.updatedAt)):"",h=l?u("sessionNote.label",{note:l.text,time:f}):u("sessionNote.menuItem");return(0,r.jsxs)("div",{"data-testid":"mobile-session-row","data-model-changed":m?"true":"false",className:"relative z-20 flex h-7 shrink-0 items-center gap-2 border-b px-3 text-[11px] leading-none ".concat(m?"border-warning-border bg-warning-subtle text-warning-foreground":"border-border bg-surface-2 text-muted-foreground"),children:[t?(0,r.jsxs)("button",{type:"button",onClick:c,"aria-label":x,title:x,"data-testid":"mobile-session-model",className:"relative flex min-w-0 basis-0 grow items-center gap-1.5 truncate text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-[''] ".concat(l?"shrink-[4]":"shrink"),children:[(0,r.jsx)(tT.A,{size:12,"aria-hidden":"true",className:"shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:t})]}):null,l?(0,r.jsxs)("button",{type:"button",onClick:i,"aria-label":h,title:h,"data-testid":"mobile-session-note",className:"relative flex min-w-0 shrink basis-0 grow items-center gap-1 text-left touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:[(0,r.jsx)(K.A,{size:12,"aria-hidden":"true",className:"shrink-0 opacity-70"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:l.text}),(0,r.jsx)("span",{"data-testid":"mobile-session-note-time",className:"shrink-0 tabular-nums opacity-70",children:f})]}):null,n?(0,r.jsx)("span",{"data-testid":"mobile-session-usage",title:null!=a?a:u("agentSession.chipLabel",{usage:n}),className:"min-w-0 max-w-[10rem] shrink-0 truncate tabular-nums",children:n}):null,s?(0,r.jsx)("button",{type:"button",onClick:d,"aria-label":u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),title:u("agentModel.changedRecentlyDetail",{from:s.from,to:s.to}),"data-testid":"mobile-session-model-changed",className:"relative shrink-0 rounded-full border border-warning-border bg-warning/20 px-1.5 py-0.5 font-medium touch-manipulation before:absolute before:inset-x-0 before:-inset-y-2 before:content-['']",children:u("agentModel.changedRecently")}):null]})}),ne=(0,s.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,live:l,frame:i,onKeysSent:o,onSurfaceModeChange:c}=e,{messages:d,isLoading:u,refresh:m}=(0,tK.Md)({worktreeId:t,cliToolId:n,instanceId:a}),x=(0,s.useCallback)((e,n)=>tm.y.sendMessage(t,e,n),[t]),f=(0,tq.Fx)(),h=(0,s.useMemo)(()=>({offline:(0,tq.sV)(f.signals),reachable:(0,tq._X)(f.signals)}),[f.signals]),{messages:p,sendOptimistic:g,retry:b,discard:v}=(0,tW.v4)({worktreeId:t,serverMessages:d,sendFn:x,onSent:m,connectivity:h});!function(e){let{cliToolId:t,instanceId:n,send:a}=e,{register:r}=(0,s.useContext)(t$);(0,s.useEffect)(()=>(r({target:{cliToolId:t,instanceId:n},send:a}),()=>r(null)),[r,t,n,a])}({cliToolId:n,instanceId:a,send:g});let{worktreePath:y,openFile:j}=(0,tX.O)(),w=(0,s.useContext)(t$).insertToComposer,k=(0,s.useCallback)(e=>{let t=v(e);t&&w(t)},[v,w]);return(0,r.jsx)(tU.wY,{messages:p,worktreeId:t,worktreePath:y,cliToolId:n,instanceId:a,live:l,onSurfaceModeChange:c,frame:i,onKeysSent:o,compact:!0,history:{onFilePathClick:j,isLoading:u,onRetryPending:b,onDiscardPending:k,onInsertToMessage:w,hideCornerControls:!0,openSearchOnWindowEvent:!0,searchBarTopClassName:t6}})}),nt=(0,s.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:l,instanceId:i,disableAutoFollow:c,onSurfaceModeChange:d,directInputOpen:u=!1}=e,{terminal:m,prompt:x,agentSession:f,setAutoScroll:h,refresh:p}=(0,tH.NK)({worktreeId:a,cliToolId:l,instanceId:i}),{compactTuiLayoutPadding:g,preservePaintedPanelRows:b,mobileWrapMode:v}=(0,t4.EK)(l),y=(0,o.c)("worktree"),j=(0,to.Ym)(),k=null!=i?i:l,N=function(e,t){let n=(0,et.rC)(),a=null==n?void 0:n.worktrees;return(0,s.useMemo)(()=>{var n;let r=null==a?void 0:a.find(t=>t.id===e);return null!=(n=lv(null==r?void 0:r.sessionStatusByInstance)[t])?n:null},[a,e,t])}(a,k),C=(0,et.rC)(),S=lf(N,null,null==(t=f.session)?void 0:t.agent),I=lg(f.session,f.context,y,j),T=lb(f.session,f.context,y,j),{note:E,save:A}=el(a,k),[M,R]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=()=>R(!0);return window.addEventListener(es,e),()=>window.removeEventListener(es,e)},[]),(0,s.useEffect)(()=>{R(!1)},[a,k]);let L=(0,s.useCallback)(()=>R(!0),[]),P=(0,s.useCallback)(()=>R(!1),[]),D=(0,s.useCallback)(e=>{A(e),R(!1)},[A]),F=null!==S||null!==E,[O,z]=(0,s.useState)(null);(0,t0.T3)(e=>{e.type===t1.T4&&e.worktreeId===a&&e.instance===k&&(z({from:e.from,to:e.to,at:e.at}),null==C||C.refresh())}),(0,s.useEffect)(()=>{if(null===O)return;let e=O.at+3e5-Date.now();if(e<=0)return void z(null);let t=setTimeout(()=>z(null),e);return()=>clearTimeout(t)},[O]);let _=(0,s.useCallback)(()=>z(null),[]);(0,s.useEffect)(()=>{z(null)},[a,k]);let B=(0,tM.B)(a,l,i,p),V=tQ({cliToolId:l,instanceId:i}),U=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{null!==U.current&&clearTimeout(U.current)},[]);let H=(0,s.useCallback)(()=>{if("opencode"===l)return void B([...t9]);let e={cliToolId:l,instanceId:i};V?V(t8,e):tm.y.sendMessage(a,t8,e).catch(()=>{}),null!==U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{U.current=null,p()},em.LK)},[l,i,V,p,B,a]),K=(0,t5.NP)(a),[W,q]=(0,s.useState)(X.wf);(0,s.useEffect)(()=>{q((0,t5.TR)(K))},[K]);let $=(0,s.useCallback)(e=>{q(e),(0,t5.If)(K,e)},[K]),G=(0,s.useCallback)(e=>{u||$(e)},[u,$]),[J,Y]=(0,tZ.Af)(),Q=(0,s.useRef)(null),Z=(0,s.useRef)(m.autoScroll);Z.current=m.autoScroll,(0,s.useEffect)(()=>{let e=Q.current;if(!u||c||null===e)return;let t=()=>{if(!Z.current)return;let t=e.querySelector('[role="log"]');t&&(t.scrollTop=t.scrollHeight)};if(t(),"undefined"==typeof ResizeObserver)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u,c]),(0,s.useEffect)(()=>{null==d||d(W)},[d,W]);let ee=m.isUnclassifiedActive&&!x.visible&&"chat"!==W,en=tR(m.composerText),ea=t_(l,m.realtimeSnippet||m.output),er=(0,s.useMemo)(()=>({isRunning:m.isRunning,attaching:m.attaching,sessionStatus:m.sessionStatus,isThinking:m.isThinking,isPromptWaiting:x.visible,promptData:x.data,isSelectionListActive:m.isSelectionListActive,isPagerActive:m.isPagerActive,isDismissablePanelActive:m.isDismissablePanelActive,isUnclassifiedActive:m.isUnclassifiedActive}),[m.isRunning,m.attaching,m.sessionStatus,m.isThinking,m.isSelectionListActive,m.isPagerActive,m.isDismissablePanelActive,m.isUnclassifiedActive,x.visible,x.data]);return(0,r.jsxs)("div",{className:"relative flex flex-col h-full min-h-0",children:[(0,r.jsxs)("div",{role:"group","aria-label":y("surfaceMode.groupLabelMobile"),"data-testid":"mobile-surface-mode-toggle",className:"pointer-events-none absolute right-2 z-30 flex items-center gap-0.5 rounded-full border border-border bg-surface-2/95 p-0.5 shadow-lg backdrop-blur ".concat(F?"top-9":"top-2"),children:[t3.map(e=>{let{mode:t,labelKey:n,icon:a}=e,s=W===t,l=y(n);return(0,r.jsx)("button",{type:"button",onClick:()=>G(t),"aria-pressed":s,"aria-label":l,"aria-disabled":!!u||void 0,title:l,"data-testid":"mobile-surface-mode-".concat(t),className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(s?"bg-accent-500/20 text-accent-600 dark:text-accent-400":"text-muted-foreground"," ").concat(u?"opacity-40":""),children:(0,r.jsx)(a,{size:18,"aria-hidden":"true"})},t)}),"chat"===W?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"mx-0.5 h-6 w-px bg-border"}),(0,r.jsx)("button",{type:"button",onClick:Y,"aria-pressed":J,"aria-label":J?y("chatTranscript.toolActivity.hide"):y("chatTranscript.toolActivity.show"),title:J?y("chatTranscript.toolActivity.hide"):y("chatTranscript.toolActivity.show"),"data-testid":"mobile-chat-tool-activity-toggle",className:"pointer-events-auto flex min-h-[44px] min-w-[44px] items-center justify-center rounded-full transition-colors touch-manipulation ".concat(J?"bg-accent-500/15 text-accent-700 dark:text-accent-400":"text-muted-foreground"),children:(0,r.jsx)(w.A,{size:18,"aria-hidden":"true"})})]}):null]}),F?(0,r.jsx)(t7,{modelLabel:S,usage:I,usageDetail:T,recentChange:O,note:E,onEditNote:L,onOpenPicker:H,onDismissChange:_}):null,M?(0,r.jsxs)("div",{"data-testid":"mobile-session-note-editor",className:"absolute inset-x-2 z-40 rounded-md border border-border bg-surface p-2 shadow-lg ".concat(F?"top-9":"top-2"),children:[(0,r.jsx)(ei,{initialText:null!=(n=null==E?void 0:E.text)?n:"",onCommit:D,onCancel:P,ariaLabel:y("sessionNote.menuItem"),placeholder:y("sessionNote.placeholder"),testId:"mobile-session-note-input"}),(0,r.jsx)("p",{className:"mt-1 text-[10px] leading-tight text-muted-foreground",children:y("sessionNote.hint")})]}):null,(0,r.jsx)("div",{ref:Q,className:"flex-1 min-h-0 overflow-hidden","data-testid":"mobile-terminal-region",children:"chat"===W?(0,r.jsx)("div",{className:"h-full min-h-0","data-testid":"mobile-chat-surface",children:(0,r.jsx)(ne,{worktreeId:a,cliToolId:l,instanceId:i,live:er,frame:m.output,onKeysSent:p,onSurfaceModeChange:$})}):(0,r.jsx)(tE.D,{output:m.output,isActive:m.isRunning,isThinking:m.isThinking,autoScroll:m.autoScroll,onScrollChange:h,disableAutoFollow:c,compactTuiLayoutPadding:g,preservePaintedPanelRows:b,wrapMode:v,searchBarTopClassName:t6})}),en&&!u?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tL,{worktreeId:a,cliToolId:l,instanceId:i,composerText:m.composerText,onActionSent:p})}):null,ea?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1",children:(0,r.jsx)(tB,{cliToolId:l,frame:m.realtimeSnippet||m.output})}):null,m.isRunning&&!u?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1","data-testid":"mobile-quick-keys-slot",children:(0,r.jsx)(tV.XU,{worktreeId:a,cliToolId:l,instanceId:i,hasAgentSession:null!==f.session,onKeysSent:p,compact:!0,collapsible:!0,layout:"mobile"})}):null,ee&&!u?(0,r.jsx)("div",{className:"shrink-0 px-2 pt-1 pb-2",children:(0,r.jsx)(tA.U,{worktreeId:a,cliToolId:l,instanceId:i,onKeysSent:p})}):null]})});var nn=n(83051);let na={isOpen:!1,position:{x:0,y:0},targetPath:null,targetType:null};function nr(){let[e,t]=(0,s.useState)(na),n=(0,s.useCallback)((e,n,a)=>{t({isOpen:!0,position:e,targetPath:n,targetType:a})},[]),a=(0,s.useCallback)((e,t,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}n({x:r,y:s},t,a)},[n]),r=(0,s.useCallback)(()=>{t(e=>({...e,isOpen:!1}))},[]),l=(0,s.useCallback)(()=>{t(na)},[]);return(0,s.useEffect)(()=>{if(!e.isOpen)return;let t=()=>{r()},n=setTimeout(()=>{document.addEventListener("click",t)},0);return()=>{clearTimeout(n),document.removeEventListener("click",t)}},[e.isOpen,r]),(0,s.useEffect)(()=>{if(!e.isOpen)return;let t=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[e.isOpen,r]),{menuState:e,openMenu:a,openMenuAt:n,closeMenu:r,resetMenu:l}}var ns=n(47650),nl=n(7504),ni=n(22198),no=n(21786),nc=n(26754),nd=n(71360),nu=n(9286);function nm(e,t,n){let a=n-t-8;return a<8?8:Math.min(Math.max(e,8),a)}let nx=(0,s.memo)(function(e){let{isOpen:t,position:n,targetPath:a,targetType:l,onClose:i,onNewFile:c,onNewDirectory:d,onRename:u,onDelete:m,onUpload:x,onMove:f,items:h,ariaLabel:p}=e,g=(0,o.c)("worktree"),b=(0,s.useRef)(null),{shouldRender:v,isExiting:y}=(0,nu.O)(t,em.$B),j=h?h.map(e=>e.id).join(","):"builtin",w="".concat(n.x,":").concat(n.y,":").concat(l,":").concat(j),[k,N]=(0,s.useState)(null),C=(null==k?void 0:k.key)===w?k:null;(0,s.useLayoutEffect)(()=>{if(!t)return;let e=b.current;if(!e)return;let a=e.getBoundingClientRect();N({key:w,left:nm(n.x,a.width,window.innerWidth),top:nm(n.y,a.height,window.innerHeight)})},[t,w,n.x,n.y]);let S=(0,s.useCallback)(e=>{e&&a&&e(a),i()},[a,i]),I=[{id:"new-file",label:g("fileTree.newFile"),icon:(0,r.jsx)(nl.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(c),showFor:["directory"]},{id:"new-directory",label:g("fileTree.newDirectory"),icon:(0,r.jsx)(ni.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(d),showFor:["directory"]},{id:"upload",label:g("contextMenu.uploadFile"),icon:(0,r.jsx)(no.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(x),showFor:["directory"],showDividerAfter:!0},{id:"rename",label:g("contextMenu.rename"),icon:(0,r.jsx)(e1.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(u)},{id:"move",label:g("contextMenu.move"),icon:(0,r.jsx)(nc.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>{f&&a&&l&&f(a,l),i()},showDividerAfter:!0},{id:"delete",label:g("contextMenu.delete"),icon:(0,r.jsx)(nd.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onClick:()=>S(m),variant:"danger"}],T=h?h.map(e=>{var t,n;return{id:e.id,label:e.label,icon:null!=(t=e.icon)?t:null,onClick:()=>{e.onSelect(),i()},variant:e.variant,showDividerAfter:e.showDividerAfter,disabled:null!=(n=e.disabled)&&n}}):I.filter(e=>!e.showFor||l&&e.showFor.includes(l));if((0,s.useEffect)(()=>{if(!t)return;let e=e=>{if("Escape"===e.key)return void i();if("ArrowDown"===e.key||"ArrowUp"===e.key){var t;let n;e.preventDefault();let a=null==(t=b.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,i]),(0,s.useEffect)(()=>{if(t&&b.current){let e=b.current.querySelector('[role="menuitem"]');e&&e.focus()}},[t]),!v)return null;let E=(0,r.jsx)("div",{ref:b,"data-testid":"context-menu",role:"menu","aria-label":null!=p?p:g("contextMenu.label"),className:"fixed min-w-[160px] py-1 bg-surface rounded-lg shadow-lg border border-border ".concat(y?"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:e2.M.CONTEXT_MENU,left:"".concat(C?C.left:0,"px"),top:"".concat(C?C.top:0,"px")},children:T.map((e,t)=>{var n;let l=null!=(n=e.disabled)?n:!a;return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsxs)("button",{role:"menuitem","data-testid":"context-menu-".concat(e.id),onClick:e.onClick,disabled:l,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(l?"opacity-50 cursor-not-allowed":""),children:[e.icon,(0,r.jsx)("span",{children:e.label})]}),e.showDividerAfter&&t<T.length-1&&(0,r.jsx)("div",{"data-testid":"context-menu-divider",className:"my-1 border-t border-border"})]},e.id)})});return"undefined"==typeof document?E:(0,ns.createPortal)(E,document.body)});var nf=n(55813),nh=n(30061);let np="commandmate.worktree.fileMetadataDisplay",ng={showSize:!0,showCreated:!1,showModified:!1},nb="commandmate:fileMetadataDisplayChange";function nv(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 ny=(0,s.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"})})}),nj=(0,s.memo)(function(e){let{open:t}=e;return(0,r.jsx)("svg",{"data-testid":"folder-icon",className:"w-5 h-5 flex-shrink-0 text-warning",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:t?(0,r.jsx)("path",{d:"M19 20H5c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h6c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2zM5 6v12h14V8h-7l-2-2H5z"}):(0,r.jsx)("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}),nw=(0,s.memo)(function(e){let{text:t,query:n}=e;if(!n||!n.trim())return(0,r.jsx)(r.Fragment,{children:t});let a=(0,h.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))})}),nk=(0,s.memo)(function(e){let{extension:t}=e,n=(0,s.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 flex-shrink-0 ".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"})})}),nN=(0,s.memo)(function e(t){let{item:n,path:a,depth:l,worktreeId:i,expanded:c,cache:u,onToggle:m,onFileSelect:x,onLoadChildren:f,onContextMenu:h,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y=ng}=t,j=(0,o.c)("worktree"),[w,k]=(0,s.useState)(!1),N=a?"".concat(a,"/").concat(n.name):n.name,C=c.has(N),S="directory"===n.type,I=u.get(N),T=(0,s.useMemo)(()=>v?(0,nf.M)(v):void 0,[v]),E=(0,s.useMemo)(()=>{if(S)return;let e=[];if(void 0!==n.size&&e.push("".concat(j("fileTree.metadata.size"),": ").concat(nv(n.size))),n.birthtime){let t=(0,en.bg)(new Date(n.birthtime),T);t&&e.push("".concat(j("fileTree.metadata.created"),": ").concat(t))}if(n.mtime){let t=(0,en.bg)(new Date(n.mtime),T);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,T,j]),A=(0,s.useCallback)(async()=>{S?(C||I||(k(!0),await f(N),k(!1)),m(N)):null==x||x(N)},[S,C,I,N,f,m,x]),M=(0,s.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),A())},[A]),R=(0,s.useCallback)(e=>{e.preventDefault(),null==h||h(e,N,S?"directory":"file")},[N,S,h]),L=function(e){let{delay:t=500,moveThreshold:n=10,onLongPress:a}=e,r=(0,s.useRef)(null),l=(0,s.useRef)(null),i=(0,s.useRef)(null),o=(0,s.useCallback)(()=>{r.current&&(clearTimeout(r.current),r.current=null),l.current=null,i.current=null},[]);(0,s.useEffect)(()=>()=>o(),[o]);let c=(0,s.useCallback)(e=>{if(1!==e.touches.length)return;let n=e.touches[0];l.current={x:n.clientX,y:n.clientY},i.current=e,r.current=setTimeout(()=>{i.current&&a(i.current),o()},t)},[t,a,o]),d=(0,s.useCallback)(e=>{if(!l.current||1!==e.touches.length)return;let t=e.touches[0],a=t.clientX-l.current.x,r=t.clientY-l.current.y;Math.sqrt(a*a+r*r)>n&&o()},[n,o]);return{onTouchStart:c,onTouchMove:d,onTouchEnd:(0,s.useCallback)(()=>{o()},[o]),onTouchCancel:(0,s.useCallback)(()=>{o()},[o])}}({onLongPress:(0,s.useCallback)(e=>{null==h||h(e,N,S?"directory":"file")},[N,S,h])}),P={...function(e){let t=Math.min(e,20);return{"--tree-indent":"".concat(.5+ +t,"rem")}}(l),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:"@container flex items-center gap-2 py-1.5 pr-2 cursor-pointer hover:bg-muted rounded transition-colors pl-[min(var(--tree-indent),max(0.5rem,calc(100%_-_7rem)))]",style:P,onClick:A,onKeyDown:M,onContextMenu:R,onTouchStart:L.onTouchStart,onTouchMove:L.onTouchMove,onTouchEnd:L.onTouchEnd,onTouchCancel:L.onTouchCancel,children:[S?(0,r.jsx)("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w?(0,r.jsx)(d.y,{size:"xs",variant:"accent"}):(0,r.jsx)(ny,{expanded:C})}):(0,r.jsx)("span",{className:"w-4 h-4 flex-shrink-0"}),S?(0,r.jsx)(nj,{open:C}):(0,r.jsx)(nk,{extension:n.extension}),(0,r.jsx)(nh.nR,{content:n.name,metadata:E,className:"flex-1 truncate text-sm text-foreground @min-[176px]:min-w-16",children:"name"===g&&p?(0,r.jsx)(nw,{text:n.name,query:p}):n.name}),y.showSize&&(0,r.jsx)("span",{"data-testid":"tree-item-size",className:"hidden @min-[176px]:block truncate text-xs text-muted-foreground",children:S?void 0!==n.itemCount&&j("fileTree.itemCount",{count:n.itemCount}):nv(n.size)}),!S&&y.showCreated&&n.birthtime&&(0,r.jsx)("span",{"data-testid":"tree-item-created",className:"hidden @min-[296px]:block truncate text-xs text-muted-foreground",children:(0,en.fw)(n.birthtime,T)}),!S&&y.showModified&&n.mtime&&(0,r.jsx)("span",{"data-testid":"tree-item-modified",className:"hidden ".concat(y.showCreated?"@min-[416px]:block":"@min-[296px]:block"," truncate text-xs text-muted-foreground"),children:(0,en.fw)(n.mtime,T)})]}),S&&C&&I&&(0,r.jsx)("div",{role:"group",children:I.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:l+1,worktreeId:i,expanded:c,cache:u,onToggle:m,onFileSelect:x,onLoadChildren:f,onContextMenu:h,searchQuery:p,searchMode:g,matchedPaths:b,dateFnsLocaleStr:v,metadataDisplay:y},t.name))})]})});var nC=n(26989);let nS=[{key:"showSize",labelKey:"fileTree.metadata.showSize"},{key:"showCreated",labelKey:"fileTree.metadata.showCreated"},{key:"showModified",labelKey:"fileTree.metadata.showModified"}];function nI(e,t,n){if(t<=0||n<=0)return 0;let a=e+t+8-n;return a>0?-Math.min(a,Math.max(0,e-8)):e<8?8-e:0}let nT=(0,s.memo)(function(e){let{settings:t,onToggle:n}=e,a=(0,o.c)("worktree"),[l,i]=(0,s.useState)(!1),c=(0,s.useRef)(null),d=(0,s.useRef)(null),m=(0,s.useRef)({x:0,y:0}),[x,f]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(!l)return;let e=e=>{c.current&&!c.current.contains(e.target)&&i(!1)},t=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,s.useLayoutEffect)(()=>{let e=e=>{m.current=e,f(t=>t.x===e.x&&t.y===e.y?t:e)};if(!l)return void e({x:0,y:0});let t=d.current;if(!t)return;let n=t.getBoundingClientRect();e({x:nI(n.left-m.current.x,n.width,window.innerWidth),y:nI(n.top-m.current.y,n.height,window.innerHeight)})},[l]);let h=(0,s.useCallback)(e=>{n(e)},[n]);return(0,r.jsxs)("div",{className:"relative",ref:c,"data-testid":"file-metadata-toggle",children:[(0,r.jsx)("button",{type:"button","data-testid":"file-metadata-toggle-button",onClick:()=>i(e=>!e),"aria-haspopup":"menu","aria-expanded":l,"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)(nC.A,{className:"w-4 h-4","aria-hidden":"true"})}),l&&(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!==x.x||0!==x.y?{transform:"translate(".concat(x.x,"px, ").concat(x.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")}),nS.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)(u.Sc,{"data-testid":"file-metadata-toggle-".concat(e.key),checked:t[e.key],onCheckedChange:()=>h(e.key),className:"h-3.5 w-3.5"}),(0,r.jsx)("span",{children:a(e.labelKey)})]},e.key))]})]})});function nE(e){let{intervalMs:t,enabled:n,onPoll:a}=e,r=(0,s.useRef)(a);r.current=a;let l=(0,s.useRef)(n);l.current=n;let i=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(){null!==i.current&&(clearInterval(i.current),i.current=null)}function a(){e(),i.current=setInterval(()=>{r.current()},t)}function s(){"hidden"===document.visibilityState?e():"visible"===document.visibilityState&&l.current&&(r.current(),a())}return n?a():e(),document.addEventListener("visibilitychange",s),()=>{e(),document.removeEventListener("visibilitychange",s)}},[t,n])}function nA(e){return"commandmate:file-tree-expanded:"+e}function nM(e){try{let t=window.localStorage.getItem(nA(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 nR=n(89559),nL=n(48314),nP=n(6132);let nD=(0,s.memo)(function(e){let{worktreeId:t,onFileSelect:n,onNewFile:a,onNewDirectory:l,onRename:i,onDelete:c,onUpload:d,onMove:m,className:x="",refreshTrigger:f=0,pollingEnabled:p=!1,searchQuery:g,searchMode:b,searchResults:v,onSearchResultSelect:y,onResetView:j}=e,w=(0,to.Ym)(),k=(0,o.c)("worktree"),{settings:N,toggle:C}=function(){let[e,t]=(0,s.useState)(ng),n=(0,s.useRef)(e);n.current=e,(0,s.useEffect)(()=>{t(function(){try{var e;let t=window.localStorage.getItem(np);if(!t)return{...ng};return e=JSON.parse(t),"object"!=typeof e||null===e?{...ng}:{showSize:"boolean"==typeof e.showSize?e.showSize:ng.showSize,showCreated:"boolean"==typeof e.showCreated?e.showCreated:ng.showCreated,showModified:"boolean"==typeof e.showModified?e.showModified:ng.showModified}}catch(e){return{...ng}}}())},[]),(0,s.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(nb,e),()=>window.removeEventListener(nb,e)},[]);let a=(0,s.useCallback)(e=>{n.current=e,t(e);try{window.localStorage.setItem(np,JSON.stringify(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(nb,{detail:{settings:e}}))}catch(e){}},[]);return{settings:e,toggle:(0,s.useCallback)(e=>{a({...n.current,[e]:!n.current[e]})},[a]),setSettings:a}}(),[S,I]=(0,s.useState)(!0),[T,E]=(0,s.useState)(null),[A,M]=(0,s.useState)([]),{expanded:R,setExpanded:L,resetExpanded:P}=function(e){let[t,n]=(0,s.useState)(()=>nM(e)),a=(0,s.useRef)(e);(0,s.useEffect)(()=>{a.current!==e&&(a.current=e,n(nM(e)))},[e]),(0,s.useEffect)(()=>{!function(e,t){try{let n=nA(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,s.useCallback)(()=>{n(new Set)},[]);return{expanded:t,setExpanded:n,resetExpanded:r}}(t),[D,F]=(0,s.useState)(()=>new Map),O=(0,s.useRef)(null),z=(0,s.useRef)(R);z.current=R;let _=(0,s.useRef)(k);_.current=k;let B=(0,s.useRef)(new Set),{menuState:V,openMenu:U,closeMenu:H}=nr(),K=(0,s.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]),W=(0,s.useRef)(!0);(0,s.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let q=(0,s.useCallback)(async()=>{if(W.current){I(!0),E(null);try{let e=await K();if(!W.current||!e)return;let t=Array.from(z.current),n=new Map,a=[];for(let e=0;e<t.length;e+=5){if(!W.current)return;let r=t.slice(e,e+5);for(let[e,t]of(await Promise.allSettled(r.map(async e=>{let t=await K(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(!W.current)return;M(e.items),F(n),a.length>0&&L(e=>{let t=new Set(e);for(let e of a)e&&t.delete(e);return t})}catch(e){W.current&&E(e instanceof Error?e.message:_.current("fileTree.loadError"))}finally{W.current&&I(!1)}}},[K,L]);(0,s.useEffect)(()=>{q()},[q,f]);let $=(0,s.useRef)(null),G=(0,s.useRef)(!1);(0,s.useEffect)(()=>{$.current=null},[t]),nE({intervalMs:5e3,enabled:p,onPoll:(0,s.useCallback)(async()=>{if(W.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(!W.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 K(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(!W.current)return;let n=$.current;if($.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&&q()}finally{G.current=!1}}},[K,q])});let J=(0,s.useCallback)(async e=>{if(!(D.has(e)||B.current.has(e))){B.current.add(e);try{let t=await K(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,K]),Y=(0,s.useCallback)(e=>{L(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[L]),Q=(0,s.useCallback)(()=>{var e;P(),F(new Map),null==(e=O.current)||e.scrollTo({top:0}),null==j||j()},[P,j]),X=(0,s.useMemo)(()=>"content"===b&&v&&0!==v.length?(0,h.q3)(v.map(e=>e.filePath)):new Set,[b,v]);(0,s.useEffect)(()=>{X.size>0&&L(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,L]);let Z=(0,s.useMemo)(()=>{if(!(null==g?void 0:g.trim()))return A;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(A,"")}return"content"===b&&X.size>0?A.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}):A},[A,g,b,X,D]);if(S&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-loading",className:"p-2 ".concat(x),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)(u.EA,{className:"h-4 w-4 shrink-0 rounded"}),(0,r.jsx)(u.EA,{className:"h-4 ".concat(t%3==0?"w-32":t%3==1?"w-24":"w-40"," max-w-full")})]},t))});if(T&&0===A.length)return(0,r.jsx)("div",{"data-testid":"file-tree-error",className:"p-4 bg-danger-subtle border border-danger-border rounded-lg ".concat(x),children:(0,r.jsx)("p",{className:"text-sm text-danger",children:T})});let et=S&&A.length>0,en=!!T&&A.length>0;return 0===A.length?(0,r.jsxs)("div",{"data-testid":"file-tree-empty",className:"p-4 text-center text-muted-foreground ".concat(x),children:[(0,r.jsx)("p",{className:"text-sm",children:k("fileTree.empty")}),(a||l)&&(0,r.jsxs)("div",{className:"flex flex-col gap-2 mt-4",children:[a&&(0,r.jsxs)(u.$n,{variant:"ghost","data-testid":"empty-new-file-button",onClick:()=>a(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(nl.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newFile")})]}),l&&(0,r.jsxs)(u.$n,{variant:"ghost","data-testid":"empty-new-directory-button",onClick:()=>l(""),className:"flex items-center justify-center gap-2 px-3 py-2 text-sm text-foreground bg-surface border border-input rounded-md hover:bg-muted transition-colors",children:[(0,r.jsx)(ni.A,{className:"w-4 h-4","aria-hidden":"true"}),(0,r.jsx)("span",{children:k("fileTree.newDirectory")})]})]})]}):(null==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(x),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:"@container overflow-auto bg-surface ".concat(x),children:[(0,r.jsxs)("div",{"data-testid":"file-tree-toolbar",className:"flex flex-wrap items-center gap-1 p-1 border-b border-border",children:[a&&(0,r.jsx)(ee.m_,{content:k("fileTree.newFile"),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{"data-testid":"toolbar-new-file-button",onClick:()=>a(""),"aria-label":k("fileTree.newFile"),className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(nl.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden @min-[360px]:inline",children:k("fileTree.newFile")})]})}),l&&(0,r.jsx)(ee.m_,{content:k("fileTree.newDirectory"),placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{"data-testid":"toolbar-new-directory-button",onClick:()=>l(""),"aria-label":k("fileTree.newDirectory"),className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap px-2 py-1 text-xs text-muted-foreground hover:bg-muted rounded transition-colors",children:[(0,r.jsx)(ni.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden @min-[360px]:inline",children:k("fileTree.newDirectory")})]})}),(0,r.jsxs)("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-1",children:[(0,r.jsx)(nT,{settings:N,onToggle:C}),et&&(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:()=>{q()},disabled:et,"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)(nR.A,{className:"w-4 h-4 ".concat(et?"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)(nL.A,{className:"w-4 h-4","aria-hidden":"true"})})]})]}),en&&(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)(nP.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"flex-1 truncate",children:T}),(0,r.jsx)(u.$n,{variant:"ghost","data-testid":"file-tree-refetch-retry-button",onClick:()=>{q()},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)(nN,{item:e,path:"",depth:0,worktreeId:t,expanded:R,cache:D,onToggle:Y,onFileSelect:y||n,onLoadChildren:J,onContextMenu:U,searchQuery:g,searchMode:b,matchedPaths:X,dateFnsLocaleStr:w,metadataDisplay:N},e.name)),(0,r.jsx)(nx,{isOpen:V.isOpen,position:V.position,targetPath:V.targetPath,targetType:V.targetType,onClose:H,onNewFile:a,onNewDirectory:l,onRename:i,onDelete:c,onUpload:d,onMove:m})]})});var nF=n(38218);let nO=(0,s.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"})})}),nz=(0,s.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"})})}),n_=(0,s.memo)(function(){let e=(0,o.c)("worktree");return(0,r.jsx)(d.y,{size:"sm",variant:"accent","data-testid":"search-loading",role:"status","aria-hidden":!1,"aria-label":e("search.searching")})}),nB=(0,s.memo)(function(e){let{query:t,mode:n,isSearching:a,error:l,onQueryChange:i,onModeChange:c,onClear:d,placeholder:u,className:m=""}=e,x=(0,s.useRef)(null),f=(0,o.c)("worktree"),h=(0,s.useCallback)(e=>{i(e.target.value)},[i]),p=(0,s.useCallback)(()=>{var e;d(),null==(e=x.current)||e.focus()},[d]),g=(0,s.useCallback)(e=>{if("Escape"===e.key)if(t)p();else{var n;null==(n=x.current)||n.blur()}},[t,p]);return(0,s.useEffect)(()=>{if(!(window.innerWidth<nF.D)){let e=setTimeout(()=>{var e;null==(e=x.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)(nO,{})}),(0,r.jsx)("input",{ref:x,type:"text","data-testid":"search-input",value:t,onChange:h,onKeyDown:g,placeholder:null!=u?u:f("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":f("search.label"),"aria-busy":a}),(a||!!t)&&(0,r.jsx)("div",{className:"flex-shrink-0 w-6 h-6 flex items-center justify-center",children:a?(0,r.jsx)(n_,{}):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":f("search.clear"),children:(0,r.jsx)(nz,{})}):null})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground mr-1 whitespace-nowrap",children:f("search.mode")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-name",onClick:()=>c("name"),className:"px-2 py-0.5 text-xs rounded transition-colors whitespace-nowrap flex-shrink-0 ".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:f("search.modeName")}),(0,r.jsx)("button",{type:"button","data-testid":"mode-content",onClick:()=>c("content"),className:"px-2 py-0.5 text-xs rounded transition-colors whitespace-nowrap flex-shrink-0 ".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:f("search.modeContent")})]}),l&&(0,r.jsx)("div",{"data-testid":"search-error",className:"text-xs text-danger bg-danger-subtle px-2 py-1 rounded",role:"alert",children:l})]})});function nV(e){return 0===e.length?"0":e.map(e=>"".concat(e.id,":").concat(e.title.length,":").concat(e.content.length)).join("|")}var nU=n(12108),nH=n(54916),nK=n(60850);let nW=(0,s.memo)(function(e){var t,n;let{memo:a,onUpdate:l,onDelete:i,isSaving:c,error:d,className:u="",onInsertToMessage:m,onMoveUp:x,onMoveDown:f,canMoveUp:h=!0,canMoveDown:p=!0}=e,g=(0,o.c)("schedule"),b=(0,o.c)("worktree"),v=!!(x||f),[y,j]=(0,s.useState)(a.title),[w,k]=(0,s.useState)(a.content),[N,C]=(0,s.useState)(!1),S=(0,s.useRef)(void 0);(0,s.useEffect)(()=>()=>{S.current&&clearTimeout(S.current)},[]);let{isSaving:I,error:T,saveNow:E}=(0,nK.U)({value:y,saveFn:async e=>{await l(a.id,{title:e})}}),{isSaving:A,error:M,saveNow:R}=(0,nK.U)({value:w,saveFn:async e=>{await l(a.id,{content:e})}}),L=null!=(n=null!=(t=null!=d?d:null==T?void 0:T.message)?t:null==M?void 0:M.message)?n:null,P=(0,s.useCallback)(e=>{j(e.target.value)},[]),D=(0,s.useCallback)(e=>{k(e.target.value)},[]),F=(0,s.useCallback)(()=>{E()},[E]),O=(0,s.useCallback)(()=>{R()},[R]),z=(0,s.useCallback)(()=>{i(a.id)},[a.id,i]),_=(0,s.useCallback)(()=>{w.trim()&&(null==m||m(w))},[w,m]),B=(0,s.useCallback)(async()=>{if(w.trim())try{await (0,eX.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!=c?c:I||A)&&(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:x,disabled:!h,"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)(nU.A,{className:"w-4 h-4","aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","data-testid":"memo-move-down-".concat(a.id),onClick:f,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)(G.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)(nH.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)(eV.A,{className:"w-4 h-4 text-success"}):(0,r.jsx)(eU.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"}),L&&(0,r.jsx)("div",{className:"text-xs text-danger",children:L})]})}),nq=(0,s.memo)(function(e){let{currentCount:t,maxCount:n,onAdd:a,isLoading:s=!1,className:l=""}=e,i=(0,o.c)("schedule"),c=Math.max(0,n-t),u=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:()=>{u||a()},disabled:u,"aria-label":i("memoAdd"),"aria-disabled":u,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(u?"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)(d.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:c})})]})});function n$(e){let{query:t,onQueryChange:n,matchCount:a,currentIndex:l,onNext:i,onPrev:c,onClose:d,onCompositionStart:m,onCompositionEnd:x}=e,f=(0,o.c)("schedule"),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;null==(e=h.current)||e.focus()},[]);let p=(0,s.useCallback)(e=>{if("Escape"===e.key)return void d();"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),i())},[d,i]),g=(0,s.useCallback)(e=>{n(e.target.value)},[n]),b=0===a?"0/0":"".concat(l+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":f("memoSearchLabel"),children:[(0,r.jsx)("input",{ref:h,type:"text",value:t,onChange:g,onKeyDown:p,onCompositionStart:m,onCompositionEnd:x,placeholder:f("memoSearchPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-foreground text-sm outline-none placeholder-muted-foreground","aria-label":f("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)(u.$n,{variant:"ghost",type:"button",onClick:c,disabled:0===a,"aria-label":f("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)(u.$n,{variant:"ghost",type:"button",onClick:i,disabled:0===a,"aria-label":f("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)(u.$n,{variant:"ghost",type:"button",onClick:d,"aria-label":f("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 nG=(0,s.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a}=e,l=(0,o.c)("schedule"),i=(0,o.c)("common"),c=(0,eF.SC)(),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(!0),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(null),{query:N,matches:C,currentMatch:S,totalCount:I,setQuery:T,reset:E,navigateNext:A,navigatePrev:M,onCompositionStart:R,onCompositionEnd:L}=function(e){let{memos:t}=e,[n,a]=(0,s.useState)(""),[r,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(-1),c=(0,s.useRef)(null),d=(0,s.useRef)(""),u=(0,s.useRef)(!1),m=(0,s.useRef)(nV(t)),x=(0,s.useRef)(t);x.current=t;let f=r.length,h=(0,s.useCallback)(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),p=(0,s.useCallback)(e=>{let t=function(e,t){if(t.length<e3.E2||0===e.length)return[];let n=t.toLowerCase();return e.filter(e=>-1!==e.title.toLowerCase().indexOf(n)||-1!==e.content.toLowerCase().indexOf(n))}(x.current,e);l(t),o(t.length>0?0:-1)},[]),g=(0,s.useCallback)(e=>{h(),d.current=e,u.current||(c.current=setTimeout(()=>{p(e)},e3.e1))},[h,p]),b=(0,s.useCallback)(e=>{a(e),g(e)},[g]),v=(0,s.useCallback)(()=>{a(""),d.current="",l([]),o(-1),h()},[h]),y=(0,s.useCallback)(()=>{o(e=>0===f?-1:(e+1)%f)},[f]),j=(0,s.useCallback)(()=>{o(e=>0===f?-1:(e-1+f)%f)},[f]),w=(0,s.useCallback)(()=>{u.current=!0,h()},[h]),k=(0,s.useCallback)(()=>{u.current=!1;let e=d.current;e.length>=e3.E2&&(h(),c.current=setTimeout(()=>{p(e)},e3.e1))},[h,p]);return(0,s.useEffect)(()=>{let e=nV(t);if(e===m.current)return;m.current=e;let n=d.current;n.length>=e3.E2&&p(n)},[t,p]),(0,s.useEffect)(()=>()=>{h(),d.current=""},[h]),{query:n,matches:r,currentMatch:i,totalCount:f,setQuery:b,reset:v,navigateNext:y,navigatePrev:j,onCompositionStart:w,onCompositionEnd:k}}({memos:u}),P=j&&N.length>0,D=P?C:u,F=(0,s.useCallback)(async()=>{f(!0),b(null);try{let e=await tm.$T.getAll(t);m(e.sort((e,t)=>e.position-t.position))}catch(e){b((0,tm.hS)(e))}finally{f(!1)}},[t]);(0,s.useEffect)(()=>{F()},[F]);let O=(0,s.useCallback)(async()=>{p(!0),y(null);try{let e=await tm.$T.create(t,{title:l("memoDefaultTitle"),content:""});m(t=>[...t,e])}catch(e){y((0,tm.hS)(e))}finally{p(!1)}},[t,l]),z=(0,s.useCallback)(async(e,n)=>{await tm.$T.update(t,e,n),m(t=>t.map(t=>t.id===e?{...t,...n}:t))},[t]),_=(0,s.useCallback)(async e=>{var n;let a=u.find(t=>t.id===e);if(await c({description:i("confirmDelete",{name:null!=(n=null==a?void 0:a.title)?n:""}),variant:"danger"}))try{await tm.$T.delete(t,e),m(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Failed to delete memo:",e)}},[t,u,c,i]),B=(0,s.useCallback)(async(e,n)=>{let a=e+n;if(a<0||a>=u.length)return;let r=[...u];[r[e],r[a]]=[r[a],r[e]],m(r);try{await tm.$T.reorder(t,r.map(e=>e.id))}catch(e){b((0,tm.hS)(e)),await F()}},[u,t,F]),V=(0,s.useCallback)(()=>{F()},[F]),U=(0,s.useCallback)(()=>{w(e=>(e&&E(),!e))},[E]),K=(0,s.useCallback)(()=>{w(!1),E()},[E]);return((0,s.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]),x)?(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)(d.y,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:l("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:V,"aria-label":i("retry"),className:"px-4 py-2 text-sm font-medium text-white bg-accent-500 rounded-lg hover:bg-accent-600 transition-colors",children:i("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)(n$,{query:N,onQueryChange:T,matchCount:I,currentIndex:S,onNext:A,onPrev:M,onClose:K,onCompositionStart:R,onCompositionEnd:L})}):(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":l("memoSearchToggle"),className:"p-1.5 text-muted-foreground hover:text-foreground transition-colors rounded",children:(0,r.jsx)(H.A,{className:"w-4 h-4","aria-hidden":"true"})})]})}),0===u.length&&!P&&!v&&(0,r.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,r.jsx)("p",{children:l("memoEmpty")}),(0,r.jsx)("p",{className:"text-sm",children:l("memoEmptyHint")})]}),P&&0===D.length&&(0,r.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:(0,r.jsx)("p",{children:l("memoNoMatch")})}),D.map((e,t)=>(0,r.jsx)(nW,{memo:e,onUpdate:z,onDelete:_,onInsertToMessage:a,onMoveUp:P?void 0:()=>B(t,-1),onMoveDown:P?void 0:()=>B(t,1),canMoveUp:!P&&t>0,canMoveDown:!P&&t<u.length-1},e.id)),v&&(0,r.jsx)("div",{className:"text-center py-2 text-sm text-danger",children:v}),!P&&(0,r.jsx)(nq,{currentCount:u.length,maxCount:20,onAdd:O,isLoading:h,className:"mt-2"})]})});async function nJ(e,t){throw Error((await e.json().catch(()=>({}))).error||"".concat(t," (").concat(e.status,")"))}let nY=["todo","doing","done"],nQ={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:[]:nJ(n,"Failed to load todos")},async create(e,t,n){let a=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 a.ok?(await a.json()).todo:nJ(a,"Failed to create todo")},async update(e,t,n){let a=await fetch("/api/worktrees/".concat(encodeURIComponent(e),"/todos/").concat(encodeURIComponent(t)),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return a.ok?(await a.json()).todo:nJ(a,"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 nJ(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 nJ(n,"Failed to reorder todos")}};var nX=n(53482);let nZ={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"},n0=s.memo(function(e){let{worktreeId:t,className:n=""}=e,a=(0,o.c)("worktree"),l=(0,o.c)("common"),i=(0,eF.SC)(),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(""),[x,f]=(0,s.useState)(!0),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(""),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),I=(0,s.useCallback)(e=>{switch(e){case"doing":return a("todo.statusDoing");case"done":return a("todo.statusDone");default:return a("todo.statusTodo")}},[a]),T=(0,s.useCallback)(async()=>{f(!0),b(null);try{let e=await nQ.list(t);d(e)}catch(e){b(e instanceof Error?e.message:a("todo.loadError")),d([])}finally{f(!1)}},[t,a]);(0,s.useEffect)(()=>{T()},[t]);let E=(0,s.useCallback)(async()=>{let e=u.trim();if(e&&!h){p(!0),b(null);try{let n=await nQ.create(t,e);d(e=>[...e,n]),m("")}catch(e){b(e instanceof Error?e.message:a("todo.addError"))}finally{p(!1)}}},[u,h,t,a]),A=(0,s.useCallback)(async e=>{let n=function(e){let t=nY.indexOf(e);return nY[(t+1)%nY.length]}(e.status);d(t=>t.map(t=>t.id===e.id?{...t,status:n,done:"done"===n}:t)),b(null);try{await nQ.update(t,e.id,{status:n})}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),T()}},[t,T,a]),M=(0,s.useCallback)(async e=>{if(await i({description:l("confirmDelete",{name:e.content}),variant:"danger"})){b(null);try{await nQ.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,i,l]),R=(0,s.useCallback)(e=>{y(e),w(e.content),N(e.detail),b(null)},[]),L=(0,s.useCallback)(()=>{y(null),S(!1)},[]),P=(0,s.useCallback)(async()=>{if(!v)return;let e=j.trim();if(e&&!C){S(!0),b(null);try{let n=await nQ.update(t,v.id,{content:e,detail:k});d(e=>e.map(e=>e.id===v.id?n:e)),L()}catch(e){b(e instanceof Error?e.message:a("todo.updateError")),S(!1)}}},[v,j,k,C,t,L,a]),D=(0,s.useCallback)(async(e,n)=>{let r=e+n;if(r<0||r>=c.length)return;let s=[...c];[s[e],s[r]]=[s[r],s[e]],d(s),b(null);try{await nQ.reorder(t,s.map(e=>e.id))}catch(e){b(e instanceof Error?e.message:a("todo.reorderError")),T()}},[c,t,T,a]),F=(0,s.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),E())},[E]),O=(0,s.useMemo)(()=>({todo:c.filter(e=>"todo"===e.status).length,doing:c.filter(e=>"doing"===e.status).length,done:c.filter(e=>"done"===e.status).length}),[c]);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:2e3,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:E,disabled:h||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:[I("todo")," ",O.todo]}),(0,r.jsxs)("span",{"data-testid":"todo-count-doing",children:[I("doing")," ",O.doing]}),(0,r.jsxs)("span",{"data-testid":"todo-count-done",children:[I("done")," ",O.done]})]}),g&&(0,r.jsx)("p",{className:"mb-2 text-xs text-danger-foreground","data-testid":"todo-error",children:g}),x?(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"todo-loading",children:a("todo.loading")}):0===c.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:c.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:()=>A(e),"data-testid":"todo-status","data-status":e.status,"aria-label":a("todo.cycleStatus",{status:I(e.status)}),title:a("todo.cycleStatus",{status:I(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(nZ[e.status]),children:I(e.status)}),(0,r.jsxs)("button",{type:"button",onClick:()=>R(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===c.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:()=>M(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)(tN.a,{isOpen:null!==v,onClose:L,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:2e3,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)(nX.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:4e3,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:L,"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 n1=n(95740),n2=n(66630);function n4(e){let{isOpen:t,onClose:n,title:a,children:l,footer:i,showCloseButton:c=!0}=e,d=(0,o.c)("common"),[u,m]=(0,s.useState)(null);return((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t&&n()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,n]),(0,s.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[t]),(0,s.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,ns.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:e2.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}),c&&(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)(eu.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:l}),i&&(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:i})]}),document.body):null}let n5=["default","acceptEdits","plan","dontAsk","bypassPermissions"],n3=["read-only","workspace-write","danger-full-access"],n6=["allow-all-tools","yolo"],n9=["--dangerously-skip-permissions"],n8=["default","standard","plan","auto-accept","dont-ask"],n7="yolo",ae=[n7,...n8],at=[],an=[],aa=[],ar=[],as={claude:"acceptEdits",codex:"workspace-write",gemini:"","vibe-local":"",opencode:"",copilot:"allow-all-tools",antigravity:"--dangerously-skip-permissions","command-code":n7};function al(e){switch(e){case"claude":return n5;case"codex":return n3;case"copilot":return n6;case"antigravity":return n9;case"command-code":return ae;case"gemini":return at;case"vibe-local":return an;case"opencode":return aa;default:return ar}}let ai=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function ao(e){return e.replace(RegExp(ai.source,"g"),"")}let ac=/^[\w\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF\uF900-\uFAFF\s-]{1,100}$/;function ad(e){if(e.length>100)return!1;let t=e.trim().split(/\s+/);return t.length>=5&&t.length<=6}var au=n(3199);let am=["edit_file","write_file","shell_command","monitor_command","kill_shell"];function ax(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}function af(e,t){return"command-code"===e&&n8.includes(t.trim())}var ah=n(26020);let ap={en:{bannerTitle:"CMATE.md has schedules to check",body:"With a --permission-mode value as Permission (default / standard / plan / auto-accept / dont-ask), command-code print mode (`commandcode -p`) rejects the write tools the agent calls directly (edit_file / write_file / shell_command / monitor_command / kill_shell). This is a warning and does not stop the schedule from being saved or run. Set Permission to `yolo` if the task needs to write."},ja:{bannerTitle:"CMATE.md に確認が必要なスケジュールがあります",body:"Permission が --permission-mode の値(default / standard / plan / auto-accept / dont-ask)のとき、command-code の print モード(`commandcode -p`)は、エージェントが直接呼ぶ書き込み系ツール(edit_file / write_file / shell_command / monitor_command / kill_shell)を拒否します。これは警告で、スケジュールの登録も実行も止めません。書き込みが必要な作業なら Permission を `yolo` にしてください。"}};function ag(e){return ap[(0,ah.d9)(e)?e:ah.Xn]}let ab=[{value:"0 */1 * * *",labelKey:"cronPresetHourly"},{value:"0 9 * * *",labelKey:"cronPresetDaily9"},{value:"0 9 * * 1",labelKey:"cronPresetWeeklyMon9"}],av={name:"",cronExpression:"0 9 * * *",message:"",cliToolId:"claude",enabled:!0,permission:null!=(a=as.claude)?a:"",model:"",agent:"",variant:"",continueSession:!1,title:""},ay="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",aj="block text-xs font-semibold text-foreground mb-1",aw="mt-1 text-xs text-danger-foreground";function ak(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)(n1.A,{size:14,"aria-hidden":"true"}),n]})}function aN(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)(G.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 aC(e){var t,n;let{isOpen:a,worktreeId:l,initialValues:i,originalName:c,onInsertToMessage:d,instances:m,onClose:x,onSaved:f}=e,h=(0,o.c)("schedule"),p=(0,to.Ym)(),g=(0,nF.a)(),b=(0,s.useMemo)(()=>m&&m.length>0?m:(0,Q.lu)([...Q.XH]),[m]),[v,y]=(0,s.useState)(av),[j,w]=(0,s.useState)(""),[N,C]=(0,s.useState)(!1),[S,I]=(0,s.useState)(null),[T,E]=(0,s.useState)(()=>new Set(["basic","advanced","message"]));(0,s.useEffect)(()=>{var e,t,n,r,s,l,o,c,d,u,m,x,f,h;if(!a)return;I(null),C(!1);let p=null!=(t=null==i?void 0:i.cliToolId)?t:av.cliToolId;y({name:null!=(n=null==i?void 0:i.name)?n:av.name,cronExpression:null!=(r=null==i?void 0:i.cronExpression)?r:av.cronExpression,message:null!=(s=null==i?void 0:i.message)?s:av.message,cliToolId:p,enabled:null!=(l=null==i?void 0:i.enabled)?l:av.enabled,permission:null!=(o=null==i?void 0:i.permission)?o:av.permission,model:null!=(c=null==i?void 0:i.model)?c:av.model,agent:null!=(d=null==i?void 0:i.agent)?d:av.agent,variant:null!=(u=null==i?void 0:i.variant)?u:av.variant,continueSession:null!=(m=null==i?void 0:i.continueSession)?m:av.continueSession,title:null!=(x=null==i?void 0:i.title)?x:av.title});let g=b.find(e=>e.cliTool===p);w(null!=(h=null!=(f=null==g?void 0:g.id)?f:null==(e=b[0])?void 0:e.id)?h:p)},[a,i,b]),(0,s.useEffect)(()=>{a&&E(new Set(g?["basic"]:["basic","advanced","message"]))},[a,g]);let A=(0,s.useCallback)(e=>{E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),M=al(v.cliToolId),R=M.length>0,L=af(v.cliToolId,v.permission),P=au.Vt.has(v.cliToolId),D=au.aN.has(v.cliToolId),F=!!c,O=(0,s.useMemo)(()=>{let e=v.name.trim();return e?e.length>100?h("edit.errorNameTooLong",{max:100}):ac.test(e)?null:h("edit.errorNameInvalid"):h("edit.errorNameRequired")},[v.name,h]),z=(0,s.useMemo)(()=>ad(v.cronExpression.trim())?null:h("edit.errorCronInvalid"),[v.cronExpression,h]),_=(0,s.useMemo)(()=>v.message.trim()?v.message.length>1e4?h("edit.errorMessageTooLong",{max:1e4}):null:h("edit.errorMessageRequired"),[v.message,h]),B=(0,s.useMemo)(()=>P&&v.model.trim()?(0,au.JY)(v.model.trim()).valid?null:h("edit.errorModelInvalid"):null,[P,v.model,h]),V=(0,s.useMemo)(()=>D&&v.agent.trim()?(0,au.sd)(v.agent.trim(),"agent").valid?null:h("edit.errorAgentInvalid"):null,[D,v.agent,h]),U=(0,s.useMemo)(()=>D&&v.variant.trim()?(0,au.sd)(v.variant.trim(),"variant").valid?null:h("edit.errorVariantInvalid"):null,[D,v.variant,h]),H=(0,s.useMemo)(()=>D&&v.title.trim()?(0,au.kj)(v.title.trim()).valid?null:h("edit.errorTitleInvalid"):null,[D,v.title,h]),K=!O&&!z&&!_&&!B&&!V&&!U&&!H,W=(0,s.useCallback)(e=>{y(t=>({...t,cliToolId:e,permission:function(e){let t=as[e];if(void 0!==t)return t;let n=al(e);return n.length>0?n[0]:""}(e),model:au.Vt.has(e)?t.model:"",agent:au.aN.has(e)?t.agent:"",variant:au.aN.has(e)?t.variant:"",continueSession:!!au.aN.has(e)&&t.continueSession,title:au.aN.has(e)?t.title:""}))},[]),q=(0,s.useCallback)(e=>{let t=b.find(t=>t.id===e);t&&(w(e),W(t.cliTool))},[b,W]),G=ab.some(e=>e.value===v.cronExpression)?v.cronExpression:"custom",J=(0,s.useCallback)(e=>{"custom"!==e&&y(t=>({...t,cronExpression:e}))},[]),Y=(0,s.useCallback)(e=>{null==d||d(e),x()},[d,x]),X=(0,s.useCallback)(async()=>{if(K&&!N){C(!0),I(null);try{let e=await fetch("/api/worktrees/".concat(l,"/cmate/schedules"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.name.trim(),cronExpression:v.cronExpression.trim(),message:v.message.trim(),cliToolId:v.cliToolId,enabled:v.enabled,permission:R?v.permission:"",model:P&&v.model.trim()?v.model.trim():void 0,agent:D&&v.agent.trim()?v.agent.trim():void 0,variant:D&&v.variant.trim()?v.variant.trim():void 0,continueSession:!!D&&!!v.continueSession||void 0,title:D&&v.title.trim()?v.title.trim():void 0,originalName:null!=c?c:void 0})});if(!e.ok){let t=await e.json().catch(()=>({}));I(t.error||h("edit.saveError"));return}f(),x()}catch(e){I(h("edit.saveError"))}finally{C(!1)}}},[K,N,l,v,R,P,D,c,f,x,h]),Z=null!=(n=null==(t=b.find(e=>e.id===j))?void 0:t.alias)?n:(0,Q.f_)(v.cliToolId),ee=v.name.trim()?"".concat(v.name.trim()," \xb7 ").concat(v.cronExpression):v.cronExpression,et=[Z,R?v.permission:null,P&&v.model.trim()?v.model.trim():null,D&&v.agent.trim()?"--agent ".concat(v.agent.trim()):null,D&&v.variant.trim()?"--variant ".concat(v.variant.trim()):null,D&&v.continueSession?"--continue":null].filter(Boolean).join(" \xb7 "),en=v.message.trim(),ea=en.length>32?"".concat(en.slice(0,32),"…"):en,er=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-name-input",children:h("edit.name")}),(0,r.jsx)("input",{id:"schedule-name-input","data-testid":"schedule-name-input",type:"text",value:v.name,maxLength:100,placeholder:h("edit.namePlaceholder"),onChange:e=>y(t=>({...t,name:e.target.value})),className:ay}),O&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-name-error",children:O})]}),(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:h("edit.cron")}),d&&(0,r.jsx)(ak,{testId:"schedule-cron-ask-ai",label:h("edit.askAiCron"),title:h("edit.askAiHint"),onClick:()=>Y(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.cron"):e("edit.aiPrompts.cronRefine",{current:"`"+n+"`"})}(h,v.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:v.cronExpression,placeholder:h("edit.cronPlaceholder"),onChange:e=>y(t=>({...t,cronExpression:e.target.value})),className:"".concat(ay," font-mono sm:flex-1")}),(0,r.jsxs)("select",{"data-testid":"schedule-cron-preset","aria-label":h("edit.cronPreset"),value:G,onChange:e=>J(e.target.value),className:"".concat(ay," sm:w-48"),children:[ab.map(e=>(0,r.jsx)("option",{value:e.value,children:h("edit.".concat(e.labelKey))},e.value)),(0,r.jsx)("option",{value:"custom",children:h("edit.cronPresetCustom")})]})]}),z&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-cron-error",children:z})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(u.Sc,{"data-testid":"schedule-enabled-toggle",checked:v.enabled,onCheckedChange:e=>y(t=>({...t,enabled:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:h("edit.enabledLabel")})]})]}),es=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-cli-tool-select",children:h("edit.cliTool")}),(0,r.jsx)("select",{id:"schedule-cli-tool-select","data-testid":"schedule-cli-tool-select",value:j,onChange:e=>q(e.target.value),className:ay,children:b.map(e=>(0,r.jsx)("option",{value:e.id,children:e.alias},e.id))})]}),P&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-model-input",children:h("edit.model")}),(0,r.jsx)("input",{id:"schedule-model-input","data-testid":"schedule-model-input",type:"text",value:v.model,placeholder:h("edit.modelPlaceholder"),onChange:e=>y(t=>({...t,model:e.target.value})),className:ay}),B&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-model-error",children:B})]}),D&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-agent-input",children:h("edit.opencodeAgent")}),(0,r.jsx)("input",{id:"schedule-agent-input","data-testid":"schedule-agent-input",type:"text",value:v.agent,placeholder:h("edit.opencodeAgentPlaceholder"),onChange:e=>y(t=>({...t,agent:e.target.value})),className:ay}),V&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-agent-error",children:V})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-variant-input",children:h("edit.opencodeVariant")}),(0,r.jsx)("input",{id:"schedule-variant-input","data-testid":"schedule-variant-input",type:"text",value:v.variant,placeholder:h("edit.opencodeVariantPlaceholder"),onChange:e=>y(t=>({...t,variant:e.target.value})),className:ay}),U&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-variant-error",children:U})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-title-input",children:h("edit.opencodeTitle")}),(0,r.jsx)("input",{id:"schedule-title-input","data-testid":"schedule-title-input",type:"text",value:v.title,placeholder:h("edit.opencodeTitlePlaceholder"),onChange:e=>y(t=>({...t,title:e.target.value})),className:ay}),H&&(0,r.jsx)("p",{className:aw,"data-testid":"schedule-title-error",children:H})]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,r.jsx)(u.Sc,{"data-testid":"schedule-continue-toggle",checked:v.continueSession,onCheckedChange:e=>y(t=>({...t,continueSession:!0===e}))}),(0,r.jsx)("span",{className:"text-sm text-foreground",children:h("edit.opencodeContinue")})]})]}),R&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:aj,htmlFor:"schedule-permission-select",children:h("edit.permission")}),(0,r.jsx)("select",{id:"schedule-permission-select","data-testid":"schedule-permission-select",value:v.permission,onChange:e=>y(t=>({...t,permission:e.target.value})),className:ay,children:M.map(e=>(0,r.jsx)("option",{value:e,children:e},e))}),L&&(0,r.jsx)("p",{className:"mt-1 text-xs text-warning-foreground","data-testid":"schedule-permission-write-tools-denied-note",children:ag(p).body})]})]}),el=(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:h("edit.message")}),d&&(0,r.jsx)(ak,{testId:"schedule-message-ask-ai",label:h("edit.askAiMessage"),title:h("edit.askAiHint"),onClick:()=>Y(function(e,t){let n=t.trim();return 0===n.length?e("edit.aiPrompts.messageDraft"):e("edit.aiPrompts.messageDraftNamed",{name:"`"+n+"`"})}(h,v.name))})]}),(0,r.jsx)("textarea",{id:"schedule-message-input","data-testid":"schedule-message-input",value:v.message,rows:4,maxLength:1e4,placeholder:h("edit.messagePlaceholder"),onChange:e=>y(t=>({...t,message:e.target.value})),className:"".concat(ay," resize-none")}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between",children:[_?(0,r.jsx)("p",{className:aw,"data-testid":"schedule-message-error",children:_}):(0,r.jsx)("span",{}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"schedule-message-count",children:h("edit.charCount",{count:v.message.length,max:1e4})})]})]}),ei=(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)(aN,{id:"basic",title:h("edit.sectionBasic"),summary:ee,icon:(0,r.jsx)(k.A,{className:"w-4 h-4"}),isOpen:T.has("basic"),onToggle:A,children:er}),(0,r.jsx)(aN,{id:"advanced",title:h("edit.sectionAdvanced"),summary:et,icon:(0,r.jsx)(n2.A,{className:"w-4 h-4"}),isOpen:T.has("advanced"),onToggle:A,children:es}),(0,r.jsx)(aN,{id:"message",title:h("edit.sectionMessage"),summary:ea,icon:(0,r.jsx)($.A,{className:"w-4 h-4"}),isOpen:T.has("message"),onToggle:A,children:el}),S&&(0,r.jsx)("div",{className:"text-xs p-2 rounded bg-danger-subtle text-danger-foreground","data-testid":"schedule-submit-error",children:S})]}),eo=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:h("edit.cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"schedule-save-button",onClick:()=>void X(),disabled:!K||N,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:h("edit.save")})]}),ec=F?h("edit.titleEdit"):h("edit.titleCreate");return g?(0,r.jsx)(n4,{isOpen:a,onClose:x,title:ec,footer:eo,children:ei}):(0,r.jsx)(tN.a,{isOpen:a,onClose:x,title:ec,size:"md",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[ei,(0,r.jsx)("div",{className:"pt-2 border-t border-border",children:eo})]})})}function aS(e){return new Date(e).toLocaleString()}function aI(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 aT=(0,s.memo)(function(e){let{worktreeId:t}=e,n=(0,to.Ym)(),[a,l]=(0,s.useState)([]);if((0,s.useEffect)(()=>{let e=!1,n=t=>{e||l(e=>0===e.length&&0===t.length?e:t)};return(async()=>{try{var e;let a=await fetch("/api/worktrees/".concat(t,"/files/CMATE.md")),r=a.ok?await a.json():null,s="string"==typeof(null==r?void 0:r.content)?r.content:"";n(function(e){let t=[],n=0;for(let r=0;r<e.length;r++){var a;let s=e[r],l=function(e){let t=[];for(let n=0;n<e.length;n++){let a=e[n];if(a.length<3){t.push({row:n,message:"Row ".concat(n+1,": insufficient columns (need at least 3, got ").concat(a.length,")"),field:"columns"});continue}let[r,s,l]=a,i=ao(r);ac.test(i)||t.push({row:n,message:"Row ".concat(n+1,': invalid name "').concat(i,'"'),field:"name"}),ad(s)||t.push({row:n,message:"Row ".concat(n+1,': invalid cron "').concat(s,'"'),field:"cron"}),ao(l).trim()||t.push({row:n,message:"Row ".concat(n+1,": empty message"),field:"message"});let{result:o,errors:c}=(0,au.zK)(a[3]||"");for(let e of c)t.push({row:n,message:"Row ".concat(n+1,": ").concat(e),field:e.includes("Model")?"model":"cliTool"});o&&!(0,Q.hR)(o.cliToolId)&&t.push({row:n,message:"Row ".concat(n+1,': unknown CLI Tool "').concat(o.cliToolId,'"'),field:"cliTool"});let d=a[5];if(void 0!==d&&""!==d.trim()){let e=d.trim(),a=o.cliToolId;("claude"===a?n5:"codex"===a?n3:"copilot"===a?n6:"antigravity"===a?n9:"command-code"===a?ae:[]).includes(e)||t.push({row:n,message:"Row ".concat(n+1,': invalid permission "').concat(e,'" for ').concat(a),field:"permission"})}}return t}([s]);if(l.some(e=>"permission"!==e.field))continue;if(n>=100)break;if(n++,l.length>0)continue;let[i,,,o,c,d]=s;if(a=c,void 0!==a&&""!==a&&"true"!==a.toLowerCase())continue;let{result:u}=(0,au.zK)(o||""),m=(null!=d?d:"").trim();if(!af(u.cliToolId,m))continue;let x=ao(i);t.push({row:r,name:x,field:"permission",code:"command-code-direct-write-tools-denied",cliToolId:u.cliToolId,permission:m,message:"Row ".concat(r+1,': schedule "').concat(x,'" runs command-code with the --permission-mode value "').concat(m,'", ')+"so commandcode -p rejects the write tools the agent calls directly "+"(".concat(am.join(", "),"). ")+'This is a warning, not an error: the schedule still runs. Use "yolo" if it needs to write.'})}return t}(null!=(e=ax(s).get("Schedules"))?e:[]))}catch(e){n([])}})(),()=>{e=!0}},[t]),0===a.length)return null;let i=ag(n);return(0,r.jsxs)("div",{role:"status","data-testid":"schedule-config-warnings",className:"rounded border border-warning-border bg-warning-subtle p-3 text-warning-foreground",children:[(0,r.jsx)("p",{className:"text-sm font-semibold",children:i.bannerTitle}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:a.map(e=>(0,r.jsxs)("li",{"data-testid":"schedule-config-warning-".concat(e.name),"data-warning-code":e.code,className:"text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name}),(0,r.jsxs)("span",{className:"ml-2 font-mono",children:[e.cliToolId," / ",e.permission]})]},"".concat(e.row,"-").concat(e.name)))}),(0,r.jsx)("p",{className:"mt-2 text-xs",children:i.body})]})}),aE=(0,s.memo)(function(e){let{worktreeId:t,logs:n}=e,a=(0,o.c)("schedule"),[l,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),u=(0,s.useCallback)(async e=>{if(l===e){i(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),i(e)}}catch(e){console.error("Failed to fetch log detail:",e)}},[t,l]),m=(0,r.jsx)(aT,{worktreeId:t});return 0===n.length?(0,r.jsxs)("div",{className:"space-y-2",children:[m,(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:a("noLogs")})]}):(0,r.jsxs)("div",{className:"space-y-2","data-testid":"execution-logs-view",children:[m,n.map(e=>(0,r.jsxs)("div",{className:"border border-border rounded bg-surface","data-testid":"execution-log-row","data-warning":e.warning?"true":void 0,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.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(function(e,t){if(t&&"completed"===e)return"text-warning-foreground bg-warning-subtle";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,!!e.warning)),"data-testid":"execution-log-status",children:[e.warning&&(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),a("status.".concat(e.status))]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[aS(e.started_at),aI(e.started_at,e.completed_at)&&(0,r.jsxs)("span",{className:"ml-2",children:["(",aI(e.started_at,e.completed_at),")"]}),null!==e.exit_code&&(0,r.jsxs)("span",{className:"ml-2",children:[a("exitCode"),": ",e.exit_code]})]}),e.warning&&(0,r.jsxs)("div",{className:"text-xs text-warning-foreground mt-1 break-words","data-testid":"execution-log-warning",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠ "}),e.warning]})]}),l===e.id&&c&&(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:c.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:c.result||a("noOutput")})]})]})]},e.id))]})});function aA(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{d:"M13.586 3.586a2 2 0 112.828 2.828l-8.5 8.5a1 1 0 01-.43.26l-3 .857a.5.5 0 01-.617-.618l.857-3a1 1 0 01.26-.43l8.5-8.5z"})})}function aM(){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"w-4 h-4",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M8 2a1 1 0 00-.894.553L6.382 4H3a1 1 0 000 2h.293l.668 9.357A2 2 0 005.956 17h8.088a2 2 0 001.995-1.643L16.707 6H17a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0012 2H8zm1 5a1 1 0 012 0v6a1 1 0 11-2 0V7zm-3 0a1 1 0 011 1v5a1 1 0 11-2 0V8a1 1 0 011-1z",clipRule:"evenodd"})})}let aR=(0,s.memo)(function(e){let{worktreeId:t,className:n="",onInsertToMessage:a,instances:l}=e,i=(0,o.c)("schedule"),c=(0,eF.SC)(),[d,m]=(0,s.useState)([]),[x,f]=(0,s.useState)([]),[h,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(!0),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)("schedules"),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(void 0),[E,A]=(0,s.useState)(void 0),M=(0,s.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();m(t.logs||[])}if(n.ok){let e=await n.json();f(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,s.useEffect)(()=>{M()},[M]);let R=(0,s.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=ax(u).get("Schedules"))?n:[]).find(t=>{var n;return(null!=(n=t[0])?n:"").trim()===e});if(!m)return null;let x=(0,au.I_)(null!=(a=m[3])?a:"claude"),f=(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:x.cliToolId||"claude",enabled:""===f||"true"===f,permission:(null!=(i=m[5])?i:"").trim(),model:null!=(o=x.model)?o:""}}catch(e){return null}},[t]),L=(0,s.useCallback)(()=>{A(void 0),T(void 0),S(!0)},[]),P=(0,s.useCallback)(async e=>{let t=await R(e.name);A(e.name),T(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)},[R]),D=(0,s.useCallback)(async e=>{if(await c({description:i("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 M()}catch(e){console.error("Failed to delete schedule:",e)}},[t,i,M,c]),F=(0,s.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 M()}catch(e){console.error("Failed to toggle schedule:",e)}},[t,M]);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)(u.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:i("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)(u.$n,{variant:"ghost",type:"button",onClick:()=>void M(),className:"ml-2 px-3 py-1 text-sm text-white bg-accent-500 rounded hover:bg-accent-600",children:i("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:[i("tabs.schedules")," (",x.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:[i("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:[i("activeSchedulesTitle")," (",h.length,")"]}),(0,r.jsx)("span",{className:"text-xs text-accent-700 dark:text-accent-300",children:i("activeSchedulesDescription")})]}),0===h.length?(0,r.jsx)("p",{className:"text-xs text-accent-800 dark:text-accent-300",children:i("noActiveSchedules")}):(0,r.jsx)("div",{className:"space-y-2",children:h.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?i("activeState.active"):i("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:i("activeState.executing")})]})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{children:[i("cron"),": ",e.cronExpression||"N/A"]}),(0,r.jsxs)("span",{className:"ml-3",children:[i("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:[i("nextRun"),": ",aS(e.nextRunAt)]})]})]},e.scheduleId))})]}),0===x.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:i("emptyState.title")}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mb-5 max-w-xs",children:i("emptyState.description")}),(0,r.jsxs)(u.$n,{variant:"ghost",type:"button","data-testid":"schedule-empty-cta",onClick:L,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"})}),i("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:i("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:i("noSchedulesStep1")}),(0,r.jsx)("li",{children:i("noSchedulesStep2")}),(0,r.jsx)("li",{children:i("noSchedulesStep3")}),(0,r.jsx)("li",{children:i("noSchedulesStep4")})]})]}):(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 flex items-center justify-end",children:(0,r.jsxs)(u.$n,{variant:"ghost",type:"button","data-testid":"schedule-new-button",onClick:L,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"})}),i("edit.newSchedule")]})}),(0,r.jsx)("div",{className:"space-y-2",children:x.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?i("edit.disable"):i("edit.enable"),title:t?i("edit.disable"):i("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)(u.$n,{variant:"ghost",type:"button","data-testid":"schedule-edit-".concat(e.name),"aria-label":i("edit.edit"),title:i("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)(aA,{})}),(0,r.jsx)(u.$n,{variant:"ghost",type:"button","data-testid":"schedule-delete-".concat(e.name),"aria-label":i("edit.delete"),title:i("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)(aM,{})})]})]}),(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-1",children:[(0,r.jsxs)("span",{children:[i("cron"),": ",e.cron_expression||"N/A"]}),e.last_executed_at&&(0,r.jsxs)("span",{className:"ml-3",children:[i("lastRun"),": ",aS(e.last_executed_at)]})]})]},e.id)})})]})]}):(0,r.jsx)(aE,{worktreeId:t,logs:d})}),(0,r.jsx)(aC,{isOpen:C,worktreeId:t,initialValues:I,originalName:E,onInsertToMessage:a,instances:l,onClose:()=>S(!1),onSaved:()=>{M()}})]})}),aL=(0,s.memo)(function(e){let{worktreeId:t,vibeLocalModel:n,onVibeLocalModelChange:a,vibeLocalContextWindow:l,onVibeLocalContextWindowChange:i}=e,c=(0,o.c)("schedule"),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null!=l?String(l):""),[j,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{y(null!=l?String(l):"")},[l]),(0,s.useEffect)(()=>{let e=!1;return p(!0),fetch("/api/ollama/models").then(e=>e.json()).then(t=>{e||(m(t.models),f(0===t.models.length&&t.error?t.error:null))}).catch(()=>{e||(m([]),f("Failed to fetch models"))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let k=(0,s.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,s.useCallback)(e=>{y(e.target.value)},[]),C=(0,s.useCallback)(async()=>{let e=v.trim(),n=parseInt(e,10),a=""===e||Number.isNaN(n)?null:n,r=null!=l?l: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==i||i(a):y(null!=r?String(r):"")}catch(e){y(null!=r?String(r):"")}finally{w(!1)}}},[v,l,t,i]);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:c("vibeLocalModel")}),h?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.y,{size:"xs",variant:"muted"}),c("loading")]}):x&&0===u.length?(0,r.jsx)("p",{className:"text-xs text-warning-foreground",children:c("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:c("vibeLocalModelDefault")}),u.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:c("vibeLocalContextWindow")}),(0,r.jsx)("input",{type:"number","data-testid":"vibe-local-context-window-input",step:"1",min:Q.vz,max:Q.NL,value:v,onChange:N,onBlur:C,placeholder:c("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"})]})]})}),aP=Object.freeze({agent:null,providerId:null,modelId:null,variant:null}),aD=[{id:"opencode",label:(0,Q.oo)("opencode")}];function aF(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{providerId:e.slice(0,t),modelId:e.slice(t+1)}}let aO=(0,s.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,o.c)("schedule"),[l,i]=(0,s.useState)({}),[c,d]=(0,s.useState)({connected:!1,providers:[],agents:[]}),[m,x]=(0,s.useState)(!0),[f,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return x(!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||(i(null!=(n=t.settings)?n:{}),d(null!=(a=t.catalog)?a:{connected:!1,providers:[],agents:[]}),g(null))}).catch(()=>{e||g(a("opencodeSettingsLoadError"))}).finally(()=>{e||x(!1)}),()=>{e=!0}},[t,a]);let b=(0,s.useCallback)(async(e,n)=>{i(t=>({...t,[e]:n})),h(!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&&i(t=>({...t,[e]:s.settings}))}catch(e){g(a("opencodeSettingsSaveError"))}finally{h(!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")}),m?(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"}),a("loading")]}):(0,r.jsxs)("div",{className:"space-y-4",children:[!c.connected&&(0,r.jsx)("p",{"data-testid":"opencode-settings-offline",className:"text-xs text-muted-foreground",children:a("opencodeSettingsOffline")}),n.map(e=>{var t,s,i,o,d,u;let m=null!=(t=l[e.id])?t:{...aP},x=m.providerId&&m.modelId?"".concat(m.providerId,"/").concat(m.modelId):"",h=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}(c,m),p=null!=(s=null==h?void 0:h.variants)?s:[],g=c.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:f,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!=(o=m.agent)?o:"",disabled:f,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"),c.providers.length>0?(0,r.jsxs)("select",{"data-testid":"opencode-model-select-".concat(e.id),value:x,disabled:f,onChange:t=>{var n,a;let r=aF(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")}),c.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:x,disabled:f,placeholder:a("opencodeModelPlaceholder"),onBlur:t=>{var n,a;let r=aF(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:f,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:f,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"})]}),h&&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")}),f&&(0,r.jsxs)("div",{"data-testid":"opencode-settings-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(u.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})]})]})}),az=(0,s.memo)(function(e){let{worktreeId:t,selectedAgents:n,onSelectedAgentsChange:a,vibeLocalModel:l,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d,maxAgents:m=2,availableAgents:x=Q.XH,persistToServer:f=!0}=e,h=(0,o.c)("schedule"),p=n.length>m?n.slice(0,m):n,[g,b]=(0,s.useState)(()=>new Set(p)),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(g);k.current=g,(0,s.useEffect)(()=>{j||b(new Set(p))},[n,j,m]);let N=g.has("vibe-local"),C=g.has("opencode"),S=(0,s.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(!f){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,f]),I=g.size>=m;return(0,r.jsxs)("div",{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:h("agentSettings")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:h("selectAgents")}),(0,r.jsx)("div",{className:"space-y-3",children:x.map(e=>{let t=g.has(e),n=!t&&I;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)(u.Sc,{"data-testid":"agent-checkbox-".concat(e),"aria-label":(0,Q.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,Q.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)(u.y$,{size:"xs",variant:"muted"}),h("loading")]}),C&&(0,r.jsx)(aO,{worktreeId:t,instances:aD}),N&&(0,r.jsx)(aL,{worktreeId:t,vibeLocalModel:l,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d})]})});function a_(e){return"".concat("commandmate:worktree:mobileInstances:").concat(e)}function aB(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 aV=n(49476),aU=n(52056),aH=n(65506),aK=n(7620),aW=n(50803),aq=n(20017),a$=n(18085),aG=n(6191),aJ=n(27937),aY=n(41108),aQ=n(95342),aX=n(63001),aZ=n(55449);let a0="/api/worktrees/apply-default-agents";var a1=n(18848);let a2=["noteInstanceFlag","noteWaitOnPrompt","noteRespondNumber"];function a4(e){let{worktreeId:t,instance:n,isOpen:a,onClose:l}=e,i=(0,o.c)("worktree"),[c,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[y,j]=(0,s.useState)(!1),[w,k]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!a)return;let e=!1;return u(!0),x(!1),v(null),j(!1),(async()=>{try{let[a,r]=await Promise.all([fetch("/api/worktrees/".concat(t,"/cli-reference")),fetch("/api/worktrees/".concat(t,"/resolve-target?instance=").concat(encodeURIComponent(n.id)))]);if(e)return;if(!a.ok||!r.ok)return void x(!0);let[s,l]=await Promise.all([a.json(),r.json()]);if(e)return;h(s),g(l)}catch(t){e||x(!0)}finally{e||u(!1)}})(),()=>{e=!0}},[a,t,n.id,w]);let N=f&&p?(0,a1.kj)({binary:f.binary,worktreeId:f.worktreeId,instanceId:p.instanceId,portPrefix:f.portPrefix,messagePlaceholder:i("cliCommands.messagePlaceholder")}):null,C=(0,s.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(t),v(e),j(!1)}catch(e){console.error("[InstanceCliCommandsModal] clipboard write failed:",e),v(null),j(!0)}},[]);return(0,r.jsx)(tN.a,{isOpen:a,onClose:l,size:"md",title:i("cliCommands.title",{alias:n.alias}),children:(0,r.jsxs)("div",{className:"space-y-4","data-testid":"cli-commands-panel-".concat(n.id),children:[c&&(0,r.jsxs)("div",{"data-testid":"cli-commands-loading",className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.y,{size:"xs",variant:"muted"}),i("cliCommands.loading")]}),m&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{"data-testid":"cli-commands-error",className:"text-xs text-danger-foreground",children:i("cliCommands.loadError")}),(0,r.jsx)("button",{type:"button","data-testid":"cli-commands-retry",onClick:()=>k(e=>e+1),className:"text-xs font-medium px-2 py-1 rounded-md border border-input text-foreground hover:bg-muted",children:i("cliCommands.retry")})]}),N&&p&&f&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{"data-testid":"cli-commands-target",className:"text-xs text-muted-foreground break-words",children:i("cliCommands.target",{instance:p.instanceId,tool:(0,Q.oo)(p.cliToolId),stage:i("cliCommands.resolvedBy.".concat(p.resolvedBy))})}),p.conflict&&(0,r.jsxs)("p",{"data-testid":"cli-commands-conflict",className:"flex items-start gap-1 text-xs text-warning",children:[(0,r.jsx)(aU.A,{className:"w-3 h-3 mt-0.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:i("cliCommands.conflict",{instance:p.conflict.instanceId,roster:(0,Q.oo)(p.conflict.rosterCliTool),requested:(0,Q.oo)(p.conflict.requestedCliTool)})})]}),(0,r.jsx)("ul",{className:"space-y-3",children:a1.wx.map(e=>(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:i("cliCommands.commandLabel.".concat(e))}),(0,r.jsxs)("button",{type:"button","data-testid":"cli-commands-copy-".concat(e),"aria-label":i("cliCommands.copy"),title:i("cliCommands.copy"),onClick:()=>void C(e,N[e]),className:"flex items-center gap-1 shrink-0 text-xs px-2 py-1 rounded-md border border-input text-muted-foreground hover:text-foreground hover:bg-muted",children:[b===e?(0,r.jsx)(eV.A,{className:"w-3 h-3","aria-hidden":"true"}):(0,r.jsx)(eU.A,{className:"w-3 h-3","aria-hidden":"true"}),b===e?i("cliCommands.copied"):i("cliCommands.copy")]})]}),(0,r.jsx)("code",{"data-testid":"cli-commands-command-".concat(e),className:"block whitespace-pre-wrap break-all rounded-md bg-terminal-surface px-2 py-1.5 font-mono text-xs text-terminal-foreground",children:N[e]}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("cliCommands.commandDescription.".concat(e))})]},e))}),y&&(0,r.jsx)("p",{"data-testid":"cli-commands-copy-error",className:"text-xs text-danger-foreground",children:i("cliCommands.copyFailed")}),null!==f.portPrefix&&(0,r.jsx)("p",{"data-testid":"cli-commands-port-hint",className:"text-xs text-muted-foreground",children:i("cliCommands.portHint",{port:f.portPrefix})}),(0,r.jsxs)("div",{className:"rounded-md border border-border bg-surface-2 p-3",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:i("cliCommands.notesTitle")}),(0,r.jsx)("ul",{className:"mt-1 space-y-1",children:a2.map(e=>(0,r.jsx)("li",{"data-testid":"cli-commands-".concat(e),className:"text-xs text-muted-foreground",children:i("cliCommands.".concat(e))},e))})]})]})]})})}var a5=n(58165),a3=n(45573);function a6(e){return"prompt"===e.tone?"text-warning":"text-muted-foreground"}let a9=(0,s.memo)(function(e){var t;let{worktreeId:n,instances:a,onInstancesChange:l,vibeLocalModel:i,onVibeLocalModelChange:c,vibeLocalContextWindow:u,onVibeLocalContextWindowChange:m,modelByInstance:x,sourceByInstance:f,composerTargetInstanceId:h,className:p=""}=e,g=(0,o.c)("schedule"),b=(0,to.Ym)(),{showToast:v}=(0,tu.dj)(),y=(0,o.c)("common"),j=(0,o.c)("worktree"),w=(0,eF.SC)(),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(null),[I,T]=(0,s.useState)({}),[E,A]=(0,s.useState)(Q.XH[0]),[M,R]=(0,s.useState)(null),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(!1),[O,z]=(0,s.useState)(null),_=(0,s.useCallback)(async e=>{let t=a3.yW["ja"===b?"ja":"en"];if((null!=h?h:(0,a3.xk)())===e.id)return void v(t.self,"info");let a=await (0,a3.P0)(n,e,b);if(null===a)return void v(t.failed,"error");let r=(0,a3.oQ)(a);v(r?t.inserted:t.noComposer,r?"success":"error")},[h,b,v,n]),B=function(e,t,n){let[a,r]=(0,s.useState)({}),l=t.some(e=>"opencode"===e.cliTool);return(0,s.useEffect)(()=>{if(n)return;if(!l)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 s=setInterval(()=>void a(),1e4);return()=>{t=!0,clearInterval(s)}},[e,l,n]),null!=n?n:a}(n,a,f),V=(0,aY.UI)(n),U=(0,s.useCallback)(e=>{var t,r;return e.worktreeId!==n?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(t=a.find(t=>t.id===e.instanceId))?void 0:t.alias)?r:e.instanceId},[a,n]),H=a.length>=Q.Ab,K=a.length<=1,W=a.some(e=>"vibe-local"===e.cliTool),q=(0,s.useMemo)(()=>{let e=new Set,t=[];for(let n of a)e.has(n.cliTool)||(e.add(n.cliTool),t.push(n.cliTool));return t},[a]),$=function(e,t){let[n,a]=(0,s.useState)(null),[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(null),g=(0,s.useCallback)(e=>{l("string"==typeof(null==e?void 0:e.repositoryName)?e.repositoryName:null),o((null==e?void 0:e.repoDeclaresAgents)===!0)},[]),b=(0,s.useCallback)(async()=>{d(!0);try{let t=await fetch("".concat(a0,"?worktreeId=").concat(encodeURIComponent(e)));if(!t.ok)throw Error(String(t.status));let n=await t.json(),r=null==n?void 0:n.eligible;if("number"!=typeof r||!Number.isFinite(r))throw Error("unexpected body");return a(r),g(n),p(null),r}catch(e){return a(null),p("count"),null}finally{d(!1)}},[e,g]),v=(0,s.useCallback)(async()=>{d(!0),p(null),m(!1),f(null);try{let e=await fetch(aZ.zk,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:t})}),n=await e.json().catch(()=>null),a=null==n?void 0:n.defaultSelectedAgents;if(!e.ok||!Array.isArray(a))return p("save"),!1;return(0,aZ.IK)(a),m(!0),!0}catch(e){return p("save"),!1}finally{d(!1)}},[t]),y=(0,s.useCallback)(async()=>{d(!0),p(null),m(!1);try{let n=await fetch(a0,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:e,agents:t})}),r=await n.json().catch(()=>null),s=null==r?void 0:r.updated;if(!n.ok||"number"!=typeof s||!Number.isFinite(s))return p("apply"),null;f(s),g(r);let l=r.eligible;return"number"==typeof l&&Number.isFinite(l)&&a(l),s}catch(e){return p("apply"),null}finally{d(!1)}},[e,t,g]);return{eligible:n,repositoryName:r,repoDeclaresAgents:i,busy:c,savedDefault:u,appliedCount:x,error:h,refreshEligible:b,saveAsDefault:v,applyToUnchanged:y}}(n,q),J=q.length>=aX.eu&&q.length<=aX.Wj,Y=k||$.busy,X=J&&!$.repoDeclaresAgents&&null!==$.eligible&&$.eligible>0,ee="count"===$.error?g("agentDefaultsCountError"):"save"===$.error?g("agentDefaultsSaveError"):"apply"===$.error?g("agentDefaultsApplyError"):null,et=(0,s.useCallback)(()=>{let e=!D;F(e),e&&$.refreshEligible()},[D,$]),en=(0,s.useCallback)(async()=>{if(!X)return;let e=await $.refreshEligible();null!==e&&0!==e&&await w({description:g("agentDefaultsApplyConfirm",{count:e,agents:q.map(e=>(0,Q.oo)(e)).join(", ")})})&&await $.applyToUnchanged()},[X,$,w,g,q]),ea=(0,s.useCallback)(async e=>{let t=e.map((e,t)=>({...e,order:t}));N(!0),S(null);try{(await fetch("/api/worktrees/".concat(n),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentInstances:t})})).ok?l(t):S(g("agentInstanceSaveError"))}catch(e){S(g("agentInstanceSaveError"))}finally{N(!1)}},[n,l,g]),er=(0,s.useCallback)(()=>{if(a.length>=Q.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)}(E,a);ea([...a,{id:e,cliTool:E,alias:function(e,t){let n=(0,Q.oo)(e);if(t===e)return n;let a=t.slice(e.length+1);return a?"".concat(n," ").concat(a):n}(E,e),order:a.length}])},[E,a,ea]),es=(0,s.useCallback)(async e=>{var t;if(a.length<=1)return;let n=a.find(t=>t.id===e);await w({description:y("confirmDelete",{name:null!=(t=null==n?void 0:n.alias)?t:""}),variant:"danger"})&&ea(a.filter(t=>t.id!==e))},[a,ea,w,y]),el=(0,s.useCallback)((e,t)=>{let n=e+t;if(n<0||n>=a.length)return;let r=[...a];[r[e],r[n]]=[r[n],r[e]],ea(r)},[a,ea]),ei=(0,s.useCallback)((e,t)=>{T(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n});let n=a.find(t=>t.id===e);n&&t!==n.alias&&ea(a.map(n=>n.id===e?{...n,alias:t}:n))},[a,ea]),eo=(0,s.useCallback)((e,t)=>{if(e===t||e<0||t<0||e>=a.length||t>=a.length)return;let n=[...a],[r]=n.splice(e,1);n.splice(t,0,r),ea(n)},[a,ea]),ec=["flex flex-col p-4",p?"overflow-y-auto":"",p].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:ec,"data-testid":"agent-instances-pane",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-foreground mb-1",children:g("agentInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:g("agentInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-2",children:a.map((e,t)=>{var s,l;let i=e.id in I?I[e.id]:e.alias,o=M===t,c=null!=(s=null==x?void 0:x[e.id])?s:null,d=null==B?void 0:B[e.id],u=lh(d,j),m=!!(l=d)&&("sse"!==l.kind||"live"!==l.liveness),f=(0,aQ.g)({owed:V.owedBy(e.id),awaiting:V.awaitedBy(e.id),aliasOf:U}),p=h===e.id;return(0,r.jsxs)("div",{"data-testid":"agent-instance-row-".concat(e.id),draggable:!0,onDragStart:()=>R(t),onDragOver:e=>e.preventDefault(),onDrop:()=>{null!==M&&eo(M,t),R(null)},onDragEnd:()=>R(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(o?"opacity-50":""),children:[(0,r.jsx)("span",{className:"cursor-grab text-muted-foreground shrink-0","aria-hidden":"true",children:(0,r.jsx)(aV.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":g("agentInstanceAliasLabel"),value:i,maxLength:Q.pQ,disabled:k,placeholder:g("agentInstanceAliasPlaceholder"),onChange:t=>T(n=>({...n,[e.id]:t.target.value})),onBlur:t=>ei(e.id,t.target.value),onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||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)(nh.nR,{content:(0,Q.oo)(e.cliTool),className:"mt-0.5 block truncate text-xs text-muted-foreground"}),c&&(0,r.jsx)("span",{"data-testid":"agent-instance-model-".concat(e.id),title:j("agentModel.modelLabel",{model:c}),className:"mt-0.5 block truncate text-xs text-muted-foreground",children:c}),u&&(0,r.jsxs)("span",{"data-testid":"agent-instance-source-".concat(e.id),title:j(m?"agentSource.degradedTitle":"agentSource.healthyTitle"),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(m?"text-warning":"text-muted-foreground"),children:[m?(0,r.jsx)(aU.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}):(0,r.jsx)(aH.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:u})]}),f.map(t=>(0,r.jsxs)("span",{"data-testid":"agent-instance-relay-".concat(t.tone,"-").concat(e.id),title:j("relay.".concat(t.titleKey)),className:"mt-0.5 flex items-center gap-1 truncate text-xs ".concat(a6(t)),children:[(0,r.jsx)(aK.A,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{className:"truncate",children:j("relay.".concat(t.key),t.params)})]},t.key))]}),(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-cli-".concat(e.id),"aria-label":j("cliCommands.open"),title:j("cliCommands.open"),onClick:()=>z(e.id),className:"shrink-0 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted",children:(0,r.jsx)(aW.A,{className:"w-4 h-4"})}),O===e.id&&(0,r.jsx)(a4,{worktreeId:n,instance:e,isOpen:!0,onClose:()=>z(null)}),(0,r.jsxs)(Z.rI,{children:[(0,r.jsx)(Z.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"agent-instance-menu-".concat(e.id),"aria-label":g("agentInstanceActions"),title:g("agentInstanceActions"),disabled:k,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)(aq.A,{className:"w-4 h-4"})})}),(0,r.jsxs)(Z.SQ,{align:"end",children:[!p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(Z._2,{"data-testid":"agent-instance-delegate-".concat(e.id),onSelect:()=>{_(e)},children:[(0,r.jsx)(a$.A,{className:"w-4 h-4"}),a3.yW["ja"===b?"ja":"en"].menuItem]}),(0,r.jsx)(Z.mB,{})]}),(0,r.jsxs)(Z._2,{"data-testid":"agent-instance-move-up-".concat(e.id),disabled:0===t,onSelect:()=>el(t,-1),children:[(0,r.jsx)(nU.A,{className:"w-4 h-4"}),g("agentInstanceMoveUp")]}),(0,r.jsxs)(Z._2,{"data-testid":"agent-instance-move-down-".concat(e.id),disabled:t===a.length-1,onSelect:()=>el(t,1),children:[(0,r.jsx)(G.A,{className:"w-4 h-4"}),g("agentInstanceMoveDown")]}),(0,r.jsx)(Z.mB,{}),(0,r.jsxs)(Z._2,{"data-testid":"agent-instance-delete-".concat(e.id),disabled:K,onSelect:()=>{es(e.id)},className:"text-danger-foreground focus:text-danger-foreground",children:[(0,r.jsx)(nd.A,{className:"w-4 h-4"}),g("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":g("agentInstanceBaseTool"),value:E,disabled:k||H,onChange:e=>A(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:Q.XH.map(e=>(0,r.jsx)("option",{value:e,children:(0,Q.oo)(e)},e))}),(0,r.jsxs)("button",{type:"button","data-testid":"agent-instance-add",disabled:k||H,onClick:er,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)(aG.A,{className:"w-4 h-4"}),g("agentInstanceAdd")]})]}),H&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("agentInstanceMax",{max:Q.Ab})}),K&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("agentInstanceMin",{min:1})}),k&&(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)(d.y,{size:"xs",variant:"muted"}),g("loading")]}),C&&(0,r.jsx)("p",{"data-testid":"agent-instances-error",className:"mt-3 text-xs text-danger-foreground",children:C}),W&&(0,r.jsx)(aL,{worktreeId:n,vibeLocalModel:i,onVibeLocalModelChange:c,vibeLocalContextWindow:u,onVibeLocalContextWindowChange:m}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-defaults-toggle","aria-expanded":D,onClick:et,className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[D?(0,r.jsx)(G.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(aJ.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),g("agentDefaults")]}),D&&(0,r.jsxs)("div",{className:"mt-2 space-y-3","data-testid":"agent-defaults-section",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("agentDefaultsDescription")}),(0,r.jsx)("p",{"data-testid":"agent-defaults-roster",className:"text-xs font-medium text-foreground break-words",children:q.map(e=>(0,Q.oo)(e)).join(" → ")}),!J&&(0,r.jsx)("p",{"data-testid":"agent-defaults-invalid",className:"text-xs text-warning-foreground",children:g("agentDefaultsInvalidRoster",{min:aX.eu,max:aX.Wj})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-set-default",disabled:Y||!J,onClick:()=>{$.saveAsDefault()},className:"w-full 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",children:g("agentDefaultsSetDefault")}),(0,r.jsxs)("div",{className:"space-y-1",children:[$.repositoryName&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repository","data-repository":$.repositoryName,className:"text-xs text-muted-foreground",children:g("agentDefaultsRepositoryLabel",{repository:$.repositoryName})}),$.repoDeclaresAgents&&(0,r.jsx)("p",{"data-testid":"agent-defaults-repo-declared",className:"text-xs text-warning-foreground",children:g("agentDefaultsRepoDeclared")}),!$.repoDeclaresAgents&&(0,r.jsx)("span",{"data-testid":"agent-defaults-eligible","data-count":null!=(t=$.eligible)?t:void 0,className:"block text-xs text-muted-foreground",children:null===$.eligible?g("agentDefaultsEligibleUnknown"):g("agentDefaultsEligible",{count:$.eligible})}),(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-apply",disabled:Y||!X,onClick:()=>{en()},className:"w-full text-sm font-medium px-3 py-2 rounded-md border border-border bg-surface text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:g("agentDefaultsApply")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:g("agentDefaultsApplyScope")})]}),$.savedDefault&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-saved",className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(eV.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsSaved")]}),null!==$.appliedCount&&(0,r.jsxs)("p",{"data-testid":"agent-defaults-applied","data-count":$.appliedCount,className:"flex items-center gap-1 text-xs text-success-foreground",children:[(0,r.jsx)(eV.A,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),g("agentDefaultsApplied",{count:$.appliedCount})]}),ee&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{"data-testid":"agent-defaults-error",className:"text-xs text-danger-foreground",children:ee}),"count"===$.error&&(0,r.jsx)("button",{type:"button","data-testid":"agent-defaults-retry",disabled:Y,onClick:()=>{$.refreshEligible()},className:"text-xs font-medium underline text-accent-700 dark:text-accent-300 disabled:opacity-40 disabled:cursor-not-allowed",children:g("agentDefaultsRetry")})]})]})]}),(0,r.jsxs)("div",{className:"mt-6 border-t border-border pt-4",children:[(0,r.jsxs)("button",{type:"button","data-testid":"agent-updates-toggle","aria-expanded":L,onClick:()=>P(e=>!e),className:"flex w-full items-center gap-1 text-left text-sm font-semibold text-foreground hover:text-accent-600 dark:hover:text-accent-400",children:[L?(0,r.jsx)(G.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):(0,r.jsx)(aJ.A,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),y("agentUpdates.title")]}),L&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(a5.uN,{worktreeId:n,instances:a.map(e=>({id:e.id,cliTool:e.cliTool,alias:e.alias})),variant:"plain"})})]})]})}),a8=(0,s.memo)(function(e){let{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:l,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d,visibleInstanceIds:m,onToggleInstanceVisible:x,modelByInstance:f,sourceByInstance:h,composerTargetInstanceId:p}=e,g=(0,o.c)("schedule"),b=(0,o.c)("worktree"),v=new Set(m),y=m.length<=1,j=(0,aY.UI)(t),w=(0,s.useCallback)(e=>{var a,r;return e.worktreeId!==t?"".concat(e.instanceId," @ ").concat(e.worktreeId):null!=(r=null==(a=n.find(t=>t.id===e.instanceId))?void 0:a.alias)?r:e.instanceId},[n,t]);return(0,r.jsxs)("div",{"data-testid":"mobile-agent-instances-pane",children:[(0,r.jsx)(a9,{worktreeId:t,instances:n,onInstancesChange:a,vibeLocalModel:l,onVibeLocalModelChange:i,vibeLocalContextWindow:c,onVibeLocalContextWindowChange:d,modelByInstance:f,sourceByInstance:h,composerTargetInstanceId:p}),(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:g("mobileVisibleInstances")}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:g("mobileVisibleInstancesDescription")}),(0,r.jsx)("div",{className:"space-y-1",children:n.map(e=>{var t;let n=v.has(e.id),a=n&&y,s=null!=(t=null==f?void 0:f[e.id])?t:null,l=(0,aQ.g)({owed:j.owedBy(e.id),awaiting:j.awaitedBy(e.id),aliasOf:w});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)(u.Sc,{"data-testid":"mobile-visible-instance-toggle-".concat(e.id),checked:n,disabled:a,onCheckedChange:()=>x(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,Q.sw)(e)}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:(0,Q.oo)(e.cliTool)}),s&&(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-model-".concat(e.id),title:b("agentModel.modelLabel",{model:s}),className:"block text-xs text-muted-foreground truncate",children:s}),l.map(t=>(0,r.jsx)("span",{"data-testid":"mobile-visible-instance-relay-".concat(t.tone,"-").concat(e.id),title:b("relay.".concat(t.titleKey)),className:"block text-xs truncate ".concat(a6(t)),children:b("relay.".concat(t.key),t.params)},t.key))]})]},e.id)})}),y&&(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:g("mobileVisibleInstanceMin")})]})]})}),a7=Array.from({length:Math.floor(104)+1},(e,t)=>3e5+3e5*t);var re=n(76351);function rt(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 rn="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 ra(e){let{isOpen:t,worktreeId:n,instances:a,onClose:l,onSaved:i}=e,c=(0,o.c)("schedule"),d=(0,nF.a)(),u=(0,s.useMemo)(()=>a&&a.length>0?a:(0,Q.lu)([...Q.XH]),[a]),[m,x]=(0,s.useState)(""),[f,h]=(0,s.useState)(()=>{var e,t;return null!=(t=null==(e=u[0])?void 0:e.id)?t:Q.XH[0]}),[p,g]=(0,s.useState)(a7[0]),[b,v]=(0,s.useState)(!1),[y,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{var e,n;t&&(x(""),g(a7[0]),j(null),v(!1),h(null!=(n=null==(e=u[0])?void 0:e.id)?n:Q.XH[0]))},[t,u]),(0,s.useEffect)(()=>{if(!u.some(e=>e.id===f)){var e,t;h(null!=(t=null==(e=u[0])?void 0:e.id)?t:Q.XH[0])}},[u,f]);let w=m.trim().length>0&&!b,k=(0,s.useCallback)(async()=>{if(!m.trim()||b)return;let e=u.find(e=>e.id===f);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();i(),"session_not_running"===e.warning?(j("session_not_running"),x("")):l()}}catch(e){}finally{v(!1)}}},[n,u,f,m,p,b,i,l]),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:c("timer.agent")}),(0,r.jsx)("select",{id:"timer-instance-select","data-testid":"timer-instance-select",value:f,onChange:e=>h(e.target.value),className:rn,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:c("timer.message")}),(0,r.jsx)("textarea",{id:"timer-message-input","data-testid":"timer-message-input",value:m,onChange:e=>x(e.target.value),placeholder:c("timer.message"),maxLength:1e4,rows:3,className:"".concat(rn," 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:c("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:rn,children:a7.map(e=>(0,r.jsx)("option",{value:e,children:rt(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:c("timer.sessionWarning")})]}),C=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:l,className:"px-4 py-2 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors",children:c("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:c("timer.register")})]}),S=c("timer.titleCreate");return d?(0,r.jsx)(n4,{isOpen:t,onClose:l,title:S,footer:C,children:N}):(0,r.jsx)(tN.a,{isOpen:t,onClose:l,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 rr(e){return new Date(e).toLocaleString()}function rs(e){var t,n;let{timer:a,instances:s,onClose:l}=e,i=(0,o.c)("schedule"),c=(0,nF.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:rt(a.delayMs)}),(0,r.jsx)(u,{label:i("timer.scheduledTime"),children:rr(a.scheduledSendTime)}),(0,r.jsx)(u,{label:i("timer.createdTime"),children:rr(a.createdAt)}),null!==a.sentAt&&(0,r.jsx)(u,{label:i("timer.sentTime"),children:rr(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})]})]}),x=(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")})}),f=i("timer.detailTitle");return c?(0,r.jsx)(n4,{isOpen:!0,title:f,onClose:l,footer:x,children:m}):(0,r.jsx)(tN.a,{isOpen:!0,title:f,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:x})]})})}let rl=(0,s.memo)(function(e){let{worktreeId:t,instances:n}=e,a=(0,o.c)("schedule"),l=(0,eF.SC)(),i=(0,s.useMemo)(()=>n&&n.length>0?n:(0,Q.lu)([...Q.XH]),[n]),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[,g]=(0,s.useState)(0),b=(0,s.useRef)(null),v=(0,s.useRef)(null),j=(0,s.useRef)(null),w=(0,s.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,s.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,s.useEffect)(()=>{function e(){return w(),b.current=setInterval(()=>{w()},1e4),v.current=setInterval(()=>{g(e=>e+1)},1e3),t}function t(){b.current&&clearInterval(b.current),v.current&&clearInterval(v.current),b.current=null,v.current=null}e();let n=()=>{"hidden"===document.visibilityState?t():e()};return document.addEventListener("visibilitychange",n),()=>{t(),document.removeEventListener("visibilitychange",n)}},[w]);let N=(0,s.useCallback)(async e=>{try{(await fetch("/api/worktrees/".concat(t,"/timers?timerId=").concat(e),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w]),C=(0,s.useCallback)(async()=>{if(await l({description:a("timer.clearConfirm"),variant:"danger"}))try{(await fetch("/api/worktrees/".concat(t,"/timers/history"),{method:"DELETE"})).ok&&w()}catch(e){}},[t,w,a,l]),S=c.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===c.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)(y.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:()=>f(!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)(aG.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:()=>f(!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)(aG.A,{className:"w-3.5 h-3.5"}),a("timer.newTimer")]})]}),c.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=i.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:(0,re.$B)(e.scheduledSendTime)}),(0,r.jsx)("span",{className:"text-muted-foreground",children:rt(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")}),c.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)(ra,{isOpen:x,worktreeId:t,instances:n,onClose:()=>f(!1),onSaved:()=>{w()}}),(0,r.jsx)(rs,{timer:h,instances:i,onClose:()=>p(null)})]})});var ri=n(35626),ro=n(99648);let rc={verified:"skills.compatibility.axisOutcome.verified",unsupported:"skills.compatibility.axisOutcome.unsupported",unknown:"skills.compatibility.axisOutcome.unknown"},rd={mechanical:"skills.compatibility.evidenceKind.mechanical",self_report:"skills.compatibility.evidenceKind.selfReport",not_measured:"skills.compatibility.evidenceKind.notMeasured"},ru={outcome:"unknown",evidenceKind:"not_measured",labelKey:rc.unknown,evidenceKindKey:rd.not_measured,limitationKey:null},rm={SESSION_RESTART:"skills.compatibility.reload.sessionRestart",SESSION_RESTART_NO_SLASH:"skills.compatibility.reload.sessionRestartNoSlash",UNKNOWN:"skills.compatibility.reload.unknown"},rx={NO_SLASH_COMMAND:"skills.compatibility.limitation.noSlashCommand"};function rf(e){return{agent:e,discoveryRoots:[],discovery:ru,invocation:ru,testedVersion:null,testedDate:null,evidenceSource:null,reloadKey:rm.UNKNOWN,skipReasonKey:"skills.compatibility.skipReason.notMeasured"}}ro.td,rc.verified,rd.mechanical,rc.verified,rd.mechanical,rm.SESSION_RESTART,ro.Co,rc.verified,rd.self_report,rc.unsupported,rd.mechanical,rx.NO_SLASH_COMMAND,rm.SESSION_RESTART_NO_SLASH,rf("gemini"),rf("vibe-local"),ro.Co,ro.td,rc.verified,rd.mechanical,rc.verified,rd.mechanical,rx.NO_SLASH_COMMAND,rm.SESSION_RESTART,ro.Co,ro.td,rc.verified,rd.mechanical,rc.verified,rd.mechanical,rm.UNKNOWN,rf("antigravity"),ro.Co,rc.verified,rd.mechanical,rc.verified,rd.mechanical,rm.SESSION_RESTART;let rh={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"};rh.SATISFIED,rh.HOST_VERSION_OUT_OF_RANGE,rh.HOST_VERSION_UNKNOWN,rh.RANGE_UNSUPPORTED;let rp={CONFIRMED:"SKILL_AGENT_EVIDENCE_CONFIRMED",RESTRICTED:"SKILL_AGENT_EVIDENCE_RESTRICTED",STALE_DECLARATION:"SKILL_AGENT_EVIDENCE_STALE_DECLARATION",UNVERIFIED:"SKILL_AGENT_EVIDENCE_UNVERIFIED"};rp.CONFIRMED,rp.RESTRICTED,rp.STALE_DECLARATION,rp.UNVERIFIED;let rg=/^(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 rb(e){if("string"!=typeof e||e.length>64)return null;let t=rg.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 rv={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 ry(e,t){let n=function(e,t){let n=rb(e),a=rb(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}rv.UP_TO_DATE,rv.HIGHEST_COMPATIBLE,rv.LATEST_UNVERIFIED,rv.NONE_COMPATIBLE,rv.INSTALLED_VERSION_INVALID,rv.RANGE_UNSUPPORTED;var rj=n(75333),rw=n(34380),rk=n(37381),rN=n(95584),rC=n(80130);let rS={open:!1,selectedVersion:null,busy:!1,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applying:!1,applyResult:null,applyFailure:null};function rI(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 rT(e){var t;let{skillId:n,skillName:a,worktreeId:l,installedVersion:i,versions:c}=e,d=(0,o.c)("skills"),m=(0,s.useMemo)(()=>c.filter(e=>ry(e.version,i)),[c,i]),x=(0,s.useMemo)(()=>{var e,t,n;return null!=(n=null==(e=null!=(t=m.find(e=>"compatible"===e.compatibility.commandmate.status))?t:m[0])?void 0:e.version)?n:null},[m]),[f,h]=(0,s.useState)(rS),p=(0,s.useCallback)(()=>{h({...rS,open:!0,selectedVersion:x})},[x]),g=(0,s.useCallback)(()=>{h(rS)},[]),b=(0,s.useCallback)(async()=>{let e=f.selectedVersion;if(!e)return;h(e=>({...e,busy:!0,plan:null,failure:null,riskAcknowledged:!1,riskIncreaseAcknowledged:!1,applyResult:null,applyFailure:null}));let t=await (0,rC.Sw)(l,n,{version:e});h(e=>({...e,busy:!1,plan:t.ok?t.data.plan:null,failure:t.ok?null:t.failure}))},[n,f.selectedVersion,l]),v=(0,s.useCallback)(async()=>{var e;let t=f.plan;if(!t||!t.updatable)return;h(e=>({...e,applying:!0,applyFailure:null}));let a=await (0,rC.h2)(l,n,{planToken:t.token,version:t.update.toVersion,acknowledgeRisk:f.riskAcknowledged,acknowledgeRiskIncrease:f.riskIncreaseAcknowledged,idempotencyKey:(e=t.token,"skill-update-".concat(e))});h(e=>({...e,applying:!1,applyResult:a.ok?a.data:null,applyFailure:a.ok?null:a.failure}))},[n,f.plan,f.riskAcknowledged,f.riskIncreaseAcknowledged,l]);if(0===m.length)return(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"skill-update-uptodate",children:d("update.upToDate",{version:i})});let y=f.plan,j=f.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)(u.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:i,to:m[0].version})}),(0,r.jsx)(u.$n,{variant:"secondary",size:"sm",onClick:p,"data-testid":"skill-update-trigger",children:d("update.open")})]}),(0,r.jsx)(u.Jh,{isOpen:f.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:i})}),(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=f.selectedVersion)?t:"",onChange:e=>h(t=>({...t,selectedVersion:e.target.value,plan:null,failure:null})),disabled:f.busy,"data-testid":"skill-update-version-select",children:m.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(rN.OV[e.compatibility.commandmate.status])):""]},e.version))})]}),(0,r.jsx)(u.$n,{variant:"primary",disabled:f.busy||!f.selectedVersion,onClick:b,"data-testid":"skill-update-build",children:f.busy?d("update.building"):d("update.build")}),f.failure&&(0,r.jsxs)(rk.u,{tone:"danger","data-testid":"skill-update-error",children:[(0,r.jsx)("p",{children:d((0,rN.FW)(f.failure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:f.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)(rk.u,{tone:y.updatable?"info":"warning","data-testid":"skill-update-next-action",children:d((0,rN.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,rN.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)(rj.qW,{risk:y.securityDiff.risk.from.effective}),(0,r.jsx)("span",{"aria-hidden":"true",children:"→"}),(0,r.jsx)(rj.qW,{risk:y.securityDiff.risk.to.effective})]}),y.riskIncreased&&y.riskIncreaseMessageKey&&(0,r.jsx)(rk.u,{tone:"danger","data-testid":"skill-update-risk-increase",children:d((0,rN.e5)(y.riskIncreaseMessageKey))}),y.requiresRiskAcknowledgement&&y.riskAcknowledgementMessageKey&&(0,r.jsx)(rk.u,{tone:"warning","data-testid":"skill-update-high-risk",children:d((0,rN.e5)(y.riskAcknowledgementMessageKey))}),y.updatable&&!f.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:f.riskAcknowledged,onChange:e=>h(t=>({...t,riskAcknowledged:e.target.checked})),"data-testid":"skill-update-ack-risk"}),d("update.ackRisk")]}),y.updatable&&!f.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:f.riskIncreaseAcknowledged,onChange:e=>h(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=rN.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=rN.z2[e])?t:"plan.permissionsNone")},e)})})]}),(0,r.jsx)(rI,{heading:d("update.scriptsAdded"),paths:y.securityDiff.scripts.added,testid:"skill-update-scripts-added"}),(0,r.jsx)(rI,{heading:d("update.scriptsRemoved"),paths:y.securityDiff.scripts.removed,testid:"skill-update-scripts-removed"}),(0,r.jsx)(rI,{heading:d("update.executablesAdded"),paths:y.securityDiff.executables.added,testid:"skill-update-executables-added"}),(0,r.jsx)(rI,{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)(u.Ex,{variant:null!=(t=rN.JD[e.change])?t:"gray",children:d(null!=(n=rN.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&&!f.applyResult&&(0,r.jsx)(u.$n,{variant:"primary",disabled:f.applying||y.requiresRiskAcknowledgement&&!f.riskAcknowledged||y.riskIncreased&&!f.riskIncreaseAcknowledged,onClick:v,"data-testid":"skill-update-apply",children:f.applying?d("update.applying"):d("update.apply")}),f.applyFailure&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"skill-update-apply-error",children:[(0,r.jsxs)(rk.u,{tone:"danger",children:[(0,r.jsx)("p",{children:d((0,rN.FW)(f.applyFailure.code))}),(0,r.jsx)("p",{className:"mt-1 break-words",children:d("state.errorCode",{code:f.applyFailure.code})})]}),f.applyFailure.nextActionKey&&(0,r.jsx)(rk.u,{tone:"warning",children:d((0,rN.e5)(f.applyFailure.nextActionKey))}),f.applyFailure.blockers&&f.applyFailure.blockers.length>0&&(0,r.jsx)("ul",{className:"space-y-1","data-testid":"skill-update-apply-error-blockers",children:f.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,rN.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)(rk.u,{tone:"succeeded"===j.operation.result?"info":"warning","data-testid":"skill-update-result-next-action",children:d((0,rN.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,rN.e5)(e.messageKey),{agent:(0,Q.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,rN.e5)(j.rollback.messageKey),{version:j.rollback.backup.fromVersion})})]})]})]})})]})}let rE={status:"loading",skills:[],failure:null},rA={status:"loading",skills:[],failure:null};function rM(e){var t,n,a,l,i,c,d,m;let{worktreeId:x,className:f=""}=e,h=(0,o.c)("skills"),[p,g]=(0,s.useState)(rE),[b,v]=(0,s.useState)(rA),[y,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(0),[N,C]=(0,s.useState)(0);(0,s.useEffect)(()=>{let e=new AbortController;return g(rE),(0,rC.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,s.useEffect)(()=>{let e=new AbortController;return v(rA),(0,rC.Gj)(x,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()},[x,N]);let S=(0,s.useMemo)(()=>new Map(b.skills.map(e=>[e.skillId,e.version])),[b.skills]),I=(0,s.useMemo)(()=>new Map(p.skills.map(e=>[e.id,{name:e.name,summary:e.summary,latest:e.latest}])),[p.skills]),T=(0,s.useMemo)(()=>{let e=new Map;for(let[r,s]of S){var t,n,a;e.set(r,(a=null!=(n=null==(t=I.get(r))?void 0:t.latest)?n:null,null!==s&&null!==a&&ry(a,s)))}return e},[S,I]),E=(0,s.useMemo)(()=>{var e;return null!=(e=p.skills.find(e=>e.id===y))?e:null},[p.skills,y]),A=(0,s.useMemo)(()=>{var e;return null!=(e=b.skills.find(e=>e.skillId===y))?e:null},[b.skills,y]);if(y){let e=null!=(a=null==E?void 0:E.compatibility)?a:null,t=E?E.recommendedVersion:null!=(l=null==A?void 0:A.version)?l:null,n=E?E.recommendedVersion?e&&"compatible"!==e.status?h("detail.install.blockedIncompatible",{reason:h((0,rN.e5)(e.messageKey),{range:e.requiredRange,currentVersion:null!=(i=e.currentVersion)?i:""})}):null:h("detail.install.blockedNoVersion"):null;return(0,r.jsxs)("div",{className:"flex flex-col min-h-0 ".concat(f).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)(u.$n,{variant:"ghost",size:"sm",onClick:()=>{j(null),C(e=>e+1)},"data-testid":"worktree-skills-back",children:[(0,r.jsx)(ri.A,{size:14,"aria-hidden":"true",className:"mr-1"}),h("worktreePane.back")]}),(0,r.jsx)("h2",{className:"min-w-0 truncate text-sm font-semibold text-foreground",children:null!=(c=null==E?void 0:E.name)?c:y})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 space-y-3 overflow-auto p-3",children:[A&&E&&(0,r.jsx)(rT,{skillId:y,skillName:E.name,worktreeId:x,installedVersion:A.version,versions:E.versions}),(0,r.jsx)(rw.B,{skillId:y,version:t,blockedReason:n,worktreeId:x})]})]})}return(0,r.jsx)("div",{className:"flex flex-col min-h-0 ".concat(f).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:h("worktreePane.installedHeading")}),"loading"===b.status?(0,r.jsx)(u.EA,{className:"h-16 w-full rounded-lg","data-testid":"worktree-skills-installed-loading"}):"error"===b.status?(0,r.jsxs)(u.Zp,{className:"space-y-2","data-testid":"worktree-skills-installed-error",children:[(0,r.jsxs)(rk.u,{tone:"danger",children:[(0,r.jsx)("p",{children:h("worktreePane.installedError")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:h("state.errorCode",{code:null!=(d=null==(t=b.failure)?void 0:t.code)?d:""})})]}),(0,r.jsx)(u.$n,{variant:"secondary",size:"sm",onClick:()=>C(e=>e+1),"data-testid":"worktree-skills-installed-retry",children:h("state.retry")})]}):0===b.skills.length?(0,r.jsx)(u.Zp,{"data-testid":"worktree-skills-installed-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:h("worktreePane.installedEmpty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:b.skills.map(e=>{var t;let n=I.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)(rj.qW,{risk:e.effectiveRisk}),T.get(e.skillId)&&(0,r.jsx)(u.Ex,{variant:"info","data-testid":"worktree-skills-update-badge-".concat(e.skillId),children:h("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:h("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:h("worktreePane.catalogHeading")}),"loading"===p.status?(0,r.jsx)(u.EA,{className:"h-24 w-full rounded-lg","data-testid":"worktree-skills-catalog-loading"}):"error"===p.status?(0,r.jsxs)(u.Zp,{className:"space-y-2","data-testid":"worktree-skills-catalog-error",children:[(0,r.jsxs)(rk.u,{tone:"danger",children:[(0,r.jsx)("p",{children:h("state.errorNotice")}),(0,r.jsx)("p",{className:"mt-1 break-words",children:h("state.errorCode",{code:null!=(m=null==(n=p.failure)?void 0:n.code)?m:""})})]}),(0,r.jsx)(u.$n,{variant:"secondary",size:"sm",onClick:()=>k(e=>e+1),"data-testid":"worktree-skills-catalog-retry",children:h("state.retry")})]}):0===p.skills.length?(0,r.jsx)(u.Zp,{"data-testid":"worktree-skills-catalog-empty",children:(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:h("state.empty")})}):(0,r.jsx)("ul",{className:"space-y-2",children:p.skills.map(e=>{let t=(0,rN.gh)(e),n=S.has(e.id),a=!0===T.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)(u.Ex,{variant:"info","data-testid":"worktree-skills-catalog-update-badge-".concat(e.id),children:h("worktreePane.updateBadge")}):(0,r.jsx)(u.Ex,{variant:"info","data-testid":"worktree-skills-installed-badge-".concat(e.id),children:h("worktreePane.installedBadge")}))]}),(0,r.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:h("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:h("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)(rj.Xz,{status:e.compatibility.status}),t&&(0,r.jsx)(rj.qW,{risk:t})]})]})},e.id)})})]})]})})}var rR=n(93499),rL=n(76907),rP=n(52799),rD=n(32209);let rF={pending:"gray",running:"info",waiting_input:"warning",verifying:"info",succeeded:"success",failed:"error",not_started:"warning",cancelled:"gray"},rO={running:"info",passed:"success",failed:"error",not_started:"warning",error:"error",cancelled:"gray"},rz={running:"info",passed:"success",failed:"error",timeout:"error",skipped:"gray",error:"error"},r_=["failed","timeout","error"],rB="".concat(tg,"/blob/main/docs/design/verification-config.md"),rV=".commandmate/verify.yaml";class rU extends Error{constructor(e,t,n=null){super(e),this.name="VerificationApiError",this.status=t,this.runningRunId=n}}async function rH(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 rU(a,e.status,r)}function rK(e){return"/api/worktrees/".concat(encodeURIComponent(e))}async function rW(e,t){var n,a;let r=await fetch("".concat(rK(e),"/tasks?limit=1"),{signal:t});return r.ok?null!=(a=null==(n=(await r.json()).tasks)?void 0:n[0])?a:null:rH(r,"Failed to load tasks")}async function rq(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(rK(e),"/verify/runs?limit=").concat(n),{signal:a});return r.ok?null!=(t=(await r.json()).runs)?t:[]:rH(r,"Failed to load verification runs")}async function r$(e,t,n){let a=await fetch("".concat(rK(e),"/verify/runs/").concat(t),{signal:n});return 404===a.status?null:a.ok?(await a.json()).run:rH(a,"Failed to load the verification run")}async function rG(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=await fetch("".concat(rK(e),"/verify"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)return rH(n,"Failed to start verification");let a=await n.json();if("number"!=typeof a.runId)throw new rU("Verification response carried no run id",n.status);return a.runId}async function rJ(e,t){var n,a,r;let s=await fetch("".concat(rK(e),"/verify/config"),{signal:t});if(!s.ok)return rH(s,"Failed to load the verification config");let l=await s.json();return{exists:!0===l.exists,path:"string"==typeof l.path?l.path:rV,gates:null!=(n=l.gates)?n:[],options:null!=(a=l.options)?a:null,plannedGateIds:null!=(r=l.plannedGateIds)?r:[],error:"string"==typeof l.error?l.error:null}}async function rY(e){var t,n,a;let r=await fetch("".concat(rK(e),"/verify/config"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!r.ok)return rH(r,"Failed to draft the verification config");let s=await r.json();return{created:!0===s.created,path:"string"==typeof s.path?s.path:rV,gates:null!=(t=s.gates)?t:[],excluded:null!=(n=s.excluded)?n:[],scanned:null!=(a=s.scanned)?a:[]}}async function rQ(e,t){var n;let a=await fetch("".concat(rK(e),"/verify/runs/").concat(t,"/cancel"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!a.ok)return rH(a,"Failed to cancel the verification run");let r=await a.json();return{runId:"number"==typeof r.runId?r.runId:t,status:null!=(n=r.status)?n:"cancelled"}}async function rX(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,a=new URLSearchParams;void 0!==t.worktreeId&&a.set("worktreeId",t.worktreeId),void 0!==t.days&&a.set("days",String(t.days)),void 0!==t.limit&&a.set("limit",String(t.limit));let r=a.toString(),s=await fetch("/api/verification/runs".concat(r?"?".concat(r):""),{signal:n});return s.ok?null!=(e=(await s.json()).runs)?e:[]:rH(s,"Failed to load the verification history")}let rZ={running:null,passed:0,failed:20,not_started:21,error:99,cancelled:99},r0=["passed","failed","not_started","error","cancelled"],r1={"work-evidence":"workEvidence",scope:"scope","env-clean":"envClean",config:"config"},r2={mutex:"reason=mutex-wait",detachedContract:"was NOT judged",noContract:"no contract is attached to this run",notRequired:"success.requireScopeClean: false"};function r4(e){if(!e)return"—";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function r5(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 r3(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 r6(e){var t,n;let{task:a}=e,s=(0,o.c)("worktree"),l=a.contract,i=null!=(t=l.goal)?t:"",c=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)(rP.E,{variant:rF[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:c}),(0,r.jsxs)("div",{className:"space-y-1 pt-1",children:[(0,r.jsx)(r3,{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)(r3,{label:s("verification.contract.scopeDeny"),children:(0,r.jsx)("span",{className:"font-mono",children:l.scope.deny.join(", ")})}),(0,r.jsx)(r3,{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)(r3,{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)(r3,{label:s("verification.contract.file"),children:(0,r.jsx)("span",{className:"font-mono",children:a.contractPath})}),(0,r.jsx)(r3,{label:s("verification.contract.updated"),children:r4(a.updatedAt)})]})]})}function r9(e){let{gate:t}=e;return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-declared-gate-".concat(t.id),children:[(0,r.jsx)("span",{className:"break-all font-mono text-xs font-medium text-foreground",children:t.id}),(0,r.jsx)("span",{className:"break-all font-mono text-[11px] text-muted-foreground",children:t.command})]})}function r8(e){let{children:t,testId:n,tone:a="muted"}=e;return(0,r.jsx)("p",{className:"whitespace-pre-line break-words ".concat("warning"===a?"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground":"text-xs text-muted-foreground"),"data-testid":n,role:"warning"===a?"alert":void 0,children:t})}function r7(e){var t,n,a,l,i,c;let{state:d}=e,u=(0,o.c)("worktree"),{config:m,configError:x,phase:f,runs:h,selectedRun:p,latestRun:g}=d,b=null!=(n=null==m?void 0:m.path)?n:rV,v=(0,s.useCallback)(()=>{d.draftConfig()},[d]),y=(0,s.useCallback)(()=>{d.rerun()},[d]),j=(0,s.useCallback)(()=>{g&&d.selectRun(g.id)},[g,d]),w=(0,s.useCallback)(()=>{d.cancelRun()},[d]),k=null!=(a=h.find(e=>"running"===e.status))?a:null,N=p&&k&&p.id===k.id?p.gates:[],C=N.filter(e=>"running"!==e.status).length,S=Math.max(null!=(l=null==m?void 0:m.plannedGateIds.length)?l:0,N.length),I=k?Date.now()-new Date(k.startedAt).getTime():0;return(0,r.jsxs)("section",{className:"space-y-2 border-b border-border px-3 py-3","data-testid":"verification-onboarding","data-phase":f,children:[(0,r.jsx)(r8,{testId:"verification-onboarding-what",children:u("verification.onboarding.what",{path:b})}),(0,r.jsx)(r8,{testId:"verification-onboarding-how",children:u("verification.onboarding.how")}),null!==x&&(0,r.jsx)(r8,{tone:"warning",testId:"verification-config-error",children:u("verification.onboarding.configError",{message:x})}),(null==m?void 0:m.error)!=null&&(0,r.jsx)(r8,{tone:"warning",testId:"verification-config-invalid",children:u("verification.onboarding.invalid",{path:b,message:m.error})}),"unknown"===f&&(0,r.jsx)(r8,{testId:"verification-onboarding-unknown",children:u("verification.onboarding.loading")}),"no-config"===f&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-no-config",children:[(0,r.jsx)(r8,{children:u("verification.onboarding.noConfig.body",{path:b})}),(0,r.jsx)(r8,{children:u("verification.onboarding.noConfig.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"primary",onClick:v,disabled:d.draftPending,"data-testid":"verification-draft-button",children:u(d.draftPending?"verification.onboarding.noConfig.pending":"verification.onboarding.noConfig.action")}),(0,r.jsxs)("a",{href:rB,target:"_blank",rel:"noreferrer noopener","data-testid":"verification-docs-link",className:"inline-flex items-center gap-1 rounded text-xs 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:[u("verification.onboarding.noConfig.docs"),(0,r.jsx)(rR.A,{size:12,"aria-hidden":"true"})]})]}),d.draftFailure&&(0,r.jsx)(r8,{tone:"warning",testId:"verification-draft-failure",children:"conflict"===d.draftFailure.kind?u("verification.onboarding.noConfig.conflict",{path:b}):"empty"===d.draftFailure.kind?u("verification.onboarding.noConfig.empty",{path:b}):u("verification.onboarding.noConfig.error",{message:d.draftFailure.message})})]}),"configured"===f&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-configured",children:[(0,r.jsx)(r8,{children:u("verification.onboarding.configured.body",{path:b,count:null!=(i=null==m?void 0:m.gates.length)?i:0})}),(null==(t=d.draftResult)?void 0:t.created)&&(0,r.jsx)(r8,{testId:"verification-draft-created",children:u("verification.onboarding.noConfig.created",{path:d.draftResult.path,count:d.draftResult.gates.length})}),(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:u("verification.onboarding.configured.gatesHeading")}),(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-declared-gates",children:(null!=(c=null==m?void 0:m.gates)?c:[]).map(e=>(0,r.jsx)(r9,{gate:e},e.id))}),(0,r.jsx)(r8,{testId:"verification-builtin-gates",children:u("verification.onboarding.configured.builtin",{gates:(function(e){if(null===e)return[];let t=new Set(e.gates.map(e=>e.id));return e.plannedGateIds.filter(e=>!t.has(e))})(m).join(", ")})}),(0,r.jsx)(r8,{testId:"verification-builtin-gates-hint",children:u("verification.onboarding.configured.builtinHint")}),(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"primary",onClick:y,disabled:d.rerunPending,"data-testid":"verification-run-button",children:u(d.rerunPending?"verification.runs.rerunPending":"verification.onboarding.configured.action")})]}),"running"===f&&null!==k&&(0,r.jsxs)("div",{className:"space-y-1","data-testid":"verification-onboarding-running",children:[(0,r.jsx)(r8,{testId:"verification-running-progress",children:u("verification.onboarding.running.progress",{done:C,total:S})}),(0,r.jsx)(r8,{testId:"verification-running-elapsed",children:u("verification.onboarding.running.elapsed",{elapsed:function(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return"".concat(t,"s");let n=Math.floor(t/60);return"".concat(n,"m ").concat(String(t%60).padStart(2,"0"),"s")}(I)})}),(0,r.jsx)(r8,{children:u("verification.onboarding.running.hint")}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"secondary",onClick:d.refresh,"data-testid":"verification-running-refresh-button",children:u("verification.onboarding.running.action")}),(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"danger",onClick:w,disabled:d.cancelPending,"data-testid":"verification-cancel-button",children:u(d.cancelPending?"verification.runs.cancelPending":"verification.runs.cancel")})]}),(0,r.jsx)(r8,{testId:"verification-cancel-hint",children:u("verification.runs.cancelHint")}),d.cancelSettling&&(0,r.jsx)(r8,{testId:"verification-cancel-settling",children:u("verification.runs.cancelSettling")}),d.cancelFailure&&(0,r.jsx)(r8,{tone:"warning",testId:"verification-cancel-failure",children:"gone"===d.cancelFailure.kind?u("verification.runs.cancelGone"):u("verification.runs.cancelError",{message:d.cancelFailure.message})})]}),"result"===f&&null!==g&&(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-onboarding-result",children:[(0,r.jsx)(r8,{testId:"verification-result-body",children:u("verification.onboarding.result.body",{runId:g.id,verdict:u("verification.runStatus.".concat(g.status))})}),(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"secondary",onClick:j,"data-testid":"verification-show-latest-button",children:u("verification.onboarding.result.action")})]})]})}function se(e){let{state:t}=e,n=(0,o.c)("worktree"),[a,l]=(0,s.useState)(!1),{availableGateIds:i,selectedGateIds:c,failedGateIds:d,rerunPending:u}=t,m=(0,s.useCallback)(()=>l(e=>!e),[]),x=(0,s.useCallback)(()=>t.setGateSelection(null),[t]),f=(0,s.useCallback)(()=>{t.selectFailedGates(),l(!0)},[t]),h=(0,s.useCallback)(()=>{t.rerun()},[t]);if(0===i.length)return null;let p=null!=c?c:i,g=null===c,b=i.filter(e=>d.includes(e));return(0,r.jsxs)("div",{className:"mb-2 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-gate-selector","data-selection":g?"all":p.join(","),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:n("verification.selection.heading")}),(0,r.jsx)("button",{type:"button",onClick:m,"aria-expanded":a,"data-testid":"verification-gate-selector-toggle",className:"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:a?n("verification.selection.close"):n("verification.selection.open")})]}),(0,r.jsx)("p",{className:"mt-0.5 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-selector-summary",children:g?n("verification.selection.all",{count:i.length}):n("verification.selection.partial",{selected:p.length,total:i.length,gates:p.join(", ")})}),a&&(0,r.jsxs)("div",{className:"mt-2 space-y-2","data-testid":"verification-gate-selector-body",children:[(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-gate-checkboxes",children:i.map(e=>{let a="verification-gate-select-".concat(e),s=d.includes(e);return(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)(rD.S,{id:a,checked:p.includes(e),onCheckedChange:()=>t.toggleGate(e),"data-testid":a,"aria-label":n("verification.selection.gateLabel",{gateId:e})}),(0,r.jsx)("label",{htmlFor:a,className:"min-w-0 flex-1 cursor-pointer break-all font-mono text-[11px] text-foreground touch-manipulation",children:e}),s&&(0,r.jsx)(rP.E,{variant:"error",className:"flex-shrink-0",children:n("verification.gateStatus.failed")})]},e)})}),(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"primary",onClick:h,disabled:u,"data-testid":"verification-run-selected-button",children:u?n("verification.runs.rerunPending"):g?n("verification.selection.runAll"):n("verification.selection.runSelected",{count:p.length})}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.selection.hint")})]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"secondary",onClick:f,disabled:0===b.length,"data-testid":"verification-failed-only-button",children:n("verification.selection.failedOnly",{count:b.length})}),!g&&(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"ghost",onClick:x,"data-testid":"verification-select-all-button",children:n("verification.selection.selectAll")})]}),0===b.length&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-failed-only-empty",children:n("verification.selection.failedOnlyEmpty")})]})}function st(e){let{state:t}=e,n=(0,o.c)("worktree"),{repositoryHistoryOpen:a,repositoryHistory:l,repositoryHistoryLoading:i,repositoryHistoryError:c}=t,d=(0,s.useCallback)(()=>{t.toggleRepositoryHistory()},[t]);return(0,r.jsxs)("div",{className:"mt-2","data-testid":"verification-repository-history",children:[(0,r.jsx)("button",{type:"button",onClick:d,"aria-expanded":a,"data-testid":"verification-repository-history-toggle",className:"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(a?"verification.runs.history.close":"verification.runs.history.open")}),a&&(0,r.jsxs)("div",{className:"mt-1 space-y-1","data-testid":"verification-repository-history-body",children:[(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.hint")}),null!==c?(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-[11px] text-warning-foreground","data-testid":"verification-repository-history-error",role:"alert",children:n("verification.runs.history.error",{message:c})}):i&&0===l.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("verification.runs.history.loading")}):0===l.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"verification-repository-history-empty",children:n("verification.runs.history.empty")}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-repository-history-runs",children:l.map(e=>(0,r.jsx)(sn,{run:e},e.id))})]})]})}function sn(e){let{run:t}=e,n=(0,o.c)("worktree"),a=t.status,s=t.gates.filter(e=>r_.includes(e.status)).map(e=>e.gateId);return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 rounded-md border border-border bg-surface px-2 py-1.5","data-testid":"verification-history-run-".concat(t.id),children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)(rP.E,{variant:rO[a],className:"flex-shrink-0",children:n("verification.runStatus.".concat(a))}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",children:t.worktreeId})]}),(0,r.jsxs)("span",{className:"flex flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground",children:[(0,r.jsx)("span",{children:n("verification.runs.runLabel",{runId:t.id})}),(0,r.jsx)("span",{children:r4(t.startedAt)})]}),s.length>0&&(0,r.jsx)("span",{className:"break-words text-[11px] text-muted-foreground",children:n("verification.runs.history.failingGates",{gates:s.join(", ")})})]})}function sa(e){let{gate:t,log:n,onClose:a}=e,l=(0,o.c)("worktree"),[i,c]=(0,s.useState)("idle"),d=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{null!==d.current&&clearTimeout(d.current)},[]);let u=""===n?0:n.replace(/\n+$/,"").split("\n").length,m=""!==n.trim(),x=(0,s.useCallback)(()=>{(async()=>{try{await (0,eX.l)(n),c("done")}catch(e){c("failed")}null!==d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c("idle"),2e3)})()},[n]);return(0,r.jsx)(tN.a,{isOpen:!0,onClose:a,size:"xl",title:l("verification.gates.fullLogTitle",{gateId:t.gateId,runId:t.runId}),children:(0,r.jsxs)("div",{className:"space-y-2","data-testid":"verification-gate-full-log-".concat(t.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(eD.$,{type:"button",size:"sm",variant:"secondary",onClick:x,disabled:!m,"data-testid":"verification-gate-log-copy-button",children:[(0,r.jsx)(eU.A,{size:12,"aria-hidden":"true",className:"mr-1"}),l("done"===i?"verification.gates.copied":"failed"===i?"verification.gates.copyFailed":"verification.gates.copyLog")]}),(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground","data-testid":"verification-gate-log-size",children:l("verification.gates.fullLogSize",{lines:u})})]}),(0,r.jsx)("p",{className:"break-words text-[11px] text-muted-foreground",children:l("verification.gates.fullLogStored")}),""===n?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:l("verification.gates.noLog")}):(0,r.jsx)("pre",{className:"max-h-[60vh] overflow-auto rounded bg-terminal-surface p-2 font-mono text-[11px] leading-relaxed text-terminal-foreground",children:n})]})})}function sr(e){let{run:t,selected:n,onSelect:a}=e,s=(0,o.c)("worktree"),l=s("verification.runStatus.".concat(t.status)),i=s("verification.runStatusGloss.".concat(t.status)),c=rZ[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,gloss:i}),title:i,"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)(rP.E,{variant:rO[t.status],className:"flex-shrink-0",children:l}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:r4(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})}),null!==c&&(0,r.jsx)("span",{children:s("verification.runs.exitCode",{code:c})})]})]})})}function ss(){let e=(0,o.c)("worktree"),t=r0.map(t=>{var n;return e("verification.runs.cliLegendItem",{label:e("verification.runStatus.".concat(t)),code:null!=(n=rZ[t])?n:0})}).join(" / ");return(0,r.jsx)("p",{className:"mb-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-cli-exit-legend",children:e("verification.runs.cliLegend",{items:t})})}function sl(e){let{run:t,plannedGateIds:n}=e,a=(0,o.c)("worktree"),s=rZ[t.status],l=t.gates.filter(e=>"skipped"===e.status),i=new Set(t.gates.map(e=>e.gateId)),c=n.filter(e=>!i.has(e));return(0,r.jsxs)("div",{className:"mb-2 space-y-1 rounded-md border border-border bg-surface-2 px-2 py-2","data-testid":"verification-run-verdict",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.verdictHeading")}),(0,r.jsx)(rP.E,{variant:rO[t.status],className:"flex-shrink-0",children:a("verification.runStatus.".concat(t.status))}),null!==s&&(0,r.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a("verification.runs.exitCode",{code:s})})]}),(0,r.jsx)("p",{className:"break-words text-xs text-muted-foreground","data-testid":"verification-run-verdict-gloss",children:a("verification.runStatusGloss.".concat(t.status))}),c.length>0&&(0,r.jsx)("p",{className:"rounded border border-warning-border bg-warning-subtle px-2 py-1 text-xs text-warning-foreground","data-testid":"verification-run-partial",children:a("verification.runs.partial",{ran:i.size,total:n.length,gates:c.join(", ")})}),l.length>0&&(0,r.jsxs)("div",{className:"space-y-0.5 pt-1","data-testid":"verification-run-skip-reasons",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-foreground",children:a("verification.gates.skipHeading")}),(0,r.jsx)("ul",{className:"space-y-0.5",children:l.map(e=>(0,r.jsx)("li",{className:"break-words text-xs text-muted-foreground",children:a("verification.gates.skipReasonFor",{gateId:e.gateId,reason:a("verification.gates.skipReason.".concat(function(e){let t=null!=e?e:"";return t.includes("skipped: worktreePath is the server process working directory and options.skipInPrimaryCheckout is true.")?"primaryCheckout":t.includes("skipped: the work-evidence gate did not pass.")?"workEvidence":t.includes("skipped: the verification run was cancelled.")?"cancelled":t.includes(r2.mutex)?"mutex":t.includes(r2.detachedContract)?"detachedContract":t.includes(r2.noContract)?"noContract":t.includes(r2.notRequired)?"notRequired":"unknown"}(e.logTail)))})},e.id))})]})]})}function si(e){var t,n;let{gate:a}=e,l=(0,o.c)("worktree"),i=r_.includes(a.status),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),x=(0,s.useCallback)(()=>m(!1),[]),f=null!=c?c:i,h=(0,tP.aJ)(null!=(t=a.logTail)?t:""),p=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}}(h,40),g=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")}(a.durationMs),b=null!=(n=r1[a.gateId])?n:null;return(0,r.jsxs)("li",{className:"rounded-md border border-border bg-surface p-2","data-testid":"verification-gate-".concat(a.gateId),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(rP.E,{variant:rz[a.status],className:"flex-shrink-0",children:l("verification.gateStatus.".concat(a.status))}),(0,r.jsx)("span",{className:"min-w-0 break-all font-mono text-xs font-medium text-foreground",children:a.gateId}),"contract"===a.source&&(0,r.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground",title:l("verification.gates.contractSourceHint"),children:l("verification.gates.contractSource")}),null!==b&&(0,r.jsx)("span",{className:"text-[10px] text-muted-foreground",children:l("verification.gates.builtinBadge")})]}),null!==b&&(0,r.jsx)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-about-".concat(a.gateId),children:l("verification.gates.builtin.".concat(b))}),"skipped"===a.status&&(0,r.jsxs)("p",{className:"mt-1 break-words text-[11px] text-muted-foreground","data-testid":"verification-gate-skipped-".concat(a.gateId),children:[l("verification.gateStatus.skipped")," — ",l("verification.gateStatusGloss.skipped")]}),(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!==a.exitCode&&void 0!==a.exitCode&&(0,r.jsx)("span",{children:l("verification.gates.exitCode",{code:a.exitCode})}),g&&(0,r.jsx)("span",{children:l("verification.gates.duration",{duration:g})}),a.command&&(0,r.jsx)("span",{className:"break-all",children:a.command})]}),(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>d(!f),"aria-expanded":f,"data-testid":"verification-gate-log-toggle-".concat(a.gateId),className:"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:l(f?"verification.gates.hideLog":"verification.gates.showLog")}),""!==h&&(0,r.jsx)("button",{type:"button",onClick:()=>m(!0),"data-testid":"verification-gate-full-log-button-".concat(a.gateId),className:"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:l("verification.gates.showFullLog")})]}),u&&(0,r.jsx)(sa,{gate:a,log:h,onClose:x}),f&&(0,r.jsx)("div",{className:"mt-1","data-testid":"verification-gate-log-".concat(a.gateId),children:0===p.lines.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:l("verification.gates.noLog")}):(0,r.jsxs)(r.Fragment,{children:[p.omitted>0&&(0,r.jsx)("p",{className:"mb-1 text-[11px] text-muted-foreground",children:l("verification.gates.logOmitted",{count:p.omitted,runId:a.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:p.lines.join("\n")})]})})]})}let so=(0,s.memo)(function(e){var t,n;let{state:a,className:l=""}=e,i=(0,o.c)("worktree"),{worktreeId:c,task:d,runs:u,selectedRunId:m,selectedRun:x,loading:f,error:h,detailError:p,detailLoading:g,rerunPending:b,rerunFailure:v,cancelFailure:y,canLoadMore:j,selectRun:w,refresh:k,rerun:N,loadMore:C}=a,S=(0,s.useCallback)(()=>{N()},[N]);return(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-auto bg-surface ".concat(l).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)(rL.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:i("verification.title")})]}),(0,r.jsx)("button",{type:"button",onClick:k,"aria-label":i("verification.refresh"),title:i("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)(nR.A,{size:14,"aria-hidden":"true"})})]}),h&&(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:i("verification.loadError",{message:h})}),f?(0,r.jsx)("p",{className:"px-3 py-4 text-xs text-muted-foreground","data-testid":"verification-loading",children:i("verification.loading")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(r7,{state:a}),(0,r.jsx)(r5,{heading:i("verification.contract.heading"),testId:"verification-contract-section",children:d?(0,r.jsx)(r6,{task:d}):(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-contract-empty",children:i("verification.contract.empty")})}),(0,r.jsxs)(r5,{heading:i("verification.runs.heading"),testId:"verification-runs-section",action:(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"secondary",onClick:S,disabled:b,"data-testid":"verification-rerun-button",children:i(b?"verification.runs.rerunPending":"verification.runs.rerun")}),children:[v&&(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"===v.kind?null!==v.runningRunId?i("verification.runs.rerunConflict",{runId:v.runningRunId}):i("verification.runs.rerunConflictUnknown"):i("verification.runs.rerunError",{message:v.message})}),y&&(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-runs-cancel-failure",role:"alert",children:"gone"===y.kind?i("verification.runs.cancelGone"):i("verification.runs.cancelError",{message:y.message})}),(0,r.jsx)(se,{state:a}),(0,r.jsx)(ss,{}),0===u.length?(0,r.jsx)("p",{className:"whitespace-pre-line text-xs text-muted-foreground","data-testid":"verification-runs-empty",children:i("verification.runs.empty",{worktreeId:c})}):(0,r.jsx)("ul",{className:"space-y-1","data-testid":"verification-runs",children:u.map(e=>(0,r.jsx)(sr,{run:e,selected:e.id===m,onSelect:w},e.id))}),j&&(0,r.jsx)(eD.$,{type:"button",size:"sm",variant:"ghost",onClick:C,className:"mt-1","data-testid":"verification-load-more-button",children:i("verification.runs.loadMore",{count:10})}),(0,r.jsx)(st,{state:a})]}),null!==m&&(0,r.jsx)(r5,{heading:i("verification.gates.heading",{runId:m}),testId:"verification-gates-section",children:null!==p?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-error",role:"alert",children:"not-found"===p?i("verification.gates.notFound"):i("verification.gates.loadError",{message:p})}):null===x?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-loading",children:i(g?"verification.gates.loading":"verification.gates.empty")}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(sl,{run:x,plannedGateIds:null!=(n=null==(t=a.config)?void 0:t.plannedGateIds)?n:[]}),0===x.gates.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"verification-gates-empty",children:i("verification.gates.empty")}):(0,r.jsx)("ul",{className:"space-y-1.5","data-testid":"verification-gates",children:x.gates.map(e=>(0,r.jsx)(si,{gate:e},e.id))}),x.gates.some(e=>"contract"===e.source)&&(0,r.jsx)("p",{className:"mt-2 break-words text-[11px] text-muted-foreground","data-testid":"verification-contract-source-hint",children:i("verification.gates.contractSourceHint")})]})})]})]})});var sc=n(70532),sd=n(46046),su=n(47972),sm=n(5590),sx=n(25840);class sf extends Error{constructor(e,t,n=[]){super(t),this.name="EnvApiError",this.code=e,this.issues=n}}async function sh(e,t){var n,a,r,s,l,i;let o=await e.json().catch(()=>null);return new sf(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 sp(e,t){let n="/api/worktrees/".concat(encodeURIComponent(e),"/env");return void 0===t?n:"".concat(n,"?file=").concat(encodeURIComponent(t))}async function sg(e,t){var n,a;let r=await fetch(sp(e,t),{cache:"no-store"});if(!r.ok)throw await sh(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 sb(e,t,n){var a;let r=await fetch(sp(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:t,content:n})});if(!r.ok)throw await sh(r,"Failed to save env file");let s=await r.json();return{file:s.file,issues:null!=(a=s.issues)?a:[]}}let sv=/^[A-Za-z_][A-Za-z0-9_]*$/;function sy(e){return e.split(/\r\n|\n|\r/)}function sj(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 sw(e){let t=sy(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(!sv.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]+/,""),x=null,f=l;if(m.startsWith('"')||m.startsWith("'")){x=m[0];let n=m.slice(1),r=sj(n,x,0);for(;-1===r&&e+1<t.length;)e+=1,f=e+1,n+="\n".concat(t[e]),r=sj(n,x,0);if(-1===r){a.push({line:l,code:"unterminated-quote",severity:"error",key:u});continue}let i=n.slice(0,r);s='"'===x?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:f,exported:o,quote:x})}return{entries:n,issues:a}}let sk=/[\s#'"$`\\]/;function sN(e){if(!sk.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 sC(e,t,n){let a=sy(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(sN(l.value)))}for(let e of(i.length>0&&""===i[i.length-1]&&i.pop(),l))i.push("".concat(e.key,"=").concat(sN(e.value)));return 0===i.length?"":"".concat(i.join("\n"),"\n")}let sS=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/,sI=0;function sT(){return sI+=1,"env-row-".concat(sI)}function sE(e){return e.map(e=>({id:sT(),key:e.key,value:e.value,sourceLine:e.line}))}let sA="••••••••";function sM(e){return 0===e.length?"":sA}let sR="flex-shrink-0 px-2 opacity-80 transition-opacity hover:opacity-100 [@media(hover:none)]:opacity-100",sL={"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"},sP=(0,s.memo)(function(e){let{worktreeId:t,className:n=""}=e,a=(0,o.c)("worktree"),l=function(e){var t;let[n,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(".env"),[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)("kv"),[v,y]=(0,s.useState)([]),[j,w]=(0,s.useState)(""),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)([]),[I,T]=(0,s.useState)(""),[E,A]=(0,s.useState)(new Set),[M,R]=(0,s.useState)(!1),[L,P]=(0,s.useState)(0),D=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=!1,n=D.current+1;return D.current=n,d(!0),f(null),p(!1),sg(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:[];T(i),N(i),S(c),y(sE(c)),w(i),A(new Set),R(!1)}).catch(e=>{var a,r;if(t||D.current!==n)return;let s=e instanceof sf?e:null;f({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,L]);let F=(0,s.useMemo)(()=>"raw"===g?j:sC(k,C,v),[g,j,k,C,v]),O=(0,s.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)sS.test(n[e])&&t.push({line:e+1,code:"control-character",severity:"error"});let a=sw(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,s.useMemo)(()=>"raw"===g?j!==I:k!==I||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,I,k,v,C]),_=(0,s.useCallback)(e=>{if(e!==g){if("raw"===e)w(sC(k,C,v));else{let e=sw(j);N(j),S(e.entries),y(sE(e.entries))}b(e)}},[g,k,C,v,j]),B=(0,s.useCallback)(e=>{l(e),b("kv")},[]),V=(0,s.useCallback)(e=>{w(e),p(!1)},[]),U=(0,s.useCallback)((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n)),p(!1)},[]),H=(0,s.useCallback)(e=>{var t,n;let a={id:sT(),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)&&A(t=>new Set([...t,e.key]))},[]),K=(0,s.useCallback)(e=>{y(t=>t.filter(t=>t.id!==e)),p(!1)},[]),W=(0,s.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),q=(0,s.useCallback)(()=>R(e=>!e),[]),$=(0,s.useCallback)(()=>{A(new Set(v.map(e=>e.key)))},[v]),G=(0,s.useCallback)(()=>A(new Set),[]),J=(0,s.useCallback)(()=>P(e=>e+1),[]),Y=(0,s.useCallback)(()=>{O.valid&&!u&&(m(!0),f(null),sb(e,r,F).then(()=>{p(!0),P(e=>e+1)}).catch(e=>{var t,n;let a=e instanceof sf?e:null;f({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:i,loading:c,saving:u,error:x,saved:h,mode:g,rows:v,rawDraft:j,revealedKeys:E,rawRevealed:M,suggestions:null!=(t=null==i?void 0:i.suggestions)?t:[],issues:O.issues,canSave:O.valid,dirty:z,selectFile:B,setMode:_,setRawDraft:V,updateRow:U,addRow:H,removeRow:K,toggleReveal:W,toggleRawReveal:q,revealAll:$,hideAll:G,reload:J,save:Y}}(t),{mode:i,rows:c,revealedKeys:u,rawRevealed:m}=l,x=(0,s.useMemo)(()=>l.issues.filter(e=>"error"===e.severity),[l.issues]),f=(0,s.useMemo)(()=>l.issues.filter(e=>"warning"===e.severity),[l.issues]),h="raw"===i?m:c.length>0&&c.every(e=>u.has(e.key)),p=(0,s.useCallback)(()=>{if("raw"===i)return void l.toggleRawReveal();h?l.hideAll():l.revealAll()},[i,h,l]),g=(0,s.useMemo)(()=>"raw"!==i||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(sM(l.value)))}return s.join("\n")}(l.rawDraft,sw(l.rawDraft).entries),[i,m,l.rawDraft]),b=(0,s.useCallback)((e,t)=>{var n,s,l;return(0,r.jsx)("li",{children:a(sL[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:l.files.map(e=>(0,r.jsxs)(eD.$,{size:"sm",variant:e.name===l.selectedFile?"primary":"ghost",onClick:()=>l.selectFile(e.name),"aria-pressed":e.name===l.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)(rP.E,{variant:"gray",children:a("envManager.notCreated")}),e.isExample&&(0,r.jsx)(rP.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)(eD.$,{size:"sm",variant:"kv"===i?"primary":"ghost",onClick:()=>l.setMode("kv"),"aria-pressed":"kv"===i,"data-testid":"env-mode-kv",className:"min-h-[44px]",children:a("envManager.viewKeyValue")}),(0,r.jsx)(eD.$,{size:"sm",variant:"raw"===i?"primary":"ghost",onClick:()=>l.setMode("raw"),"aria-pressed":"raw"===i,"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)(eD.$,{size:"sm",variant:"ghost",onClick:p,"data-testid":"env-toggle-all","aria-pressed":h,className:"min-h-[44px] gap-1.5",children:[h?(0,r.jsx)(sc.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(e0.A,{size:16,"aria-hidden":"true"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:h?a("envManager.hideAll"):a("envManager.revealAll")})]}),(0,r.jsx)(eD.$,{size:"sm",variant:"ghost",onClick:l.reload,"data-testid":"env-reload","aria-label":a("envManager.reload"),className:"min-h-[44px]",children:(0,r.jsx)(nR.A,{size:16,"aria-hidden":"true"})}),(0,r.jsxs)(eD.$,{size:"sm",variant:"primary",onClick:l.save,loading:l.saving,disabled:!l.canSave||!l.dirty,"data-testid":"env-save",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(sd.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")}),l.loading&&(0,r.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-muted-foreground",children:[(0,r.jsx)(d.y,{size:"sm"}),a("envManager.loading")]}),l.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")}),!l.loading&&l.detail&&!l.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:l.selectedFile})}),l.saved&&!l.dirty&&(0,r.jsx)("p",{"data-testid":"env-saved",className:"text-xs text-success-foreground",children:a("envManager.saved")}),x.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)(aU.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:x.map(b)})]}),f.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:f.map(b)})}),!l.loading&&"kv"===i&&(0,r.jsxs)("div",{"data-testid":"env-kv-view",className:"space-y-2",children:[0===c.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")}),c.map(e=>{let t=u.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)(sm.p,{inputSize:"sm",value:e.key,onChange:t=>l.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)(sm.p,{inputSize:"sm",readOnly:!t,value:t?e.value:sM(e.value),onChange:t=>l.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)(eD.$,{size:"sm",variant:"ghost",onClick:()=>l.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(sR," min-h-[44px]"),children:t?(0,r.jsx)(sc.A,{size:16,"aria-hidden":"true"}):(0,r.jsx)(e0.A,{size:16,"aria-hidden":"true"})}),(0,r.jsx)(eD.$,{size:"sm",variant:"ghost",onClick:()=>l.removeRow(e.id),"aria-label":a("envManager.removeRow",{key:e.key}),"data-testid":"env-row-remove",className:"".concat(sR," min-h-[44px] text-danger"),children:(0,r.jsx)(nd.A,{size:16,"aria-hidden":"true"})})]})]},e.id)}),(0,r.jsxs)(eD.$,{size:"sm",variant:"secondary",onClick:()=>l.addRow(),"data-testid":"env-add-row",className:"min-h-[44px] gap-1.5",children:[(0,r.jsx)(aG.A,{size:16,"aria-hidden":"true"}),a("envManager.addRow")]}),l.suggestions.length>0&&(0,r.jsxs)(su.Zp,{"data-testid":"env-suggestions",className:"mt-3",children:[(0,r.jsxs)(su.aR,{children:[(0,r.jsx)(su.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)(su.Wu,{className:"flex flex-wrap gap-2",children:l.suggestions.map(e=>(0,r.jsxs)(eD.$,{size:"sm",variant:"secondary",onClick:()=>l.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)(aG.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)))})]})]}),!l.loading&&"raw"===i&&(0,r.jsx)("div",{"data-testid":"env-raw-view",className:"space-y-2",children:m?(0,r.jsx)(sx.T,{value:l.rawDraft,onChange:e=>l.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)(sx.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:sA})})]})})]})]})}),sD=[{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"}],sF=(0,s.memo)(function(e){var t,n;let{worktreeId:a,className:l="",selectedAgents:i,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:f,availableAgents:h,persistToServer:p,onInsertToMessage:g,useInstanceManagement:b=!1,instances:v,onInstancesChange:y,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N,verification:C,requestedSubTab:S}=e,I=(0,o.c)("schedule"),[T,E]=(0,s.useState)(null!=(t=null==S?void 0:S.tab)?t:"notes"),A=(0,s.useRef)(null!=(n=null==S?void 0:S.token)?n:null);(0,s.useEffect)(()=>{S&&S.token!==A.current&&(A.current=S.token,E(S.tab))},[S]);let M=(0,s.useCallback)(e=>{E(e)},[]),R=(0,s.useRef)({});return(0,s.useEffect)(()=>{var e,t;null==(t=R.current[T])||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest",inline:"nearest"})},[T]),(0,r.jsxs)("div",{className:"flex flex-col h-full ".concat(l),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:sD.map(e=>(0,r.jsx)("button",{type:"button",ref:t=>{R.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:I(e.labelKey)},e.id))}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden",children:["notes"===T&&(0,r.jsx)(nG,{worktreeId:a,className:"h-full",onInsertToMessage:g}),"logs"===T&&(0,r.jsx)(aR,{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)(a8,{worktreeId:a,instances:v,onInstancesChange:y,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,visibleInstanceIds:j,onToggleInstanceVisible:w,modelByInstance:k,composerTargetInstanceId:N})}):(0,r.jsx)(az,{worktreeId:a,selectedAgents:i,onSelectedAgentsChange:c,vibeLocalModel:d,onVibeLocalModelChange:u,vibeLocalContextWindow:m,onVibeLocalContextWindowChange:x,maxAgents:f,availableAgents:h,persistToServer:p})),"timer"===T&&(0,r.jsx)(rl,{worktreeId:a,instances:v,selectedAgents:i}),"todo"===T&&(0,r.jsx)(n0,{worktreeId:a,className:"h-full"}),"skills"===T&&(0,r.jsx)(rM,{worktreeId:a,className:"h-full"}),"verification"===T&&(0,r.jsx)(so,{state:C,className:"h-full"}),"env"===T&&(0,r.jsx)(sP,{worktreeId:a,className:"h-full"})]})]})});var sO=n(2317);let sz=["status","changes","history","advanced"],s_="commandmate:gitPane:",sB={activeTab:"".concat(s_,"activeTab"),historyOpen:"".concat(s_,"historyOpen"),advancedOpen:"".concat(s_,"advancedOpen")};function sV(e){return"string"==typeof e&&sz.includes(e)}let sU=e=>"boolean"==typeof e,sH=s.useLayoutEffect;function sK(e,t,n){return Math.max(8,Math.min(e,n-t-8))}let sW=(0,s.memo)(function(e){var t,n;let{branches:a,busy:l,actionError:i,hasRunningSession:c,isMobile:d,onCheckout:m}=e,x=(0,o.c)("worktree"),f=(0,o.c)("common"),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(!1),j=(0,s.useRef)(null),w=(0,s.useRef)(null),[k,N]=(0,s.useState)(null),C=a.filter(e=>!e.isCurrent),S=(0,s.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:sK(r<a.height+4+8&&s>r?n.top-a.height-4:n.bottom+4,a.height,window.innerHeight),left:sK(n.left,a.width,window.innerWidth)})},[]);sH(()=>h?(S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}):void N(null),[h,C.length,S]);let I=(0,s.useCallback)(e=>{y(!1),b({...e}),p(!1)},[]),T=(0,s.useCallback)(()=>{g&&(m(g,v),b(null))},[g,v,m]);return(0,r.jsxs)("div",{className:"relative",ref:j,"data-testid":"branch-checkout-dropdown",children:[(0,r.jsxs)(u.$n,{variant:"ghost",type:"button",onClick:()=>p(e=>!e),disabled:l||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":h,"aria-label":x("git.checkout.ariaLabel"),children:[x("git.checkout.action"),(0,r.jsx)("span",{"aria-hidden":"true",className:"text-[10px]",children:"▾"})]}),h&&"undefined"!=typeof document&&(0,ns.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:x("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:()=>I(e),disabled:l||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":x("git.checkout.checkoutBranch",{name:e.name}),title:n?x("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:x("git.checkout.defaultBadge")})]})},"".concat(e.isRemote?"r":"l",":").concat(e.name))})})}),document.body),i&&(0,r.jsx)("div",{className:"mt-1 text-xs text-danger-foreground",role:"alert","data-testid":"branch-checkout-error",children:i}),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:[x("git.checkout.confirmTitlePrefix"),(0,r.jsx)("span",{className:"font-mono",children:g.name}),x("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:x("git.checkout.historyLossWarning")}),c&&(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:x("git.checkout.runningSessionWarning")}),(0,r.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,r.jsx)(u.Sc,{checked:v,onCheckedChange:e=>y(!0===e),"data-testid":"branch-checkout-force"}),x("git.checkout.forceLabel")]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 ".concat(d?"flex-wrap":""),children:[(0,r.jsx)(u.$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:f("cancel")}),(0,r.jsx)(u.$n,{variant:"ghost",type:"button",onClick:T,disabled:l,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:x("git.checkout.action")})]})]})})]})}),sq=(0,s.memo)(function(e){let{open:t,onToggle:n,children:a}=e,s=(0,o.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})]})}),s$=(0,s.createContext)(null);function sG(e){let{value:t,children:n}=e;return(0,r.jsx)(s$.Provider,{value:t,children:n})}function sJ(){let e=(0,s.useContext)(s$);if(null===e)throw Error("useGitPaneContext must be used within a GitPaneProvider");return e}let sY=(0,s.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})})}),sQ={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"},sX={status:"git.tabs.status",changes:"git.tabs.changes",history:"git.tabs.history",advanced:"git.tabs.advanced"},sZ=(0,s.memo)(function(e){let{activeTab:t,onTabChange:n}=e,a=(0,o.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:sz.map(e=>{let s=e===t,l=a(sX[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)(sY,{path:sQ[e]}),(0,r.jsx)("span",{children:l})]},e)})})});function s0(e){let{activeTab:t,onTabChange:n,className:a="",statusSection:s,quickActionsSection:l,changesSection:i,historySection:o,advancedSection:c}=e,{isMobile:d}=sJ();return d?(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden ".concat(a),"data-testid":"git-pane-mobile",children:[(0,r.jsx)(sZ,{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 s1={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"},s2=(0,s.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"})})}),s4=(0,s.memo)(function(e){let{onClick:t,disabled:n=!1,testId:a,className:s=""}=e,l=(0,o.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)(n1.A,{size:14,"aria-hidden":"true"}),l("git.askAi")]})}),s5=(0,s.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})}),s3=(0,s.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})}),s6={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"}},s9=(0,s.memo)(function(e){var t;let{gitStatus:n,statusLoading:a,statusError:l,onRefresh:i,refreshing:c=!1}=e,{isMobile:u}=sJ(),m=(0,o.c)("worktree"),x=(0,to.Ym)(),f=(0,s.useMemo)(()=>{let e=null==n?void 0:n.lastFetchAt;if(null==e)return m("git.currentStatus.lastFetchNever");let t=(0,en.fw)(new Date(e).toISOString(),(0,nf.M)(x));return t?m("git.currentStatus.lastFetch",{relative:t}):m("git.currentStatus.lastFetchNever")},[null==n?void 0:n.lastFetchAt,x,m]),h=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:i,disabled:c,className:"p-1 text-muted-foreground hover:text-foreground rounded disabled:opacity-50","aria-label":c?m("git.currentStatus.refreshing"):m("git.currentStatus.refresh"),"aria-busy":c,"data-testid":"git-status-refresh-button",children:c?(0,r.jsx)(d.y,{size:"sm",variant:"accent"}):(0,r.jsx)(s2,{})})]}),a&&!n&&(0,r.jsxs)("div",{className:"flex items-center gap-2 py-1",role:"status",children:[(0,r.jsx)(d.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:m("git.currentStatus.loading")})]}),l&&!n&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-status-error",children:l}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center flex-wrap ".concat(u?"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]})]}),h&&(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":h,title:m(s6[h].tooltipKey),children:m(s6[h].badgeKey)})]}),(0,r.jsx)("div",{className:"text-[11px] text-muted-foreground","data-testid":"git-status-last-fetch",title:m("git.currentStatus.lastFetchTooltip"),children:f}),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})]})]})]})]})}),s8=(0,s.memo)(function(e){let{progressState:t,operation:n,error:a,conflict:l,conflictFiles:i,hasUpstream:c,onFetch:u,onPull:m,onPush:x,onAbort:f,extraActions:h}=e,{isMobile:p}=sJ(),g=(0,o.c)("worktree"),b="running"===t,v=null!=a?a:g("git.network.failed"),[y,j]=(0,s.useState)(0);return(0,s.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:[u&&(0,r.jsx)("button",{type:"button",onClick:u,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:x,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:c?void 0:g("git.network.noUpstreamTooltip"),children:g("git.network.push")}),h]}),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)(d.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:f,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}),l&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-network-conflict",children:g("git.network.conflicts",{files:i.join(", ")})})]})}),s7=(0,s.memo)(function(e){let{title:t,testId:n,files:a,actionLabel:l,mode:i,defaultOpen:c,busy:d,onDiff:m,onToggleStage:x,onPreview:f}=e,h=(0,o.c)("worktree"),[p,g]=(0,s.useState)(c),[b,v]=(0,s.useState)(null),[y,j]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),S=(0,s.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 f(e,i);j(null!=t?t:"")}catch(e){C(h("git.changes.previewFailed"))}finally{k(!1)}},[b,f,i,h]);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?"▼":"▶"}),h("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:h("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(s1[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":h("git.changes.togglePreview",{path:e.path}),"aria-expanded":t,"data-testid":"git-changes-preview-toggle",children:t?"▼":"▶"}),(0,r.jsx)("button",{type:"button",onClick:()=>m(e.path,i),className:"shrink-0 px-1.5 py-0.5 text-xs text-accent-600 dark:text-accent-400 hover:underline","aria-label":h("git.changes.showDiff",{path:e.path}),"data-testid":"git-changes-diff-button",children:h("git.changes.diff")}),(0,r.jsx)("button",{type:"button",onClick:()=>x(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":h("git.changes.fileAction",{action:l,path:e.path}),"data-testid":"git-changes-toggle-button",children:l})]}),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)(u.y$,{size:"xs",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:h("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:h("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)(s5,{line:e},t))})}),y.split("\n").length>20&&(0,r.jsx)("button",{type:"button",onClick:()=>m(e.path,i),className:"mt-1 text-xs text-accent-600 dark:text-accent-400 hover:underline","data-testid":"git-changes-preview-more",children:h("git.changes.truncated")})]}))]})]},"".concat(e.status,":").concat(e.path))})})]})}),le=(0,s.memo)(function(e){var t,n,a;let{staged:s,loading:l,error:i,busy:c,commitMessage:d,amend:m,committing:x,commitError:f,onRefresh:h,onDiff:p,onPreview:g,onStage:b,onUnstage:v,onCommitMessageChange:y,onAmendChange:j,onCommit:w,onCommitAndPush:k}=e,{isMobile:N}=sJ(),C=(0,o.c)("worktree"),S=null!=(t=null==s?void 0:s.staged)?t:[],I=null!=(n=null==s?void 0:s.unstaged)?n:[],T=null!=(a=null==s?void 0:s.untracked)?a:[],E=!x&&d.trim().length>0&&(S.length>0||m),A=!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:h,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":C("git.changes.refresh"),children:(0,r.jsx)(s2,{})})]}),l&&!s&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2",role:"status",children:[(0,r.jsx)(u.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)(s7,{title:C("git.changes.staged"),testId:"git-staged-list",files:S,actionLabel:C("git.changes.unstage"),mode:"staged",defaultOpen:A,busy:c,onDiff:p,onPreview:g,onToggleStage:v}),(0,r.jsx)(s7,{title:C("git.changes.unstaged"),testId:"git-unstaged-list",files:I,actionLabel:C("git.changes.stage"),mode:"unstaged",defaultOpen:A,busy:c,onDiff:p,onPreview:g,onToggleStage:b}),(0,r.jsx)(s7,{title:C("git.changes.untracked"),testId:"git-untracked-list",files:T,actionLabel:C("git.changes.stage"),mode:"untracked",defaultOpen:A,busy:c,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)(u.Sc,{checked:m,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:!E,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(x?"git.changes.committing":"git.changes.commit")}),(0,r.jsx)("button",{type:"button",onClick:k,disabled:!E||c,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")})]})]}),f&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-commit-error",children:f})]})]})]})}),lt=(0,s.memo)(function(e){let{commits:t,isLoading:n,commitError:a,commitListOpen:l,onToggleCommitList:i,onRefresh:c,selectedCommit:u,onCommitSelect:m,inlineDiffCommit:x,inlineFiles:f,inlineFilesLoading:h,inlineFilesError:p,onToggleInlineDiff:g,onInlineDiffFile:b,changedFiles:v,isLoadingFiles:y,detailError:j,selectedFile:w,onFileSelect:k,diffContent:N,isLoadingDiff:C}=e,{isMobile:S}=sJ(),I=(0,o.c)("worktree"),[T,E]=(0,s.useState)(!0),[A,M]=(0,s.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:i,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:l?"▼":"▶"}),I("git.history.title")]}),(0,r.jsx)("button",{type:"button",onClick:c,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":I("git.history.refresh"),children:(0,r.jsx)(s2,{})})]}),l&&n&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-8",role:"status",children:[(0,r.jsx)(d.y,{size:"lg",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loading")})]}),l&&a&&!n&&(0,r.jsx)("div",{className:"px-3 py-4 text-sm text-danger-foreground",role:"alert",children:a}),l&&!n&&!a&&0===t.length&&(0,r.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:I("git.history.empty")}),!n&&!a&&t.length>0&&(0,r.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[l&&(0,r.jsx)("div",{className:"overflow-y-auto ".concat(u?"max-h-[40%] shrink-0":"flex-1"),children:(0,r.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>{let t=x===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(u===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":I("git.history.viewDiffFor",{hash:e.shortHash}),"aria-expanded":t,"data-testid":"git-commit-view-diff-button",children:t?I("git.history.hideDiff"):I("git.history.viewDiff")})]}),t&&(0,r.jsxs)("div",{className:"border-t border-border bg-muted/40","data-testid":"git-commit-inline-files",children:[h&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-3",role:"status",children:[(0,r.jsx)(d.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingChangedFiles")})]}),p&&(0,r.jsx)(s3,{message:p}),!h&&!p&&0===f.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("git.history.noChangedFiles")}),!h&&f.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:f.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&&u===e.hash?"bg-accent-50 dark:bg-accent-900/30":""),"aria-label":I("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(s1[t.status]),children:t.status}),(0,r.jsx)("span",{className:"font-mono text-foreground",children:t.path})]})},t.path))})]})]},e.hash)})})}),u&&(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:()=>E(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:T?"▼":"▶"}),I("git.history.changedFiles")]}),T&&(0,r.jsxs)(r.Fragment,{children:[j&&(0,r.jsx)(s3,{message:j}),y&&(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",role:"status",children:[(0,r.jsx)(d.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("git.history.loadingChangedFiles")})]}),!y&&!j&&0===v.length&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("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(s1[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:()=>M(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:A?"▼":"▶"}),I("git.history.diffLabel",{file:w})]}),A&&(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)(d.y,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:I("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)(s5,{line:e},t))})})}),!C&&!N&&!j&&(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:I("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?I("git.history.loadingDiff"):I("git.history.diffInFilePanel",{file:w})})]})]})]})});function ln(e){return"`"+e+"`"}let la={local:"git.branches.filterLocal",remote:"git.branches.filterRemote",all:"git.branches.filterAll"},lr=(0,s.memo)(function(e){let{branches:t,include:n,loading:a,error:l,busy:i,actionError:c,onIncludeChange:d,onRefresh:m,onCreate:x,onDelete:f}=e,{isMobile:h,onInsertToMessage:p}=sJ(),g=(0,o.c)("worktree"),b=(0,o.c)("common"),[v,y]=(0,s.useState)(!h),[j,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(""),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(!1),M=(0,s.useCallback)(()=>{0!==k.trim().length&&(x(k.trim(),C.trim()||void 0),w(!1),N(""),S(""))},[k,C,x]),R=(0,s.useCallback)(()=>{I&&(f(I.name,E),T(null),A(!1))},[I,E,f]);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:m,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":g("git.branches.refresh"),children:(0,r.jsx)(s2,{})})]})]}),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(la[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)(u.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{className:"sr-only",children:g("git.branches.loading")})]}),l&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-error",children:l}),c&&(0,r.jsx)("div",{className:"px-3 pb-2 text-xs text-danger-foreground",role:"alert","data-testid":"git-branches-action-error",children:c}),!a&&!l&&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=i||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:()=>{A(!1),T(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)(s4,{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?ln(n.trim()):e("git.aiPrompts.branchCreateBaseHead");return e("git.aiPrompts.branchCreate",{base:a,name:ln(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:M,disabled:i||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")})]})]})}),I&&(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:I.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)(u.Sc,{checked:E,onCheckedChange:e=>A(!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&&I&&(0,r.jsx)(s4,{className:"mr-auto",testId:"branch-delete-ask-ai",onClick:()=>{p(g(E?"git.aiPrompts.branchDeleteForce":"git.aiPrompts.branchDelete",{name:ln(I.name)})),T(null),A(!1)}}),(0,r.jsx)("button",{type:"button",onClick:()=>T(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:R,disabled:i,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")})]})]})})]})}),ls=(0,s.memo)(function(e){let{stashes:t,loading:n,error:a,busy:l,actionError:i,conflictNotice:c,hasRunningSession:d,onRefresh:m,onPush:x,onPop:f,onApply:h,onDrop:p}=e,{isMobile:g,onInsertToMessage:b}=sJ(),v=(0,o.c)("worktree"),y=(0,o.c)("common"),[j,w]=(0,s.useState)(!g),[k,N]=(0,s.useState)(""),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.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)(s4,{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:m,className:"p-1 text-muted-foreground hover:text-foreground rounded","aria-label":v("git.stash.refresh"),children:(0,r.jsx)(s2,{})})]})]}),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}),i&&(0,r.jsx)("div",{className:"text-xs text-danger-foreground",role:"alert","data-testid":"git-stash-action-error",children:i}),c&&(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:c}),b&&(0,r.jsx)(s4,{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,c))})]}),(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)(u.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:l,onClick:()=>{x(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:l,onClick:()=>h(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:l,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-pop-button",children:v("git.stash.pop")}),(0,r.jsx)("button",{type:"button",disabled:l,onClick:()=>T(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!==I&&(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@","{",I,"}",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:l,onClick:()=>{p(I),T(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:()=>T(null),className:"px-2 py-1 text-xs rounded border border-input hover:bg-muted",children:y("cancel")})]})]})]})}),ll={soft:"git.danger.modeSoft",mixed:"git.danger.modeMixed",hard:"git.danger.modeHard"},li=(0,s.memo)(function(e){let{selectedCommit:t,busy:n,actionError:a,conflictNotice:l,currentBranch:i,aheadCount:c,hasRunningSession:d,onReset:m,onRevert:x,onForcePush:f}=e,{isMobile:h,onInsertToMessage:p}=sJ(),g=(0,o.c)("worktree"),b=(0,o.c)("common"),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)("mixed"),[k,N]=(0,s.useState)(!0),[C,S]=(0,s.useState)(""),[I,T]=(0,s.useState)(!1),[E,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.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}),l&&(0,r.jsx)("div",{className:"text-xs text-warning-foreground",role:"status","data-testid":"git-danger-zone-conflict",children:l}),(0,r.jsxs)("div",{className:"flex ".concat(h?"flex-col":"flex-row"," gap-2"),children:[(0,r.jsx)("button",{type:"button",onClick:()=>T(!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:()=>A(!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")}),f&&(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")})]}),I&&(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)(u.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)(u.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)(u.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)(u.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)(u.CU,{value:e,"data-testid":"reset-mode-".concat(e)}),g(ll[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!=i?i:""}),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)(s4,{className:"mr-auto",testId:"reset-ask-ai",disabled:z,onClick:()=>{O&&(p("hard"===j?g("git.aiPrompts.resetHard",{target:ln(O)}):g("git.aiPrompts.reset",{target:ln(O),mode:j})),T(!1),S(""))}}),(0,r.jsx)("button",{type:"button",disabled:n||z||"hard"===j&&C!==(null!=i?i:""),onClick:()=>{O&&(m(O,j,"hard"===j?C:void 0),T(!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:()=>{T(!1),S("")},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),E&&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)(u.Sc,{checked:M,onCheckedChange:e=>R(!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)(s4,{className:"mr-auto",testId:"revert-ask-ai",onClick:()=>{p(g("git.aiPrompts.revert",{commit:ln(t.slice(0,7))})),A(!1),R(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{x(t,M),A(!1),R(!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:()=>{A(!1),R(!1)},className:"px-2 py-1 text-xs rounded border border-border hover:bg-muted",children:b("cancel")})]})]}),L&&f&&(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)(u.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)(s4,{className:"mr-auto",testId:"force-push-ask-ai",onClick:()=>{p(function(e,t){let{branch:n,ahead:a}=t,r=n?ln(n):e("git.aiPrompts.forcePushCurrentBranch");return e("number"==typeof a&&a>0?"git.aiPrompts.forcePushAhead":"git.aiPrompts.forcePush",{branchRef:r,upstream:ln("origin/".concat(null!=n?n:"<branch>")),ahead:null!=a?a:0})}(g,{branch:i,ahead:null!=c?c:null})),P(!1)}}),(0,r.jsx)("button",{type:"button",disabled:n,onClick:()=>{f(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")})]})]})]})}),lo=(0,s.memo)(function(e){var t,n,a,l;let{worktreeId:i,onDiffSelect:c,isMobile:d=!1,worktree:m,onInsertToMessage:x,className:f=""}=e,h=(0,o.c)("worktree"),{activeTab:p,setActiveTab:g,historyOpen:b,toggleHistory:v,advancedOpen:y,toggleAdvanced:j}=function(){let{value:e,setValue:t,isAvailable:n}=(0,sO.V)({key:sB.activeTab,defaultValue:"status",validate:sV}),{value:a,setValue:r}=(0,sO.V)({key:sB.historyOpen,defaultValue:!0,validate:sU}),{value:l,setValue:i}=(0,sO.V)({key:sB.advancedOpen,defaultValue:!1,validate:sU}),o=(0,s.useCallback)(e=>t(e),[t]);return{activeTab:e,setActiveTab:o,historyOpen:a,toggleHistory:(0,s.useCallback)(()=>r(e=>!e),[r]),advancedOpen:l,toggleAdvanced:(0,s.useCallback)(()=>i(e=>!e),[i]),isPersistent:n}}(),w=Object.values(null!=(n=null==m?void 0:m.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,s.useState)(null),[a,r]=(0,s.useState)(!0),[l,i]=(0,s.useState)(null),o=(0,s.useCallback)(async()=>{i(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/status"));if(!t.ok){let e=await t.json().catch(()=>({}));i(e.error||"Failed to fetch git status");return}let a=await t.json();n(a)}catch(e){i("Failed to fetch git status")}finally{r(!1)}},[e]);return(0,s.useEffect)(()=>{o()},[o]),{gitStatus:t,statusLoading:a,statusError:l,fetchStatus:o}}(i),{commits:I,selectedCommit:T,changedFiles:E,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,selectedFile:P,diffContent:D,isLoading:F,isLoadingFiles:O,isLoadingDiff:z,commitError:_,detailError:B,setDiffContent:V,fetchCommits:U,handleCommitSelect:H,handleFileSelect:K,handleToggleInlineDiff:W,handleInlineDiffFile:q,handleRefresh:$}=function(e,t){let[n,a]=(0,s.useState)([]),[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)([]),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!0),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(null),M=(0,s.useCallback)(async()=>{w(!0),T(null);try{let t=await fetch("/api/worktrees/".concat(e,"/git/log"));if(!t.ok){let e=await t.json();T(e.error||"Failed to fetch commit history");return}let n=await t.json();a(n.commits)}catch(e){T("Failed to fetch commit history")}finally{w(!1)}},[e]),R=(0,s.useCallback)(async t=>{N(!0),o([]),b(null),y(null),A(null);try{let n=await fetch("/api/worktrees/".concat(e,"/git/show/").concat(t));if(!n.ok){let e=await n.json();A(e.error||"Failed to fetch commit details");return}let a=await n.json();o(a.files)}catch(e){A("Failed to fetch commit details")}finally{N(!1)}},[e]),L=(0,s.useCallback)(async(n,a)=>{S(!0),y(null),A(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();A(e.error||"Failed to fetch diff");return}let s=await r.json();y(s.diff),t(s.diff,a)}catch(e){A("Failed to fetch diff")}finally{S(!1)}},[e,t]);(0,s.useEffect)(()=>{M()},[M]);let P=(0,s.useCallback)(e=>{l(e),R(e)},[R]),D=(0,s.useCallback)(e=>{r&&(b(e),L(r,e))},[r,L]),F=(0,s.useCallback)(async t=>{if(c===t){d(null),m([]),p(null);return}d(t),m([]),p(null),f(!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{f(!1)}},[e,c]),O=(0,s.useCallback)((e,t)=>{l(e),b(t),o(u),L(e,t)},[u,L]),z=(0,s.useCallback)(()=>{l(null),o([]),b(null),y(null),A(null),M()},[M]);return{commits:n,selectedCommit:r,changedFiles:i,inlineDiffCommit:c,inlineFiles:u,inlineFilesLoading:x,inlineFilesError:h,selectedFile:g,diffContent:v,isLoading:j,isLoadingFiles:k,isLoadingDiff:C,commitError:I,detailError:E,setDiffContent:y,fetchCommits:M,handleCommitSelect:P,handleFileSelect:D,handleToggleInlineDiff:F,handleInlineDiffFile:O,handleRefresh:z}}(i,c),G=(0,s.useCallback)(async()=>{await U(),await S()},[U,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,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null),j=(0,s.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();l(n)}catch(e){d("Failed to fetch changes")}finally{o(!1)}},[e]);(0,s.useEffect)(()=>{j()},[j]);let w=(0,s.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,s.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,s.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:x,amend:h})});if(!t.ok){let e=await t.json().catch(()=>({}));return y(e.error||"Failed to commit"),!1}return f(""),p(!1),await j(),await a(),!0}catch(e){return y("Failed to commit"),!1}},[e,x,h,j,a]),C=(0,s.useCallback)(async()=>{b(!0);try{await N()}finally{b(!1)}},[N]),S=(0,s.useCallback)(async e=>{b(!0);try{await N()&&await e()}finally{b(!1)}},[N]);return{staged:r,stagedLoading:i,stagedError:c,opBusy:u,commitMessage:x,setCommitMessage:f,amend:h,setAmend:p,committing:g,changesCommitError:v,fetchStaged:j,handleStage:w,handleUnstage:k,handleChangesDiff:(0,s.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,s.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}}(i,{onWorkingDiff:(0,s.useCallback)((e,t)=>{V(e),c(e,t)},[V,c]),onCommitted:G}),{branches:em,branchInclude:ex,branchesLoading:ef,branchesError:eh,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,s.useState)([]),[l,i]=(0,s.useState)("local"),[o,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)(null),p=(0,s.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,s.useEffect)(()=>{p(l)},[p,l]);let g=(0,s.useCallback)(e=>{i(e)},[]),b=(0,s.useCallback)(()=>{p(l)},[p,l]),v=(0,s.useCallback)(async(t,a)=>{x(!0),h(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(()=>({}));h(e.error||"Failed to checkout branch");return}await Promise.all([n(),p(l)])}catch(e){h("Failed to checkout branch")}finally{x(!1)}},[e,l,n,p]),y=(0,s.useCallback)(async(t,n)=>{x(!0),h(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(()=>({}));h(e.error||"Failed to create branch");return}await p(l)}catch(e){h("Failed to create branch")}finally{x(!1)}},[e,l,p]),j=(0,s.useCallback)(async(t,n)=>{x(!0),h(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(()=>({}));h(e.error||"Failed to delete branch");return}await p(l)}catch(e){h("Failed to delete branch")}finally{x(!1)}},[e,l,p]);return{branches:a,branchInclude:l,branchesLoading:o,branchesError:d,branchBusy:m,branchActionError:f,fetchBranches:p,handleBranchIncludeChange:g,handleBranchesRefresh:b,handleCheckout:v,handleBranchCreate:y,handleBranchDelete:j}}(i,{onCheckoutCascade:(0,s.useCallback)(async()=>{await Promise.all([S(),es(),U()])},[S,es,U])}),{stashes:eN,stashLoading:eC,stashError:eS,stashBusy:eI,stashActionError:eT,stashConflictNotice:eE,fetchStash:eA,handleStashPush:eM,handleStashPop:eR,handleStashApply:eL,handleStashDrop:eP}=function(e,t){let{onStashMutated:n}=t,[a,r]=(0,s.useState)([]),[l,i]=(0,s.useState)(!0),[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null),[f,h]=(0,s.useState)(null),p=(0,s.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{i(!1)}},[e]);(0,s.useEffect)(()=>{p()},[p]);let g=(0,s.useCallback)(async()=>{await Promise.all([p(),n()])},[p,n]),b=(0,s.useCallback)(async(e,t,n)=>{u(!0),x(null),h(null);try{let a=await fetch(e,t),r=await a.json().catch(()=>({}));if(!a.ok)return void x(r.error||n);if(r.conflict){let e=Array.isArray(r.conflictFiles)?r.conflictFiles.join(", "):"",t=r.stashRetained?" (stash retained)":"";h("Stash operation produced conflicts: ".concat(e).concat(t))}await g()}catch(e){x(n)}finally{u(!1)}},[g]),v=(0,s.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,s.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:l,stashError:o,stashBusy:d,stashActionError:m,stashConflictNotice:f,fetchStash:p,handleStashPush:v,handleStashPop:y,handleStashApply:(0,s.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,s.useCallback)(t=>{b("/api/worktrees/".concat(e,"/git/stash/").concat(t),{method:"DELETE"},"Failed to drop stash")},[e,b])}}(i,{onStashMutated:(0,s.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,s.useState)(!1),[l,i]=(0,s.useState)(null),[o,c]=(0,s.useState)(null);return{dangerBusy:a,dangerActionError:l,dangerConflictNotice:o,handleReset:(0,s.useCallback)(async(t,a,s)=>{r(!0),i(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(()=>({}));i(e.error||"Failed to reset");return}await n()}catch(e){i("Failed to reset")}finally{r(!1)}},[e,n]),handleRevert:(0,s.useCallback)(async(t,a)=>{r(!0),i(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(()=>({}));i(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){i("Failed to revert")}finally{r(!1)}},[e,n])}}(i,{onHeadMoved:(0,s.useCallback)(async()=>{await Promise.all([S(),es(),eb(ex),U()])},[S,es,eb,ex,U])}),{operation:eB,progressState:eV,error:eU,errorReason:eH,conflict:eK,conflictFiles:eW,runFetch:eq,runPull:e$,runPush:eG,abort:eJ}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onCascade:n}=t,[a,r]=(0,s.useState)(null),[l,i]=(0,s.useState)("idle"),[o,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(!1),[f,h]=(0,s.useState)([]),p=(0,s.useRef)(null),g=(0,s.useRef)(n);(0,s.useEffect)(()=>{g.current=n},[n]),(0,s.useEffect)(()=>()=>{var e;null==(e=p.current)||e.abort()},[]);let b=(0,s.useCallback)(async(t,n,a)=>{var s,l,o;c(null),u(null),x(!1),h([]),r(t),i("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((l=null==e?void 0:e.error,"string"==typeof l&&l.length>0?l:null)),i("error");return}let o=await r.json().catch(()=>({success:!0}));"pull"===t&&(null==o?void 0:o.conflict)&&(x(!0),h(Array.isArray(o.conflictFiles)?o.conflictFiles:[])),i("idle")}catch(e){e instanceof Error&&"AbortError"===e.name?i("idle"):(c(null),u(null),i("error"))}finally{r(null),p.current=null,null==(o=g.current)||o.call(g,t)}},[e]),v=(0,s.useCallback)(e=>{let t={prune:!0===e.prune};return void 0!==e.remote&&(t.remote=e.remote),b("fetch","fetch",t)},[b]),y=(0,s.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:l,error:o,errorReason:d,conflict:m,conflictFiles:f,runFetch:v,runPull:y,runPush:(0,s.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,s.useCallback)(()=>{var e;null==(e=p.current)||e.abort()},[])}}(i,{onCascade:(0,s.useCallback)(e=>{S(),eb(ex),"pull"===e&&(es(),U())},[S,eb,ex,es,U])}),eY="auth_failed"===eH?h("git.network.authFailedGuidance"):"protected_branch"===eH?h("git.danger.protectedBranchWarning"):eU,eQ="running"===eV&&("push"===eB||"pull"===eB),eX=(null==k?void 0:k.aheadBehind)!=null,eZ=(0,s.useCallback)(()=>{eq({})},[eq]),e0=(0,s.useCallback)(()=>eu(()=>eG({setUpstream:!eX})),[eu,eG,eX]);nE({intervalMs:5e3,enabled:"running"!==eV,onPoll:S});let e1=(0,s.useMemo)(()=>({isMobile:d,onDiffSelect:c,onInsertToMessage:x}),[d,c,x]),e2=(0,r.jsx)(s9,{gitStatus:k,statusLoading:N,statusError:C,onRefresh:eZ,refreshing:"running"===eV}),e4=(0,r.jsx)(s8,{progressState:eV,operation:eB,error:eY,conflict:eK,conflictFiles:eW,hasUpstream:eX,onPull:()=>e$({}),onPush:()=>eG({setUpstream:!eX}),onAbort:eJ,extraActions:(0,r.jsx)(sW,{branches:em,busy:ep||eQ,actionError:eg,hasRunningSession:w,isMobile:d,onCheckout:ej})}),e5=(0,r.jsx)(le,{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)(lt,{commits:I,isLoading:F,commitError:_,commitListOpen:b,onToggleCommitList:v,onRefresh:$,selectedCommit:T,onCommitSelect:H,inlineDiffCommit:A,inlineFiles:M,inlineFilesLoading:R,inlineFilesError:L,onToggleInlineDiff:W,onInlineDiffFile:q,changedFiles:E,isLoadingFiles:O,detailError:B,selectedFile:P,onFileSelect:K,diffContent:D,isLoadingDiff:z}),e6=(0,r.jsxs)(sq,{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:h("git.remote")}),(0,r.jsx)("div",{children:(0,r.jsx)(u.$n,{variant:"ghost",type:"button",onClick:()=>eq({}),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:h("git.network.fetch")})})]}),(0,r.jsx)(lr,{branches:em,include:ex,loading:ef,error:eh,busy:ep||eQ,actionError:eg,onIncludeChange:ev,onRefresh:ey,onCreate:ew,onDelete:ek}),(0,r.jsx)(ls,{stashes:eN,loading:eC,error:eS,busy:eI||eQ,actionError:eT,conflictNotice:eE,hasRunningSession:w,onRefresh:eA,onPush:eM,onPop:eR,onApply:eL,onDrop:eP}),(0,r.jsx)(li,{selectedCommit:T,busy:eD||eQ,actionError:eF,conflictNotice:eO,currentBranch:null!=(a=null==k?void 0:k.currentBranch)?a:null,aheadCount:null!=(l=null==k||null==(t=k.aheadBehind)?void 0:t.ahead)?l:null,hasRunningSession:w,onReset:ez,onRevert:e_,onForcePush:e=>eG(e?{forceWithLease:!0}:{force:!0})})]});return(0,r.jsx)(sG,{value:e1,children:(0,r.jsx)(s0,{activeTab:p,onTabChange:g,className:f,statusSection:e2,quickActionsSection:e4,changesSection:e5,historySection:e3,advancedSection:e6})})}),lc=(0,s.memo)(function(e){let{worktreeId:t,worktree:n,onWorktreeUpdate:a}=e,[l,i]=(0,s.useState)(!1),c=(0,o.c)("worktree"),d=(0,s.useRef)(null==n?void 0:n.id),u=(0,s.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:l,onToggleLogs:()=>i(!l),onWorktreeUpdate:a})}):(0,r.jsx)("div",{className:"text-muted-foreground text-center py-8",children:c("detail.loadingInfo")})}),ld=(0,s.memo)(function(e){let{activeTab:t,worktreeId:n,worktree:a,messages:s,cliToolId:l,instanceId:i,onFilePathClick:c,onFileSelect:d,onWorktreeUpdate:u,onNewFile:m,onNewDirectory:x,onRename:f,onDelete:h,onUpload:p,onMove:g,onFileTreeReset:b,refreshTrigger:v,fileSearch:y,showToast:j,selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,disableAutoFollow:R,historySubTab:L,onHistorySubTabChange:P,onDiffSelect:D,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:U,useInstanceManagement:H,instances:K,onInstancesChange:W,visibleInstanceIds:q,onToggleInstanceVisible:$,verification:G,toolsSubTabRequest:J,onSurfaceModeChange:Y,directInputOpen:Q}=e,X=(0,o.c)("worktree");switch(t){case"terminal":return(0,r.jsx)(T.t,{componentName:"TerminalDisplay",children:(0,r.jsx)(nt,{worktreeId:n,cliToolId:l,instanceId:i,disableAutoFollow:R,onSurfaceModeChange:Y,directInputOpen:Q})});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"===L?"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:X("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"===L?"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:X("detail.subTabGit")})]}),"message"===L?(0,r.jsx)(T.t,{componentName:"HistoryPane",children:(0,r.jsx)(nn.bl,{messages:s,worktreeId:n,onFilePathClick:c,className:"flex-1 min-h-0",showToast:j,onInsertToMessage:F,showArchived:O,onShowArchivedChange:z,historyDisplayLimit:_,onHistoryDisplayLimitChange:B,historyUserOnly:V,onHistoryUserOnlyChange:U})}):(0,r.jsx)(T.t,{componentName:"GitPane",children:(0,r.jsx)(lo,{worktreeId:n,onDiffSelect:D,isMobile:!0,worktree:null!=a?a:void 0,onInsertToMessage:F,className:"flex-1 min-h-0"})})]});case"files":var Z;return(0,r.jsx)(T.t,{componentName:"FileTreeView",children:(0,r.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,r.jsx)(nB,{query:y.query,mode:y.mode,isSearching:y.isSearching,error:y.error,onQueryChange:y.setQuery,onModeChange:y.setMode,onClear:y.clearSearch}),(0,r.jsx)(nD,{worktreeId:n,onFileSelect:d,onNewFile:m,onNewDirectory:x,onRename:f,onDelete:h,onUpload:p,onMove:g,onResetView:b,refreshTrigger:v,pollingEnabled:"files"===t,searchQuery:y.query,searchMode:y.mode,searchResults:null==(Z=y.results)?void 0:Z.results,className:"flex-1 min-h-0"})]})});case"memo":return(0,r.jsx)(T.t,{componentName:"NotesAndLogsPane",children:(0,r.jsx)(sF,{worktreeId:n,className:"h-full",selectedAgents:w,onSelectedAgentsChange:k,availableAgents:N,maxAgents:C,persistToServer:S,vibeLocalModel:I,onVibeLocalModelChange:E,vibeLocalContextWindow:A,onVibeLocalContextWindowChange:M,onInsertToMessage:F,useInstanceManagement:H,instances:K,onInstancesChange:W,visibleInstanceIds:q,onToggleInstanceVisible:$,modelByInstance:lv(null==a?void 0:a.sessionStatusByInstance),composerTargetInstanceId:i,verification:G,requestedSubTab:J})});case"info":return(0,r.jsx)(lc,{worktreeId:n,worktree:a,onWorktreeUpdate:u});default:return null}}),lu="v".concat("0.41.1"),lm=[{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 lx(e,t,n){return(0,x.Mq)(e,(0,tC.px)(n?null==t?void 0:t[n]:void 0))}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 lh(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 lp(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 lg(e,t,n,a){var r;let s=lp(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 lb(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=lp(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}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,l]=(0,s.useState)(!1),[i,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>{a()&&e&&(o(e.description||""),l(!1))},[n,e]);let u=(0,s.useCallback)(async()=>{if(e){d(!0);try{let n=await tm.y.updateDescription(e.id,i);t(n),l(!1)}catch(e){console.error("Failed to save description:",e)}finally{d(!1)}}},[e,i,t]),m=(0,s.useCallback)(()=>{o((null==e?void 0:e.description)||""),l(!1)},[e]);return{isEditing:r,text:i,setText:o,isSaving:c,handleSave:u,handleCancel:m,startEditing:(0,s.useCallback)(()=>{l(!0)},[])}}let lj=(0,s.memo)(function(e){var t,n;let{worktreeId:a,worktree:l,cardClassName:i,descriptionEditor:c,showLogs:d,onToggleLogs:m,onWorktreeUpdate:x}=e,{isEditing:f,text:h,setText:p,isSaving:g,handleSave:b,handleCancel:v,startEditing:y}=c,j=(0,o.c)("worktree"),w=(0,o.c)("common"),{copied:k,markCopied:N}=(0,e9.q)(),{copied:C,markCopied:S}=(0,e9.q)(),I=(0,s.useCallback)(async()=>{try{await (0,eX.l)(l.path),N()}catch(e){}},[l.path,N]),T=(0,s.useCallback)(async()=>{try{await (0,eX.l)(l.repositoryPath),S()}catch(e){}},[l.repositoryPath,S]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:i,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:l.name})]}),(0,r.jsxs)("div",{className:i,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)(u.$n,{variant:"ghost",type:"button",onClick:T,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)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eH.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-base text-foreground",children:null!=(t=l.repositoryDisplayName)?t:l.repositoryName}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:l.repositoryPath})]}),(0,r.jsxs)("div",{className:i,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)(u.$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)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eH.A,{className:"w-3.5 h-3.5"})})]}),(0,r.jsx)("p",{className:"text-sm text-foreground break-all font-mono",children:l.path})]}),(0,r.jsxs)("div",{className:i,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=l.status)?n:"",onChange:async e=>{let t=e.target.value;try{let e=await fetch("/api/worktrees/".concat(l.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:""===t?null:t})});if(e.ok&&x){let t=await e.json();x(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:lm.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:i,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")}),!f&&(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")})]}),f?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("textarea",{value:h,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)(u.$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)(u.$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:l.description?(0,r.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:l.description}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground italic",children:j("detail.noDescription")})})]}),l.link&&(0,r.jsxs)("div",{className:i,children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-muted-foreground mb-1",children:j("detail.link")}),(0,r.jsx)("a",{href:l.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-accent-600 hover:underline break-all",children:l.link})]}),l.updatedAt&&(0,r.jsxs)("div",{className:i,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(l.updatedAt).toLocaleString()})]}),(0,r.jsx)(tp,{version:lu,className:i}),(0,r.jsx)(tk,{className:i}),(0,r.jsxs)("div",{className:i,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:m,className:"text-sm text-accent-600 hover:text-accent-800",children:d?j("detail.hide"):j("detail.show")})]}),d&&(0,r.jsx)(tx,{worktreeId:a})]})]})}),lw=(0,s.memo)(function(e){var t,n,a,l,i,c,d;let{worktreeName:f,repositoryName:p,description:g,status:b,gitStatus:v,onInfoClick:y,hasUpdate:j,worktreeStatus:w,onWorktreeStatusChange:k,sessionStatusByCli:C,sessionStatusByInstance:S,instances:I,activeInstanceId:T,onActiveInstanceChange:E,onAgentDragStart:A,onAgentDragEnd:M,onKillSession:R,verificationChip:L,agentSessionByInstance:P}=e,D=(0,o.c)("worktree"),F=(0,to.Ym)(),O=(0,o.c)("common"),z=tc.sb[b],_=z?D(z):void 0,[B,V]=(0,s.useState)(null),U=null==I?void 0:I.find(e=>e.id===T),H=!!T&&null!=(i=null!=(l=null==S||null==(t=S[T])?void 0:t.isRunning)?l:U?null==C||null==(n=C[U.cliTool])?void 0:n.isRunning:void 0)&&i,K=lx(b,C,null==U?void 0:U.cliTool),W=(0,s.useCallback)((e,t)=>{e.dataTransfer.setData(ea,t),e.dataTransfer.effectAllowed="move",V(t),null==A||A(t)},[A]),q=(0,s.useCallback)(()=>{V(null),null==M||M()},[M]),$=g?(0,h.W5)(g,50):null,G=(null!=I?I:[]).map(e=>{var t;return{item:e,status:(0,tC.kA)(null!=(t=null==S?void 0:S[e.id])?t:null==C?void 0:C[e.cliTool]),isActive:e.id===T}}),J=new Set((null!=I?I:[]).filter(e=>{var t;return(0,tC.px)(null!=(t=null==S?void 0:S[e.id])?t:null==C?void 0:C[e.cliTool])}).map(e=>e.id)),Y=(e,t)=>(0,x.Mq)(t,J.has(e))?O(x.rH):O("status.".concat(t)),X=(e,t)=>(0,x.Mq)(t,J.has(e))?x.Jd:void 0,et=(null!=I?I:[]).some(e=>{var t,n;return(null==(t=null!=(n=null==S?void 0:S[e.id])?n:null==C?void 0:C[e.cliTool])?void 0:t.awaitingInstruction)===!0}),en=!!R&&H,er=(0,tf.Y)(),es="".concat(null!=(c=null==(a=er.updateInfo)?void 0:a.latestVersion)?c:"",":").concat(er.hasUpdate,":").concat(er.state),el=[F,f,p,null!=$?$:"",null!=(d=null==v?void 0:v.currentBranch)?d:"",(null==v?void 0:v.isDirty)?"dirty":"",en?"end":"",et?"awaiting":"",es,...G.map(e=>"".concat(e.item.id,":").concat((0,Q.sw)(e.item),":").concat(e.status,":").concat(e.isActive?"active":"")+(J.has(e.item.id)?":unclassified":""))].join("\n"),ei=(0,s.useRef)(null),eo=(0,s.useRef)(null),ec=function(e,t,n,a,r){let[l,i]=(0,s.useState)(()=>({key:n,pillBudget:4,squeezed:!1})),o=l;return l.key!==n&&i(o={key:n,pillBudget:4,squeezed:!1}),(0,s.useLayoutEffect)(()=>{let e=t.current;e&&!l.squeezed&&function(e){if(e.scrollWidth>e.clientWidth+1)return!0;for(let t of Array.from(e.querySelectorAll("*")))if(!(t.scrollWidth<=t.clientWidth+1)&&"visible"===getComputedStyle(t).overflowX)return!0;return!1}(e)&&i(e=>{if(e.squeezed)return e;let t=Math.min(e.pillBudget,a);return t>0?{...e,pillBudget:t-1}:{...e,squeezed:!0}})},[t,l,a,r]),(0,s.useEffect)(()=>{let t=e.current;if(!t||"undefined"==typeof ResizeObserver)return;let n=null,a=null,r=new ResizeObserver(e=>{var t;let r=null==(t=e[e.length-1])?void 0:t.contentRect;if(!r)return;let s=r.width!==n;(s||r.height!==a)&&(n=r.width,a=r.height,i(e=>s?{key:e.key,pillBudget:4,squeezed:!1}:{...e}))});return r.observe(t),()=>r.disconnect()},[e]),{pillBudget:o.pillBudget,squeezed:o.squeezed}}(ei,eo,el,G.filter(td.Lm).length,L);return(0,r.jsxs)("div",{ref:ei,"data-testid":"desktop-header",className:"flex items-center justify-between gap-3 px-4 py-3 bg-surface border-b border-border",children:[(0,r.jsxs)("div",{ref:eo,"data-testid":"desktop-header-identity",className:"flex items-center gap-3 min-w-0".concat(ec.squeezed?" overflow-x-clip":""),children:[(0,r.jsx)(m.m,{"data-testid":"desktop-status-indicator",status:b,size:"lg",label:K?O(x.rH):_,className:K?x.Jd:void 0,"data-unclassified":K?"true":void 0}),(0,r.jsxs)("div",{className:"flex flex-col min-w-[6rem] shrink-4",children:[(0,r.jsx)("h1",{className:"text-lg font-semibold text-foreground truncate max-w-[200px] leading-tight",children:f}),(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:p}),v&&"(unknown)"!==v.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:v.currentBranch,"data-testid":"desktop-branch-name",children:(0,h.W5)(v.currentBranch,30)}),v.isDirty&&(0,r.jsx)("span",{className:"text-warning",title:D("git.uncommittedChanges"),children:"*"})]}),$&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,r.jsx)("span",{className:"truncate max-w-[300px] text-muted-foreground",title:g,children:$})]})]})]}),L&&(0,r.jsx)("div",{className:"min-w-0 w-[360px] max-w-max",children:L})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0 max-w-full","data-testid":"desktop-header-controls",children:[I&&I.length>0&&(()=>{var e,t,n,a;let s=(0,td.Uw)(G,ec.pillBudget),l=s.filter(e=>"overflow"===e.slot),i=null!=(a=null!=(n=null==(e=l.find(e=>"running"===e.status||"generating"===e.status))?void 0:e.status)?n:null==(t=l.find(e=>"waiting"===e.status))?void 0:t.status)?a:null;return(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0".concat(ec.squeezed?" overflow-x-clip":""),"data-testid":"desktop-agent-status-row",children:[s.map(e=>{var t;if("overflow"===e.slot)return null;let n=e.item,a=(0,Q.sw)(n),s=Y(n.id,e.status),l=X(n.id,e.status),i=D("detail.statusPill",{label:a,status:s}),o=null==S?void 0:S[n.id],c=null==P?void 0:P[n.id],d=lf(null==o?void 0:o.model,null==o?void 0:o.reasoningEffort,null==c||null==(t=c.session)?void 0:t.agent),u=d?D("detail.statusPillWithModel",{label:a,status:s,model:d}):i,x=lg(null==c?void 0:c.session,null==c?void 0:c.context,D,F),f=x?D("detail.statusPillWithUsage",{base:u,usage:x}):u,h=lh(null==o?void 0:o.eventSource,D),p=h?D("detail.statusPillWithSource",{base:f,source:h}):f,g=e.isActive,b={draggable:!0,onDragStart:e=>W(e,n.id),onDragEnd:q},v=B===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==E?void 0:E(n.id),...b,"aria-label":p,title:p,"aria-pressed":g,className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(g?"bg-accent-100 dark:bg-accent-900/30 text-accent-900 dark:text-accent-100":"hover:bg-muted text-foreground").concat(v),children:[(0,r.jsx)(m.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:l}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:i})]},n.id):(0,r.jsx)(ee.m_,{content:p,placement:"bottom",children:(0,r.jsx)("button",{type:"button","data-testid":"desktop-agent-status-".concat(n.id),onClick:()=>null==E?void 0:E(n.id),...b,"aria-label":p,"aria-pressed":g,className:"flex items-center justify-center w-6 h-6 rounded-full transition-colors ".concat(g?"bg-accent-100 dark:bg-accent-900/30":"hover:bg-muted").concat(v),children:(0,r.jsx)(m.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:l})})},n.id)}),l.length>0&&(0,r.jsxs)(Z.rI,{children:[(0,r.jsx)(Z.ty,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","data-testid":"desktop-agent-status-overflow","aria-label":D("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)(m.m,{status:i,size:"sm","aria-hidden":!0,title:void 0}),"+",l.length]})}),(0,r.jsx)(Z.SQ,{align:"end",children:l.map(e=>{let t=e.item,n=D("detail.statusPill",{label:(0,Q.sw)(t),status:Y(t.id,e.status)});return(0,r.jsxs)(Z._2,{"data-testid":"desktop-agent-overflow-".concat(t.id),onSelect:()=>null==E?void 0:E(t.id),children:[(0,r.jsx)(m.m,{status:e.status,size:"sm","aria-hidden":!0,title:void 0,className:X(t.id,e.status)}),(0,r.jsx)("span",{className:"whitespace-nowrap",children:n})]},t.id)})})]}),et&&(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:D("awaitingInstruction.label"),children:D("awaitingInstruction.badge")})]})})(),en&&(0,r.jsxs)(u.$n,{variant:"ghost",type:"button",onClick:R,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":D("terminal.endSession"),"data-testid":"desktop-kill-session",children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✕"}),O("end")]}),k&&(0,r.jsx)("select",{value:null!=w?w:"",onChange:e=>{let t=e.target.value;k(""===t?null:t)},onClick:e=>e.stopPropagation(),className:"flex-shrink-0 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":D("detail.worktreeStatusLabel"),children:lm.map(e=>{var t;return(0,r.jsx)("option",{value:null!=(t=e.value)?t:"",children:D(e.labelKey)},e.labelKey)})}),(0,r.jsx)(tI.H,{}),(0,r.jsx)(tS.g,{}),(0,r.jsxs)(u.$n,{variant:"ghost",type:"button",onClick:y,className:"relative flex flex-shrink-0 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":D("detail.viewInfo"),"data-testid":"desktop-info-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:"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:D("detail.info")}),j&&(0,r.jsx)(N,{"data-testid":"info-update-indicator",className:"absolute top-0 right-0","aria-label":D("tabs.updateAvailable")})]})]})]})}),lk=(0,s.memo)(function(e){let{worktreeId:t,worktree:n,isOpen:a,onClose:l,onWorktreeUpdate:i}=e,[c,d]=(0,s.useState)(!1),u=(0,o.c)("worktree"),m=(0,s.useRef)(a),x=ly(n,i,a,()=>{let e=a&&!m.current;return m.current=a,e});return n?(0,r.jsx)(tN.a,{isOpen:a,onClose:l,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:x,showLogs:c,onToggleLogs:()=>d(!c),onWorktreeUpdate:i})})}):null}),lN=(0,s.memo)(function(){let e=(0,o.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)(u.y$,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:e("detail.loading")})]})})}),lC=(0,s.memo)(function(e){let{message:t,onRetry:n}=e,a=(0,o.c)("worktree"),s=(0,o.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)(u.$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")})]})})});var lS=n(72115);let lI=(0,s.memo)(function(e){let{activityPane:t,rightPane:n,activityPaneWidth:a=18,minPaneWidth:l=10,maxPaneWidth:i=60,onActivityPaneResize:c,className:d=""}=e,u=(0,s.useRef)(null),m=(0,o.c)("worktree"),[x,f]=(0,s.useState)(a),h=c?a:x,p=(0,s.useCallback)(e=>{let t=u.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let r=Math.min(i,Math.max(l,(c?a:x)+e/n*100));c?c(r):f(r)},[a,x,l,i,c]),g=(0,s.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(h,"%")},className:"flex-shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",children:(0,r.jsx)(T.t,{componentName:"ActivityPane",children:t})}),(0,r.jsx)(lS.f,{onResize:p,orientation:"horizontal",ariaValueNow:h})]}),(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.t,{componentName:"TerminalPane",children:n})})]})})});var lT=n(23570),lE=n(5379),lA=n(15870),lM=n(9540),lR=n(39332),lL=n(16485),lP=n(78192),lD=n(39324),lF=n(80298),lO=n(55867);let lz=[{id:"files",labelKey:"activityBar.files",icon:j.A},{id:"git",labelKey:"activityBar.git",icon:lR.A},{id:"notes",labelKey:"activityBar.notes",icon:K.A},{id:"schedules",labelKey:"activityBar.schedules",icon:lL.A},{id:"agent",labelKey:"activityBar.agent",icon:lP.A},{id:"timer",labelKey:"activityBar.timer",icon:lD.A},{id:"todo",labelKey:"activityBar.todo",icon:lF.A},{id:"skills",labelKey:"activityBar.skills",icon:n1.A},{id:"verification",labelKey:"activityBar.verification",icon:rL.A},{id:"env",labelKey:"activityBar.env",icon:lO.A}],l_=new Set(lz.map(e=>e.id)),lB="files",lV="__closed__";function lU(e){return"".concat("commandmate.worktree.activeActivity-").concat(e)}var lH=n(32916),lK=n(65380),lW=n(45195),lq=n(89275),l$=n(40823);function lG(){let e=(0,o.c)("worktree"),t=(0,lq.Hq)(),{theme:n,setTheme:a}=(0,lE.D)(),{currentLocale:l,switchLocale:i}=(0,lW.g)(),c=(0,lK.H)(),{open:d}=(0,l$.V0)(),u=(0,s.useRef)(!1),m=e("activityBar.settings"),x="0.41.1",f=(0,s.useCallback)(async()=>{try{await fetch("/api/auth/logout",{method:"POST"}),window.location.href="/login"}catch(e){window.location.href="/login"}},[]);return(0,r.jsxs)(Z.rI,{children:[(0,r.jsx)(ee.m_,{content:m,placement:"right",children:(0,r.jsx)(Z.ty,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-settings","aria-label":m,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)(lA.A,{size:20,"aria-hidden":"true"})})})}),(0,r.jsxs)(Z.SQ,{side:"right",align:"end",className:"w-56",onCloseAutoFocus:()=>{u.current&&(u.current=!1,queueMicrotask(d))},children:[(0,r.jsx)(Z.lp,{"data-testid":"activity-bar-settings-version",children:e("activityBar.settingsMenu.version",{version:x?"v".concat(x):"-"})}),(0,r.jsx)(Z._2,{onSelect:()=>{u.current=!0},children:e("activityBar.settingsMenu.settings")}),(0,r.jsx)(Z._2,{onSelect:()=>t.push("/skills"),children:e("activityBar.settingsMenu.skills")}),(0,r.jsx)(Z.mB,{}),(0,r.jsx)(Z.lp,{children:e("activityBar.settingsMenu.theme")}),(0,r.jsxs)(Z.Hr,{value:null!=n?n:"system",onValueChange:e=>a(e),children:[(0,r.jsx)(Z.Ht,{value:"light",children:e("activityBar.settingsMenu.themeLight")}),(0,r.jsx)(Z.Ht,{value:"dark",children:e("activityBar.settingsMenu.themeDark")}),(0,r.jsx)(Z.Ht,{value:"system",children:e("activityBar.settingsMenu.themeSystem")})]}),(0,r.jsx)(Z.lp,{children:e("activityBar.settingsMenu.language")}),(0,r.jsx)(Z.Hr,{value:l,onValueChange:e=>i(e),children:ah.dI.map(e=>(0,r.jsx)(Z.Ht,{value:e,children:ah.vK[e]},e))}),(0,r.jsx)(Z.mB,{}),(0,r.jsx)(Z._2,{asChild:!0,children:(0,r.jsx)("a",{href:"https://github.com/kewton/MyCodeBranchDesk",target:"_blank",rel:"noopener noreferrer",children:e("activityBar.settingsMenu.github")})}),c&&(0,r.jsx)(Z._2,{onSelect:()=>{f()},children:e("activityBar.settingsMenu.logout")})]})]})}let lJ=(0,s.memo)(function(e){let{active:t,onToggle:n,className:a=""}=e,l=(0,o.c)("worktree"),i=(0,s.useRef)([]),{isOpen:c,toggle:d}=(0,lH.VF)(),u=(0,s.useCallback)((e,t,a)=>{var r,s,l,o;if("Enter"===e.key||" "===e.key){e.preventDefault(),n(a);return}if("ArrowDown"===e.key){e.preventDefault();let n=(t+1)%lz.length;null==(r=i.current[n])||r.focus();return}if("ArrowUp"===e.key){e.preventDefault();let n=(t-1+lz.length)%lz.length;null==(s=i.current[n])||s.focus();return}if("Home"===e.key){e.preventDefault(),null==(l=i.current[0])||l.focus();return}if("End"===e.key){e.preventDefault(),null==(o=i.current[lz.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)(ee.m_,{content:l("activityBar.toggleSidebar"),placement:"right",children:(0,r.jsx)("button",{type:"button","data-testid":"activity-bar-toggle-sidebar",onClick:d,"aria-label":l("activityBar.toggleSidebar"),"aria-expanded":c,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)(lM.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":l("activityBar.label"),className:"flex flex-col items-stretch",children:lz.map((e,a)=>{let s=e.icon,o=t===e.id,c=l(e.labelKey);return(0,r.jsx)(ee.m_,{content:c,placement:"right",children:(0,r.jsx)("button",{ref:e=>{i.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)(s,{size:20,"aria-hidden":"true"})})})},e.id)})}),(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(lG,{})})]})}),lY="worktree-activity-pane",lQ={files:"FileTreeView",git:"GitPane",notes:"MemoPane",schedules:"ExecutionLogPane",agent:"AgentInstancesPane",timer:"TimerPane",todo:"TodoPane",skills:"WorktreeSkillsPane",verification:"VerificationPane",env:"EnvManagerPane"},lX=(0,s.memo)(function(e){let{active:t,activities:n,className:a=""}=e;if(null===t)return(0,r.jsx)("div",{id:lY,"data-testid":"activity-pane","data-active":"none",className:"h-full flex flex-col ".concat(a).trim()});let s=n[t],l=lQ[t];return(0,r.jsx)("div",{id:lY,"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.t,{componentName:l,children:null!=s?s:null})})});var lZ=n(13577),l0=n(72338),l1=n(90088),l2=n(96195),l4=n(56936);let l5=(0,s.memo)(function(e){let{inputRef:t,searchQuery:n,onQueryChange:a,matchCount:s,currentIdx:l,onNextMatch:i,onPrevMatch:c,onClose:d}=e,m=(0,o.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.nativeEvent.isComposing||(e.shiftKey?c():i())},placeholder:m("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)(u.$n,{variant:"ghost",type:"button",onClick:c,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":m("fileSearch.prevMatch"),children:"▲"}),(0,r.jsx)(u.$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":m("fileSearch.nextMatch"),children:"▼"}),(0,r.jsx)(u.$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":m("fileSearch.close"),children:(0,r.jsx)(eu.A,{className:"w-4 h-4"})})]})});var l3=n(40051);function l6(){return(0,r.jsx)("div",{className:"flex items-center justify-center py-12 bg-surface",children:(0,r.jsx)(d.y,{size:"xl",variant:"accent"})})}let l9=(0,i.default)(()=>n.e(530).then(n.bind(n,530)).then(e=>({default:e.HtmlPreview})),{loadableGenerated:{webpack:()=>[530]},ssr:!1,loading:()=>(0,r.jsx)(l6,{})}),l8=(0,i.default)(()=>Promise.resolve().then(n.bind(n,27307)).then(e=>({default:e.PdfPreview})),{loadableGenerated:{webpack:()=>[27307]},ssr:!1,loading:()=>(0,r.jsx)(l6,{})}),l7=(0,i.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(l6,{})}),ie=/^---\s*\nmarp:\s*true/;function it(){let e=(0,o.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,r.jsx)(d.y,{size:"xl",variant:"accent"}),(0,r.jsx)("p",{className:"ml-3 text-muted-foreground",children:e("fileViewer.loading")})]})}function ia(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 ir(e){let{reason:t}=e;return(0,r.jsxs)("div",{"data-testid":"file-read-only-notice","data-reason-code":t.code,role:"status",className:"flex items-center gap-2 px-3 py-2 bg-warning-subtle border-b border-warning-border text-xs text-warning-foreground",children:[(0,r.jsx)(eZ.A,{className:"w-3.5 h-3.5 shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:t.message})]})}function is(e){let{filePath:t,isMaximized:n,onToggleMaximize:a,copyableContent:s,onSearch:l}=e,i=(0,o.c)("worktree"),{copied:c,markCopied:d}=(0,e9.q)(),{copied:u,markCopied:m}=(0,e9.q)(),x=async()=>{try{await (0,eX.l)(t),d()}catch(e){}},f=async()=>{if(s)try{await (0,eX.l)(s),m()}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:x,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":i("actions.copyFilePath"),title:i("actions.copyPath"),children:c?(0,r.jsx)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eH.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":i("actions.searchInFile"),title:i("actions.search"),children:(0,r.jsx)(H.A,{className:"w-3.5 h-3.5"})}),s&&(0,r.jsx)("button",{type:"button",onClick:f,className:"flex-shrink-0 p-1 rounded-md hover:bg-muted text-muted-foreground transition-colors","aria-label":i("actions.copyFileContent"),title:i("actions.copyContent"),children:u?(0,r.jsx)(eV.A,{className:"w-3.5 h-3.5 text-success"}):(0,r.jsx)(eU.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":i(n?"actions.minimize":"actions.maximize"),title:i(n?"actions.minimize":"actions.maximize"),children:n?(0,r.jsx)(J.A,{className:"w-4 h-4"}):(0,r.jsx)(Y.A,{className:"w-4 h-4"})})]})]})}function il(e){var t;let{content:n,extension:a,searchMatches:l,searchCurrentIdx:i,totalLines:o,rangeStart:c,worktreeId:d,filePath:u,onLineRangeFetched:m}=e,x=(0,s.useRef)(null),f=(0,s.useMemo)(()=>n.split("\n"),[n]),h=Math.max(1,null!=c?c:1),p=f.length,g=Math.max(null!=o?o:p,p),b=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{b.current.clear()},[n,a]);let v=(0,s.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,f.length),l=f.slice(e,t).join("\n"),i="";try{i=e8.A.highlight(l,{language:a,ignoreIllegals:!0}).value}catch(e){i=e8.A.highlightAuto(l).value}s=i.split("\n"),r.set(n,s)}return null!=(t=s[e-500*n])?t:""},[f,a]),y=(0,s.useMemo)(()=>new Set(null!=l?l:[]),[l]),j=(null!=(t=null==l?void 0:l.length)?t:0)>0?l[null!=i?i:0]:-1,w=(0,l2.Te)({count:g,getScrollElement:()=>x.current,estimateSize:()=>24,overscan:100});(0,s.useEffect)(()=>{if(!l||0===l.length)return;let e=l[null!=i?i:0];if(!Number.isFinite(e))return;let t=Math.max(0,Math.min(g-1,e-1));w.scrollToIndex(t,{align:"center"})},[i,l,w,g]);let k=w.getVirtualItems();return!function(e){let{virtualItems:t,worktreeId:n,filePath:a,onLineRangeFetched:r,loadedStart:l,loadedLineCount:i}=e,o=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!n||!a||!r||0===t.length)return;let e=t[0].index+1,s=t[t.length-1].index+1,c=l+i-1;if(e>=l&&s<=c)return;let d=Math.max(1,500*Math.floor((e-1)/500)+1),u=d+500-1;if(o.current.has(d))return;o.current.add(d);let m="/api/worktrees/".concat(n,"/files/").concat((0,e4.o)(a),"?startLine=").concat(d,"&endLine=").concat(u);(0,tm.E)(m).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,l,i])}({virtualItems:k,worktreeId:d,filePath:u,onLineRangeFetched:m,loadedStart:h,loadedLineCount:p}),(0,r.jsx)("div",{className:"overflow-auto h-full",ref:x,"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-h,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)(l3.E,{className:"h-4 w-3/4"})})]},e.key)})})})}function ii(e){let{slides:t,fileName:n}=e,a=(0,o.c)("worktree"),[l,i]=(0,s.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:()=>{i(e=>Math.max(0,e-1))},disabled:0===l,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:[l+1," / ",t.length]}),(0,r.jsx)("button",{type:"button",onClick:()=>{i(e=>Math.min(t.length-1,e+1))},disabled:l===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[l],sandbox:"",title:a("fileViewer.slideTitle",{name:n,number:l+1}),className:"w-full h-full border-0"})})]})}function io(e){let{marpSlides:t,fileName:n,worktreeId:a,filePath:l,contentText:i,onFileSaved:c,isMaximized:d,onToggleMaximize:u,onDirtyChange:m,onOpenFile:x}=e,f=(0,o.c)("worktree"),[h,p]=(0,s.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"===h?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:f("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"===h?"bg-accent-100 dark:bg-accent-900/50 text-accent-700 dark:text-accent-300":"text-muted-foreground hover:bg-muted"),children:f("fileViewer.editor")})]}),(0,r.jsx)(is,{filePath:l,isMaximized:d,onToggleMaximize:u,copyableContent:i})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:"slides"===h?(0,r.jsx)(ii,{slides:t,fileName:n}):(0,r.jsx)(l7,{worktreeId:a,filePath:l,onSave:c,initialViewMode:"split",onDirtyChange:m,onOpenFile:x})})]})}function ic(e){let{children:t,isMaximized:n,onToggle:a,filePath:s}=e;if(!n)return(0,r.jsx)(r.Fragment,{children:t});let l=(0,r.jsxs)("div",{"data-testid":"maximized-file-overlay",className:"fixed inset-0 bg-surface flex flex-col",style:{zIndex:e2.M.MAXIMIZED_EDITOR},children:[(0,r.jsx)(is,{filePath:s,isMaximized:n,onToggleMaximize:a}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:t})]});return"undefined"==typeof document?l:(0,ns.createPortal)(l,document.body)}function id(e){let{tab:t,content:n,worktreeId:a,isMaximized:s,onToggleMaximize:l,onFileSaved:i,onDirtyChange:o,onOpenFile:c}=e,d=e6(n.content);return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)(is,{filePath:t.path,isMaximized:s,onToggleMaximize:l,copyableContent:n.content,onSearch:d.openSearch}),d.searchOpen&&(0,r.jsx)(l5,{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)(il,{content:n.content,extension:n.extension,searchMatches:d.searchMatches,searchCurrentIdx:d.searchCurrentIdx}):(0,r.jsx)(l7,{worktreeId:a,filePath:t.path,onSave:i,initialViewMode:"preview",onDirtyChange:o,onOpenFile:c})})]})}function iu(e){var t,n;let{tab:a,content:l,worktreeId:i,isMaximized:o,onToggleMaximize:c,onLoadContent:d}=e,u=e6(l.content),m=(0,s.useCallback)(e=>{var t;d&&d(a.path,{...l,content:e.content,totalLines:e.totalLines,totalBytes:null!=(t=e.totalBytes)?t:l.totalBytes,range:e.range})},[d,a.path,l]),x=void 0!==l.range&&(null!=(n=l.totalLines)?n:0)>l.range.end-l.range.start+1;return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(is,{filePath:a.path,isMaximized:o,onToggleMaximize:c,copyableContent:l.content,onSearch:u.openSearch}),l.readOnly&&l.readOnlyReason&&(0,r.jsx)(ir,{reason:l.readOnlyReason}),u.searchOpen&&(0,r.jsx)(l5,{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)(il,{content:l.content,extension:l.extension,searchMatches:u.searchOpen?u.searchMatches:void 0,searchCurrentIdx:u.searchOpen?u.searchCurrentIdx:void 0,totalLines:l.totalLines,rangeStart:null==(t=l.range)?void 0:t.start,worktreeId:x?i:void 0,filePath:x?a.path:void 0,onLineRangeFetched:x?m:void 0})})]})}let im=(0,s.memo)(function(e){var t,n,a,l;let{tab:i,worktreeId:c,onLoadContent:d,onLoadError:u,onSetLoading:m,onFileSaved:x,onDirtyChange:f,onOpenFile:h}=e,p=(0,o.c)("worktree"),g=(0,s.useRef)(p);g.current=p;let b=(0,s.useRef)(!1),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(!1);!function(e){let{tab:t,worktreeId:n,onLoadContent:a}=e,r=(0,s.useRef)(null),l=(0,s.useRef)(a);l.current=a;let i=(0,s.useRef)(t.path);i.current=t.path,nE({intervalMs:5e3,enabled:function(e){if(null===e.content||e.loading||e.isDirty||e.content.isPdf)return!1;let{totalBytes:t}=e.content;return void 0===t||!(t>=1048576)}(t),onPoll:async()=>{let e="/api/worktrees/".concat(n,"/files/").concat((0,e4.o)(i.current)),t={};r.current&&(t["If-Modified-Since"]=r.current);try{let n=await (0,tm.E)(e,{headers:t,timeoutMs:l4.K3,retries:0});if(304===n.status||!n.ok)return;r.current=n.headers.get("Last-Modified");let a=await n.json();l.current(i.current,a)}catch(e){}}})}({tab:i,worktreeId:c,onLoadContent:d});let k=(0,s.useMemo)(()=>f?e=>f(i.path,e):void 0,[f,i.path]),N=(0,s.useCallback)(()=>{w(e=>!e)},[]);(0,s.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&w(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j]),(0,s.useEffect)(()=>{null!==i.content||i.loading||null!==i.error||b.current||(b.current=!0,m(i.path,!0),(async()=>{try{let t=await (0,tm.E)("/api/worktrees/".concat(c,"/files/").concat((0,e4.o)(i.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(i.path,a);return}let n=await t.json();d(i.path,n)}catch(e){u(i.path,e instanceof Error?e.message:g.current("fileViewer.loadError"))}finally{b.current=!1}})())},[i.content,i.loading,i.error,i.path,c,d,u,m]);let C=null!=(a=null==(t=i.content)?void 0:t.content)?a:null,S=null!=(l=null==(n=i.content)?void 0:n.extension)?l:null;if((0,s.useEffect)(()=>{if(!C||"md"!==S||!ie.test(C)||C.length>1e6)return void y(null);let e=!1;return(async()=>{try{let t=await (0,tm.E)("/api/worktrees/".concat(c,"/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,c]),i.loading)return(0,r.jsx)(it,{});if(i.error)return(0,r.jsx)(ia,{error:i.error});if(!i.content)return null;let{content:I}=i;return I.isImage?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(is,{filePath:i.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(eO.a,{src:I.content,alt:I.path,mimeType:I.mimeType})})]})}):I.isVideo?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(is,{filePath:i.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 overflow-auto",children:(0,r.jsx)(ez.u,{src:I.content,mimeType:I.mimeType})})]})}):I.isPdf?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(is,{filePath:i.path,isMaximized:j,onToggleMaximize:N}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(l8,{dataUri:I.content,filePath:i.path})})]})}):I.readOnly?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsx)(iu,{tab:i,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onLoadContent:d})}):I.isHtml?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(is,{filePath:i.path,isMaximized:j,onToggleMaximize:N,copyableContent:I.content}),(0,r.jsx)("div",{className:"flex-1 min-h-0",children:(0,r.jsx)(l9,{worktreeId:c,filePath:i.path,htmlContent:I.content,onFileSaved:x,onOpenFile:h})})]})}):"md"===I.extension?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:v?(0,r.jsx)(io,{marpSlides:v,fileName:i.name,worktreeId:c,filePath:i.path,contentText:I.content,onFileSaved:x,isMaximized:j,onToggleMaximize:N,onDirtyChange:k,onOpenFile:h}):(0,r.jsx)(id,{tab:i,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:h})})}):eQ("."+I.extension)?(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsx)("div",{className:"h-full flex flex-col",children:(0,r.jsx)(id,{tab:i,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onFileSaved:x,onDirtyChange:k,onOpenFile:h})})}):(0,r.jsx)(ic,{isMaximized:j,onToggle:N,filePath:i.path,children:(0,r.jsx)(iu,{tab:i,content:I,worktreeId:c,isMaximized:j,onToggleMaximize:N,onLoadContent:d})})}),ix="commandmate:file-tabs:";function ih(e){let t=e.split("/");return t[t.length-1]||e}function ip(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}function ig(e,t,n){if("all"===n)return e.map(e=>e.path);let a=e.findIndex(e=>e.path===t);return -1===a?[]:"others"===n?e.filter((e,t)=>t!==a).map(e=>e.path):e.slice(a+1).map(e=>e.path)}let ib={tabs:[],activeIndex:null};function iv(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 iy=(0,s.memo)(function(e){let{tab:t,isActive:n,onActivate:a,onClose:l,onOpenMenu:i}=e,c=(0,o.c)("worktree"),d=(0,s.useCallback)(()=>{n||a(t.path)},[n,a,t.path]),u=(0,s.useCallback)(e=>{e.stopPropagation(),l(t.path)},[l,t.path]),m=(0,s.useCallback)(e=>{i(e,t.path)},[i,t.path]),x=(0,s.useCallback)(e=>{1===e.button&&(e.preventDefault(),e.stopPropagation(),l(t.path))},[l,t.path]),f=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:d,onAuxClick:x,onContextMenu:m,className:"flex items-center gap-1 px-3 py-2 text-sm font-medium border-b-2 cursor-pointer flex-shrink-0 ".concat(f),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:c("fileTabs.unsavedChanges")}),(0,r.jsx)("button",{type:"button",onClick:u,className:"ml-1 p-0.5 rounded-sm hover:bg-muted transition-colors","aria-label":c("fileTabs.closeTab",{name:t.name}),children:(0,r.jsx)(eu.A,{className:"w-3 h-3"})})]})}),ij=(0,s.memo)(function(e){var t,n,a;let{tabs:l,activeIndex:i,worktreeId:d,onClose:u,onActivate:m,onLoadContent:x,onLoadError:f,onSetLoading:h,onFileSaved:p,onDirtyChange:g,onMoveToFront:b,onOpenFile:v}=e,y=(0,o.c)("worktree"),[j,w]=(0,s.useState)(!1),k=(0,s.useRef)(null),N=(0,s.useRef)(null),C=(0,s.useRef)({x:0,y:0}),[S,I]=(0,s.useState)({x:0,y:0}),{menuState:T,openMenu:E,openMenuAt:A,closeMenu:M}=nr(),[R,L]=(0,s.useState)(null),P=null!==i&&i>=0&&i<l.length?l[i]:null,D=l.length>5?l.slice(0,5):l,F=l.length>5?l.slice(5):[];(0,s.useEffect)(()=>{if(!j)return;let e=e=>{k.current&&!k.current.contains(e.target)&&w(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[j]),(0,s.useLayoutEffect)(()=>{let e=e=>{C.current=e,I(t=>t.x===e.x&&t.y===e.y?t:e)};if(!j)return void e({x:0,y:0});let t=N.current;if(!t)return;let n=t.getBoundingClientRect();e({x:iv(n.left-C.current.x,n.width,window.innerWidth),y:iv(n.top-C.current.y,n.height,window.innerHeight)})},[j]);let O=(0,s.useCallback)(e=>{w(!1),null==b||b(e)},[b]),z=(0,s.useCallback)(()=>{w(e=>!e)},[]),_=(0,s.useCallback)(e=>{for(let t=e.length-1;t>=0;t--)u(e[t])},[u]),B=(0,s.useCallback)((e,t)=>{let n=ig(l,t,e);if(0===n.length)return;let a=new Set(n);if(l.some(e=>e.isDirty&&a.has(e.path)))return void L({mode:e,anchorPath:t});_(n)},[l,_]),V=T.targetPath,U=(0,s.useMemo)(()=>V?[{id:"close-all-tabs",label:y("fileTabs.closeAll"),icon:(0,r.jsx)(lZ.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("all",V),disabled:0===l.length},{id:"close-other-tabs",label:y("fileTabs.closeOthers"),icon:(0,r.jsx)(l0.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("others",V),disabled:0===ig(l,V,"others").length},{id:"close-tabs-to-right",label:y("fileTabs.closeToRight"),icon:(0,r.jsx)(l1.A,{className:"w-4 h-4","aria-hidden":"true",role:"img"}),onSelect:()=>B("right",V),disabled:0===ig(l,V,"right").length}]:[],[V,l,B,y]),H=(0,s.useCallback)((e,t)=>{E(e,t,"file")},[E]),K=null!=(a=null!=(n=null==P?void 0:P.path)?n:null==(t=l[0])?void 0:t.path)?a:null,W=(0,s.useCallback)(e=>{if(!K)return;let t=e.currentTarget.getBoundingClientRect();A({x:t.left,y:t.bottom},K,"file")},[K,A]),q=R?ig(l,R.anchorPath,R.mode):[],$=q.filter(e=>{var t;return null==(t=l.find(t=>t.path===e))?void 0:t.isDirty}),J=(0,s.useCallback)(()=>L(null),[]);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:D.map((e,t)=>(0,r.jsx)(iy,{tab:e,isActive:t===i,onActivate:m,onClose:u,onOpenMenu:H},e.path))}),F.length>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",ref:k,children:[(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-button",onClick:z,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)(G.A,{className:"w-3 h-3 transition-transform ".concat(j?"rotate-180":"")}),(0,r.jsxs)("span",{children:["+",F.length]})]}),j&&(0,r.jsx)("div",{ref:N,"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!==S.x||0!==S.y?{transform:"translate(".concat(S.x,"px, ").concat(S.y,"px)")}:void 0,children:F.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"tab-dropdown-item-".concat(e.path),onClick:()=>O(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))})]}),l.length>0&&(0,r.jsx)("button",{type:"button","data-testid":"tab-actions-button",onClick:W,"aria-haspopup":"menu","aria-expanded":T.isOpen,"aria-label":y("fileTabs.tabActions"),title:y("fileTabs.tabActions"),className:"flex-shrink-0 flex items-center px-2 py-2 text-muted-foreground hover:text-foreground hover:bg-muted border-b-2 border-transparent transition-colors",children:(0,r.jsx)(c.A,{className:"w-4 h-4"})})]}),(0,r.jsx)(nx,{isOpen:T.isOpen,position:T.position,targetPath:T.targetPath,targetType:T.targetType,onClose:M,items:U,ariaLabel:y("fileTabs.tabActions")}),(0,r.jsxs)(tN.a,{isOpen:null!==R,onClose:J,title:y("fileTabs.confirmCloseTitle"),size:"sm",children:[(0,r.jsx)("p",{"data-testid":"file-tabs-close-confirm-body",className:"text-sm text-foreground",children:y("fileTabs.confirmCloseBody",{count:$.length})}),(0,r.jsx)("ul",{className:"mt-2 max-h-32 overflow-y-auto text-sm text-muted-foreground",children:$.map(e=>(0,r.jsx)("li",{className:"truncate",title:e,children:e},e))}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,r.jsx)(eD.$,{variant:"ghost",size:"sm","data-testid":"file-tabs-close-cancel",onClick:J,children:y("fileTabs.confirmCancel")}),(0,r.jsx)(eD.$,{variant:"secondary",size:"sm","data-testid":"file-tabs-close-keep-unsaved",onClick:()=>{let e=new Set($);_(q.filter(t=>!e.has(t))),L(null)},children:y("fileTabs.confirmKeepUnsaved")}),(0,r.jsx)(eD.$,{variant:"danger",size:"sm","data-testid":"file-tabs-close-discard",onClick:()=>{_(q),L(null)},children:y("fileTabs.confirmDiscard")})]})]}),(0,r.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:P&&(0,r.jsx)(im,{tab:P,worktreeId:d,onLoadContent:x,onLoadError:f,onSetLoading:h,onFileSaved:p,onDirtyChange:g,onOpenFile:v},P.path)})]})}),iw=(0,s.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})}),ik=(0,s.memo)(function(e){let{diff:t,filePath:n,onClose:a}=e,s=(0,o.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)(iw,{line:e},t))})})})]})}),iN="commandmate.worktree.filePanelCollapsed",iC="worktree-file-panel",iS=(0,s.createContext)({tabCount:0,hasDiff:!1}),iI="commandmate:filePanelStateChange";function iT(){let[e,t]=(0,s.useState)(!1),n=(0,s.useRef)(e);n.current=e,(0,s.useEffect)(()=>{t(function(){try{let e=window.localStorage.getItem(iN);if("true"===e)return!0}catch(e){}return!1}())},[]),(0,s.useEffect)(()=>{let e=e=>{e.detail&&e.detail.collapsed!==n.current&&t(e.detail.collapsed)};return window.addEventListener(iI,e),()=>window.removeEventListener(iI,e)},[]);let a=(0,s.useCallback)(e=>{t(e);try{window.localStorage.setItem(iN,String(e))}catch(e){}try{window.dispatchEvent(new CustomEvent(iI,{detail:{collapsed:e}}))}catch(e){}},[]);return{collapsed:e,toggle:(0,s.useCallback)(()=>{a(!n.current)},[a]),setCollapsed:a}}let iE=(0,s.memo)(function(e){let{terminal:t,terminalHeader:n,fileTabs:a,worktreeId:l,onCloseTab:i,onActivateTab:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,diffContent:x,diffFilePath:f,onCloseDiff:h,onDirtyChange:p,onMoveToFront:g,onOpenFile:b}=e,v=(0,s.useRef)(null),[y,j]=(0,s.useState)(50),{collapsed:w}=iT(),k=(0,s.useCallback)(e=>{let t=v.current;if(!t)return;let n=t.offsetWidth;if(0===n)return;let a=e/n*100;j(e=>Math.min(80,Math.max(20,e+a)))},[]),N=(0,s.useMemo)(()=>({width:"".concat(y,"%")}),[y]),C=(0,s.useMemo)(()=>({width:"".concat(100-y,"%")}),[y]),S=(0,s.useMemo)(()=>({tabCount:a.tabs.length,hasDiff:!!(x&&f)}),[a.tabs.length,x,f]),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?w?(0,r.jsx)(iS.Provider,{value:S,children:(0,r.jsx)("div",{ref:v,className:"flex h-full min-h-0",children:(0,r.jsx)("div",{"data-testid":"terminal-pane",style:{width:"100%"},className:"flex-shrink-0 overflow-hidden",children:I})})}):(0,r.jsx)(iS.Provider,{value:S,children:(0,r.jsxs)("div",{ref:v,className:"flex h-full min-h-0",children:[(0,r.jsx)("div",{"data-testid":"terminal-pane",style:N,className:"flex-shrink-0 overflow-hidden",children:I}),(0,r.jsx)(lS.f,{onResize:k,orientation:"horizontal",ariaValueNow:y}),(0,r.jsx)("div",{id:iC,"data-testid":"file-panel-pane",style:C,className:"flex-grow overflow-hidden flex",children:(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:x&&f&&h?(0,r.jsx)(ik,{diff:x,filePath:f,onClose:h}):(0,r.jsx)(ij,{tabs:a.tabs,activeIndex:a.activeIndex,worktreeId:l,onClose:i,onActivate:o,onLoadContent:c,onLoadError:d,onSetLoading:u,onFileSaved:m,onDirtyChange:p,onMoveToFront:g,onOpenFile:b})})})]})}):(0,r.jsx)(iS.Provider,{value:S,children:(0,r.jsx)("div",{className:"h-full",children:I})})});var iA=n(7125),iM=n(22509),iR=n(54485),iL=n(55412);let iP=[.5,.5],iD={splits:[{cliToolId:"claude",instanceId:"claude"}],widths:[1]},iF=new Set(Q.XH);function iO(e){return"".concat("commandmate:terminalSplits:").concat(e)}function iz(e){return"object"==typeof e&&null!==e}function i_(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function iB(e){return void 0===e||!!Array.isArray(e)&&2===e.length&&e.every(i_)}function iV(e,t){let n=e+t;if(!Number.isFinite(n)||n<=0)return[1,1];let a=Math.min(e,t);return!Number.isFinite(a)||a<=0?[1,1]:[e/a,t/a]}function iU(e){let t=e[0];return t?{splits:[{cliToolId:t.cliTool,instanceId:t.id}],widths:[1]}:{splits:iD.splits.map(e=>({...e})),widths:[...iD.widths]}}function iH(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){if(4===e.splits.length)return iB(e.rowHeights)&&void 0!==e.rowHeights?e:{...e,rowHeights:[...iP]};if(void 0===e.rowHeights)return e;let{rowHeights:t,...n}=e;return n}function iW(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,4),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?iH(e.widths):l.length<e.widths.length?iH(e.widths.slice(0,l.length)):Array.from({length:l.length},()=>1/l.length),iK({...e,splits:l,widths:n}))}function iq(e,t,n){let a=function(e,t){try{let n=window.localStorage.getItem(iO(e));if(!n)return iU(t);let a=JSON.parse(n),r=function(e){if(!iz(e))return null;let{splits:t,widths:n,rowHeights:a}=e;if(!Array.isArray(t)||!Array.isArray(n)||t.length<1||t.length>4||n.length!==t.length)return null;let r=[];for(let e of t){if(!iz(e))return null;let t=e.cliToolId;if("string"!=typeof t||!iF.has(t))return null;let n=e.instanceId,a="string"==typeof n&&(0,Q.n6)(n)?n:t;r.push({cliToolId:t,instanceId:a})}for(let e of n)if(!i_(e))return null;let s={splits:r,widths:n};return 4===r.length&&void 0!==a&&iB(a)&&(s.rowHeights=[...a]),s}(a);if(r)return iK({...r,widths:iH(r.widths)});return console.warn("[useTerminalSplits] stale state for ".concat(e,"; falling back to default")),iU(t)}catch(n){return console.warn("[useTerminalSplits] failed to parse stored state for ".concat(e,"; using default"),n),iU(t)}}(e,t);return n?iW(a,t):a}var i$=n(81507);let iG=(0,s.memo)(function(e){var t,n,a,l;let{worktreeId:i,instances:c,rosterReady:d=!0,renderPane:u,onFocusedSplitChange:m,showToast:x,onActiveInstanceChange:f,headerInstanceSelection:h}=e,{splits:p,widths:g,rowHeights:b,setRowHeights:v,addSplit:y,removeSplit:j,setSplitInstance:w,setSplitWidth:k,resetWidths:N,availableInstanceIds:C,focusedSplitIndex:S,setFocusedSplitIndex:I,maximizedIndex:T,toggleMaximize:E}=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],[a,r]=(0,s.useState)(()=>iq(e,t,n)),[l,i]=(0,s.useState)(0),[o,c]=(0,s.useState)(null),d=(0,s.useRef)(a);d.current=a;let u=(0,s.useRef)(t);u.current=t;let m=(0,s.useRef)(n);m.current=n;let x=(0,s.useRef)(e);(0,s.useEffect)(()=>{x.current!==e&&(x.current=e,r(iq(e,u.current,m.current)),i(0),c(null))},[e]);let f=(0,s.useMemo)(()=>t.map(e=>"".concat(e.id,":").concat(e.cliTool)).join("|"),[t]);(0,s.useEffect)(()=>{n&&r(e=>iW(e,u.current))},[f,n]);let h=(0,s.useRef)(e);(0,s.useEffect)(()=>{if(h.current!==e){h.current=e;return}try{window.localStorage.setItem(iO(e),JSON.stringify(a))}catch(e){}},[a,e]);let p=(0,s.useCallback)(()=>{c(null),r(e=>{if(e.splits.length>=4)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}(u.current,t);if(!n)return e;let a=[...e.splits,{cliToolId:n.cliTool,instanceId:n.id}];if(4===a.length)return iK({...e,splits:a,widths:Array.from({length:4},()=>.25)});let r=e.widths.length-1,s=e.widths[r]/2,l=[...e.widths];return l[r]=s,l.push(s),iK({...e,splits:a,widths:l})})},[]),g=(0,s.useCallback)(()=>{c(null),r(e=>{if(e.splits.length<=1)return e;let t=e.splits.slice(0,-1),n=iH(e.widths.slice(0,-1));return iK({...e,splits:t,widths:n})})},[]);(0,s.useEffect)(()=>{i(e=>{let t=a.splits.length-1;return e>t?t:e<0?0:e}),c(e=>null!==e&&e>a.splits.length-1?null:e)},[a.splits.length]);let b=(0,s.useCallback)((e,t)=>{let n=d.current,a=u.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},[]),v=(0,s.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]})},[]),y=(0,s.useCallback)(()=>{c(null),r(e=>{let t=e.splits.length;if(0===t)return e;let n=Array.from({length:t},()=>1/t);return 4===t?{...e,widths:n,rowHeights:[...iP]}:iK({...e,widths:n})})},[]),j=(0,s.useCallback)(e=>{r(t=>4!==t.splits.length?t:Array.isArray(e)&&2===e.length&&iB(e)?{...t,rowHeights:[...e]}:t)},[]),w=(0,s.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]),k=(0,s.useCallback)(e=>{i(e)},[]),N=(0,s.useMemo)(()=>{var e;return(e=a.rowHeights)&&iB(e)?[...e]:[...iP]},[a.rowHeights]),C=(0,s.useCallback)(e=>{e<0||e>=d.current.splits.length||c(t=>t===e?null:e)},[]);return{splits:a.splits,widths:a.widths,rowHeights:N,setRowHeights:j,addSplit:p,removeSplit:g,setSplitInstance:b,setSplitWidth:v,resetWidths:y,availableInstanceIds:w,focusedSplitIndex:l,setFocusedSplitIndex:k,maximizedIndex:o,toggleMaximize:C}}(i,c,d),A=(0,s.useMemo)(()=>{let e=new Map;for(let t of c)e.set(t.id,t);return e},[c]),M=(0,o.c)("worktree"),{visible:R,toggle:L,setWidth:P}=(0,i$.TG)(),{collapsed:D,toggle:F}=iT(),O=!D,z=(0,s.useRef)(null),[_,B]=(0,s.useState)(!1),V=(0,s.useRef)(p.length),[U,H]=(0,s.useState)(null);(0,s.useEffect)(()=>{p.length>V.current&&H(p.length-1),V.current=p.length},[p.length]),(0,s.useEffect)(()=>{null==m||m(S)},[S,m]);let K=(0,s.useRef)(0),W=(0,s.useRef)(p);W.current=p,(0,s.useEffect)(()=>{if(!h||h.token===K.current)return;K.current=h.token;let{instanceId:e}=h,t=W.current.findIndex(t=>t.instanceId===e);if(0!==t){if(t>0)return void I(t);w(0,e)&&I(0)}},[h,w,I]),(0,s.useEffect)(()=>{if(null===U)return;let e=z.current;if(!e)return;let t=e.querySelector('[data-split-index="'.concat(U,'"]'));if(!t)return;let n=t.querySelector("textarea");null==n||n.focus(),I(U),H(null)},[U,I]);let q=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=g.reduce((e,t)=>e+t,0),s=t/a*r,l=[...g],i=l[e]+s,o=l[e+1]-s,c=.05*r;i<c||o<c||(l[e]=i,l[e+1]=o,k(l))},[g,k]),$=iV(null!=(t=g[0])?t:1,null!=(n=g[1])?n:1),G=iV(null!=(a=b[0])?a:1,null!=(l=b[1])?l:1),X=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetWidth;if(0===a)return;let r=g[0]+g[1];if(!(r>0))return;let s=t/a*r,l=g[0]+s,i=g[1]-s,o=.05*r;l<o||i<o||k([l,i,l,i])},[g,k]),Z=(0,s.useCallback)((e,t)=>{let n=z.current;if(!n)return;let a=n.offsetHeight;if(0===a)return;let r=b[0]+b[1];if(!(r>0))return;let s=t/a*r,l=b[0]+s,i=b[1]-s,o=.05*r;l<o||i<o||v([l,i])},[b,v]),et=(0,s.useCallback)(()=>B(!0),[]),en=(0,s.useCallback)(()=>B(!1),[]),ea=(0,s.useCallback)(()=>{N(),P(i$.sg)},[N,P]),er=p.length<4&&!_,es=p.length>1&&!_,el=p.length>1||R,ei=null!==T,eo=p.length>1,ec=4===p.length,ed=(0,s.useCallback)(()=>{E(null!=T?T:S)},[E,T,S]),eu=M(ei?"terminal.restoreSplits":"terminal.maximizeFocusedSplit"),em="".concat(eu," — ").concat(M("terminal.maximizeShortcutHint")),{tabCount:ex,hasDiff:ef}=(0,s.useContext)(iS),eh=0===ex&&!ef,ep="".concat(M(R?"terminal.hideHistory":"terminal.showHistory")," — ").concat(M("terminal.historyAllSplitsHint")),eg=M(eh?"terminal.filesEmptyHint":O?"terminal.hideFiles":"terminal.showFiles"),eb=(0,s.useMemo)(()=>p.map((e,t)=>(0,i$.Ce)(t)).join(" "),[p]),ev=(0,s.useMemo)(()=>p.map((e,t)=>()=>I(t)),[p,I]),ey=(0,s.useMemo)(()=>p.map((e,t)=>e=>w(t,e)),[p,w]),ej=(0,s.useMemo)(()=>p.map((e,t)=>()=>E(t)),[p,E]),ew=(0,s.useMemo)(()=>p.map((e,t)=>e=>{var n,a;let r=(0,Q.sw)(null!=(a=A.get(e))?a:{cliTool:"claude",alias:e});if((null==(n=p[t])?void 0:n.instanceId)===e)return;let s=p.findIndex((n,a)=>a!==t&&n.instanceId===e);if(-1!==s){null==x||x("".concat(r," is already in use by split ").concat(s+1),"warning");return}w(t,e)&&(null==f||f(e),null==x||x("Moved ".concat(r," to Split ").concat(t+1),"success"))}),[p,w,x,f,A]);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.jsx)("span",{"data-testid":"split-count-label",className:"text-xs text-muted-foreground tabular-nums mr-1 truncate",children:ei?M("terminal.maximizedStatus",{split:(null!=T?T:0)+1}):"".concat(p.length," / ").concat(4," splits")}),(0,r.jsx)(ee.m_,{content:M("terminal.addSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:y,disabled:!er,"aria-disabled":!er,"aria-label":M("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)(aG.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(ee.m_,{content:M("terminal.removeSplit"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:j,disabled:!es,"aria-disabled":!es,"aria-label":M("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)(iA.A,{className:"w-4 h-4","aria-hidden":"true"})})}),(0,r.jsx)(ee.m_,{content:M("terminal.equalizeWidthsHint"),placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ea,disabled:!el,"aria-disabled":!el,"aria-label":M("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)(iM.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"})})}),(0,r.jsx)(ee.m_,{content:em,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:ed,disabled:!eo,"aria-disabled":!eo,"aria-pressed":ei,"aria-label":eu,"data-testid":"toggle-maximize-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:ei?(0,r.jsx)(J.A,{className:"w-4 h-4 flex-shrink-0","aria-hidden":"true"}):(0,r.jsx)(Y.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.jsx)(ee.m_,{content:ep,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:L,"aria-pressed":R,"aria-expanded":R,"aria-controls":eb,"aria-label":M(R?"terminal.hideHistory":"terminal.showHistory"),"data-testid":"toggle-history-pane",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors ".concat(R?"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)(iR.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.historyLabel")})]})}),(0,r.jsx)(ee.m_,{content:eg,placement:"bottom",className:"flex-shrink-0",children:(0,r.jsxs)("button",{type:"button",onClick:F,disabled:eh,"aria-disabled":eh,"aria-pressed":O,"aria-expanded":O,"aria-controls":iC,"aria-label":M(O?"terminal.hideFiles":"terminal.showFiles"),"data-testid":"toggle-file-panel",className:"flex flex-shrink-0 items-center gap-1 whitespace-nowrap text-xs px-2 py-0.5 rounded border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ".concat(O?"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)(iL.A,{className:"w-3.5 h-3.5 flex-shrink-0","aria-hidden":"true"}),(0,r.jsx)("span",{children:M("terminal.filesLabel")}),ex>0&&(0,r.jsx)("span",{"data-testid":"open-files-count",className:"ml-0.5 min-w-[1.25rem] px-1 rounded-full bg-muted text-[10px] leading-4 text-muted-foreground tabular-nums text-center",children:ex})]})})]}),(0,r.jsxs)("div",{ref:z,"data-testid":"terminal-split-layout","data-layout":ec?"grid":"row",className:ec?"grid flex-1 min-h-0 w-full overflow-y-auto":"flex flex-1 min-h-0 w-full",style:ec?{gridTemplateColumns:ei?"1fr":"".concat($[0],"fr ").concat(4,"px ").concat($[1],"fr"),gridTemplateRows:ei?"1fr":"minmax(".concat(280,"px, ").concat(G[0],"fr) ").concat(4,"px minmax(").concat(280,"px, ").concat(G[1],"fr)")}:void 0,children:[p.map((e,t)=>{var n;let a=t===p.length-1,l=null!==T&&T!==t,i=T===t;return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"split-wrapper-".concat(t),"data-hidden":l?"true":void 0,style:ec?{gridColumn:i||t%2==0?1:3,gridRow:i||t<2?1:3,minWidth:0,minHeight:0,...l?{display:"none"}:null}:{flexGrow:i?1:null!=(n=g[t])?n:1,flexShrink:1,flexBasis:0,minWidth:0,...l?{display:"none"}:null},className:"h-full",children:u({splitIndex:t,cliToolId:e.cliToolId,instanceId:e.instanceId,instance:A.get(e.instanceId),availableInstances:C(t).map(e=>A.get(e)).filter(e=>void 0!==e),onInstanceChange:ey[t],onFocus:ev[t],isFocused:S===t,onDropInstance:ew[t],isMaximized:i,onToggleMaximize:ej[t]})}),ec||a?null:(0,r.jsx)(iJ,{resizerIdx:t,hidden:null!==T,ariaValueNow:g.length?g[t]/g.reduce((e,t)=>e+t,0)*100:50,onResize:q,onStart:et,onEnd:en,onDoubleClick:N})]},"split-".concat(t))}),ec?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iJ,{resizerIdx:0,testId:"split-grid-column-resizer",gridArea:{gridColumn:2,gridRow:"1 / span 3"},hidden:ei,ariaValueNow:g[0]/(g[0]+g[1])*100,onResize:X,onStart:et,onEnd:en,onDoubleClick:N}),(0,r.jsx)(iJ,{resizerIdx:0,testId:"split-grid-row-resizer",orientation:"vertical",gridArea:{gridColumn:"1 / span 3",gridRow:2},hidden:ei,ariaValueNow:b[0]/(b[0]+b[1])*100,onResize:Z,onStart:et,onEnd:en,onDoubleClick:N})]}):null]})]})});function iJ(e){let{resizerIdx:t,ariaValueNow:n,onResize:a,onStart:l,onEnd:i,onDoubleClick:o,hidden:c=!1,orientation:d="horizontal",testId:u,gridArea:m}=e,x=(0,s.useCallback)(e=>a(t,e),[t,a]);return(0,r.jsx)("div",{"data-testid":null!=u?u:"split-resizer-".concat(t),style:{...m,...c?{display:"none"}:null},onMouseDownCapture:l,onTouchStartCapture:l,onMouseUpCapture:i,onTouchEndCapture:i,children:(0,r.jsx)(lS.f,{onResize:x,orientation:d,ariaValueNow:n,onDoubleClick:o})})}var iY=n(52771),iQ=n(88894),iX=n(49509);let iZ="BTab",i0=(0,s.memo)(function(e){var t,n;let{worktreeId:a,cliToolId:l,instanceId:i,agentMode:c,sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:f,onKeysSent:h}=e,p=(0,o.c)("worktree"),g=(0,s.useId)(),{activeKey:b,markPressed:v}=(0,iX.t)(),y=(0,tM.B)(a,l,i,h),j=(0,s.useMemo)(()=>{var e;return"ready"===(e={sessionStatus:d,isPromptWaiting:u,isSelectionListActive:m,isDismissablePanelActive:x,isUnclassifiedActive:f}).sessionStatus&&!e.isPromptWaiting&&!e.isSelectionListActive&&!e.isDismissablePanelActive&&!e.isUnclassifiedActive},[d,u,m,x,f]),w=(0,s.useCallback)(()=>{j&&(v(iZ),y([iZ]))},[j,v,y]);if(!(l&&iY.AO.includes(l)))return null;let k=(0,iY.PD)(c),N=null!=(n=null==(t=(0,iQ.h)(l))?void 0:t.noteId)?n:null,C=N?p("agentMode.note.".concat(N)):null,S=N?p("agentMode.noteShort.".concat(N)):null,I=k?p("agentMode.mode.".concat(c)):null;return(0,r.jsxs)("div",{className:"grid grid-flow-col grid-cols-[max-content] auto-cols-[minmax(0,max-content)] items-center gap-1","data-testid":"agent-mode-control",children:[(0,r.jsx)("button",{type:"button",onClick:w,disabled:!j,className:"min-w-[44px] px-2 py-1 rounded-full border text-xs font-medium transition-colors\n disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent\n ".concat(b===iZ?"border-accent-500 bg-accent-500 text-white":"border-border text-muted-foreground hover:text-accent-600 hover:border-accent-400 dark:hover:text-accent-400"),"aria-label":k?p("agentMode.cycleFromAria",{mode:I}):p("agentMode.cycleAria"),title:null!=C?C:void 0,"aria-describedby":C?g:void 0,"data-testid":"agent-mode-cycle-button","data-agent-mode":c,"data-enabled":String(j),children:(0,r.jsxs)("span",{className:"flex items-center justify-center gap-1",children:[(0,r.jsx)("span",{children:p("agentMode.label")}),(0,r.jsx)("span",{className:"hidden @min-[400px]:inline opacity-60","data-testid":"agent-mode-key-notation",children:"shift+tab"})]})}),k||C?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden","data-testid":"agent-mode-captions",children:[k?(0,r.jsx)("span",{className:"min-w-0 truncate px-2 py-1 rounded-full bg-muted text-xs text-muted-foreground","data-testid":"agent-mode-chip","data-agent-mode":c,children:I}):null,C?(0,r.jsx)("span",{"aria-hidden":"true",title:C,className:"min-w-0 truncate px-2 py-1 rounded-full border border-warning-border bg-warning-subtle text-xs text-warning-foreground","data-testid":"agent-mode-note",children:S}):null]}):null,C?(0,r.jsx)("span",{id:g,className:"sr-only",children:C}):null]})});function i1(e){let{worktreeId:t,cliToolId:n,instanceId:a,onKeysSent:l,onClose:i}=e,c=(0,o.c)("worktree"),d=(0,s.useRef)(null),{send:u,error:m}=ep(t,n,a,l);(0,s.useEffect)(()=>{var e;null==(e=d.current)||e.focus()},[]);let x=(0,s.useCallback)(e=>{let t=function(e){if(!0===e.isComposing||229===e.keyCode||e.metaKey||e.altKey)return null;if("Tab"===e.key)return e.ctrlKey?null:{type:"key",key:e.shiftKey?"BTab":"Tab"};if(e.ctrlKey){if(1!==e.key.length)return null;let t="C-".concat(e.key.toLowerCase());return ef(t)?{type:"key",key:t}:null}let t=eh[e.key];return void 0!==t?{type:"key",key:t}:1==[...e.key].length?{type:"text",text:e.key}:null}(e.nativeEvent);null!==t&&(e.preventDefault(),u([t]))},[u]),f=(0,s.useCallback)(e=>{let t=e.data;t&&u([{type:"text",text:t}]),d.current&&(d.current.value="")},[u]),h=(0,s.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData("text");t&&u(function(e){let t=e.replace(/\r\n/g,"\r").replace(/\n/g,"\r"),n=[];for(let e=0;e<t.length;e+=4096)n.push({type:"text",text:t.slice(e,e+4096)});return n}(t))},[u]);return(0,r.jsxs)("div",{"data-testid":"direct-input-bar",role:"region","aria-label":c("directInput.toggleAria"),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:c("directInput.notice")}),(0,r.jsx)("input",{ref:d,type:"text","data-testid":"direct-input-capture",placeholder:c("directInput.placeholder"),"aria-label":c("directInput.placeholder"),autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,onKeyDown:x,onCompositionEnd:f,onPaste:h,className:"flex-1 min-w-[8rem] min-h-[32px] px-2 rounded-md font-mono text-xs bg-surface border border-info-border text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),(0,r.jsx)("button",{type:"button","data-testid":"direct-input-close",onClick:i,"aria-label":c("directInput.close"),className:"min-h-[32px] px-3 rounded-md text-xs font-medium bg-surface border border-info-border text-info-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background shrink-0",children:c("directInput.close")}),m?(0,r.jsx)("p",{role:"alert","data-testid":"direct-input-error",className:"w-full text-xs text-danger-foreground",children:c(m)}):null]})}function i2(e){if(!e)return null;let t=e.decisionId;return"string"==typeof t&&""!==t?t:null}let i4="\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(),i5="bg-accent-600 text-white hover:bg-accent-700 focus:ring-ring",i3="bg-surface border-2 border-input hover:bg-muted text-foreground focus:ring-ring",i6=[/^[^\S\n]*type\s+something\b/i];function i9(e){return!0===e.requiresTextInput&&i6.some(t=>t.test(e.label))}function i8(e){var t,n;return"multiple_choice"!==e.type||!0===e.multiSelect?null:null!=(n=null==(t=e.options.find(e=>e.isDefault))?void 0:t.number)?n:null}function i7(e){return"multiple_choice"!==e.type||!0!==e.multiSelect?[]:e.options.filter(e=>!0===e.checked).map(e=>e.number)}function oe(e){let{promptData:t,answering:n,onRespond:a,decisionId:l,onDismiss:i,labelId:c,cliToolName:d}=e,m=(0,o.c)("prompt"),[x,f]=(0,s.useState)(()=>i8(t)),[h,p]=(0,s.useState)(()=>i7(t)),[g,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(!1),j=function(e){let t=[e.question];if("multiple_choice"===e.type){var n,a;for(let r of(t.push(String(null!=(a=null==(n=e.askUserQuestion)?void 0:n.questionIndex)?a:"")),e.options))t.push("".concat(r.number,":").concat(r.label))}return t.join("\0")}(t),[w,k]=(0,s.useState)(j);j!==w&&(k(j),f(i8(t)),p(i7(t)),b(""));let N="multiple_choice"===t.type&&!0===t.multiSelect?t.options:null,C=(0,s.useMemo)(()=>{var e;return"multiple_choice"!==t.type?null:null!=(e=t.options.find(e=>e.number===x))?e:null},[t,x]),S=(0,s.useMemo)(()=>(null!=N?N:[]).filter(e=>h.includes(e.number)&&i9(e)).map(e=>e.number),[N,h]),T=null!==N?S.length>0:null!==C&&i9(C),E=n||v,A=(0,s.useCallback)((e,t)=>{p(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e))},[]),M=(0,s.useCallback)(async e=>{if(!E){y(!0);try{await a(e,l)}catch(e){}finally{y(!1)}}},[E,a,l]),R=(0,s.useCallback)(async()=>{if(!E&&null!==x){y(!0);try{let e=T&&g.trim()?g.trim():x.toString();await a(e,l)}catch(e){}finally{y(!1)}}},[E,a,l,x,T,g]),L=(0,s.useCallback)(async()=>{if(E)return;let e=[...h].sort((e,t)=>e-t);if(0===e.length)return;let t=T?g.trim():e.join(",");if(""!==t){y(!0);try{await a(t,l)}catch(e){}finally{y(!1)}}},[E,a,l,h,T,g]),P=(0,s.useCallback)(async e=>{if(!E&&l){y(!0);try{await a(e,l)}catch(e){}finally{y(!1)}}},[E,a,l]);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:c,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?m("confirmationFrom",{toolName:d}):m("confirmationFromClaude")]}),i&&(0,r.jsx)(u.$n,{variant:"ghost",type:"button",onClick:i,"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"})})})]}),(0,I.XF)(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?m("askUserQuestionProgress",{index:t.askUserQuestion.questionIndex+1,total:t.askUserQuestion.questionCount}):m("askUserQuestionSource")}),(0,r.jsx)("p",{className:"text-foreground leading-relaxed",children:(0,I.XF)(t)?t.question:m("unclassifiedTitle")}),E&&(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)(u.y$,{size:"sm",variant:"accent"}),(0,r.jsx)("span",{children:m("sending")})]}),"yes_no"===t.type&&(0,r.jsx)(os,{promptData:t,disabled:E,onYes:()=>M("yes"),onNo:()=>M("no")}),"multiple_choice"===t.type&&null!==N&&(0,r.jsx)(oi,{promptData:t,disabled:E,checkedNumbers:h,onToggleOption:A,textInputValue:g,onTextInputChange:b,showTextInput:T,onSubmit:L}),"multiple_choice"===t.type&&null===N&&(0,r.jsx)(ol,{promptData:t,disabled:E,selectedOption:x,onSelectOption:f,textInputValue:g,onTextInputChange:b,showTextInput:T,onSubmit:R}),!(0,I.XF)(t)&&(0,r.jsx)(ot,{promptData:t,decisionId:l,disabled:E,onRespond:P})]})}function ot(e){var t,n,a,s,l;let{promptData:i,decisionId:c,disabled:d,onRespond:u}=e,m=(0,o.c)("prompt"),x=c&&null!=(n=i.decisionOptions)?n:null,f=function(e){if(null===i2(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}),f?(0,r.jsx)(or,{choices:f,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))})]}),f?null:x&&x.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(on,{toolName:null!=(a=i.toolName)?a:null,patterns:null!=(s=i.patterns)?s:null,allowAlwaysLabel:null!=(l=null==(t=x.find(e=>"always"===e.reply))?void 0:t.label)?l:null}),(0,r.jsx)(oa,{options:x,disabled:d,onRespond:u})]}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:m("unclassifiedInstruction",{command:m("unclassifiedRespondCommand")})})]})}function on(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 oa(e){let{options:t,disabled:n,onRespond:a}=e,s=(0,o.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)(u.$n,{variant:"ghost",type:"button",disabled:n,onClick:()=>a(String(e.number)),"data-testid":"structured-decision-option-".concat(e.number),className:"".concat(i4," ").concat(3===e.number?i3:i5),children:[e.number,". ",e.label]},e.number))})}function or(e){let{choices:t,disabled:n,onRespond:a}=e,l=(0,o.c)("prompt"),i=(0,s.useId)(),[c,d]=(0,s.useState)(null),m=(0,s.useCallback)(e=>{let t=c===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)},[c,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:l("selectAnOption")}),(0,r.jsx)(u.z6,{name:i,value:null!=c?String(c):"",onValueChange:e=>d(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.labels.map((e,t)=>(0,r.jsxs)("label",{className:m(t+1),children:[(0,r.jsx)(u.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!==c&&a(String(c))},disabled:n||null===c,className:"w-full ".concat(i4," ").concat(i5),children:l("submit")})]})}function os(e){let{promptData:t,disabled:n,onYes:a,onNo:s}=e,l=(0,o.c)("prompt"),i="yes"===t.defaultOption,c="no"===t.defaultOption,d="".concat(i4," ").concat(i5," ").concat(i?"primary default highlighted":""),m="".concat(i4," ").concat(c?"bg-foreground text-background hover:bg-foreground/90 primary default highlighted":i3);return(0,r.jsxs)("div",{className:"flex items-center gap-3",role:"group","aria-label":l("yesNoGroupLabel"),children:[(0,r.jsx)(u.$n,{variant:"ghost",type:"button",onClick:a,disabled:n,className:d,children:l("yes")}),(0,r.jsx)(u.$n,{variant:"ghost",type:"button",onClick:s,disabled:n,className:m,children:l("no")})]})}function ol(e){let{promptData:t,disabled:n,selectedOption:a,onSelectOption:l,textInputValue:i,onTextInputChange:c,showTextInput:d,onSubmit:m}=e,x=(0,s.useId)(),f=(0,o.c)("prompt"),h=(0,s.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:f("selectAnOption")}),(0,r.jsx)(u.z6,{name:x,value:null!=a?String(a):"",onValueChange:e=>l(Number(e)),disabled:n,className:"flex flex-col gap-2",children:t.options.map(e=>(0,r.jsxs)("label",{className:h(e.number),children:[(0,r.jsx)(u.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:f("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(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"text-input-".concat(x),type:"text",value:i,onChange:e=>c(e.target.value),disabled:n,placeholder:f("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:m,disabled:n||null===a,className:"w-full ".concat(i4," ").concat(i5),children:f("submit")})]})}function oi(e){let{promptData:t,disabled:n,checkedNumbers:a,onToggleOption:l,textInputValue:i,onTextInputChange:c,showTextInput:d,onSubmit:m}=e,x=(0,s.useId)(),f=(0,o.c)("prompt"),h=(0,s.useCallback)(e=>{let t=n?"opacity-50 cursor-not-allowed":"";return"".concat("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all"," ").concat(e?"bg-accent-50 dark:bg-accent-900/30 border-2 border-accent-500":"bg-surface border-2 border-border hover:border-input"," ").concat(t)},[n]),p=0===a.length,g=d&&""===i.trim();return(0,r.jsxs)("div",{className:"space-y-3","data-testid":"multi-select-prompt-actions",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"multi-select-hint",children:f("multiSelectHint")}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"sr-only",children:f("selectAllThatApply")}),(0,r.jsx)("div",{role:"group","aria-label":f("selectAllThatApply"),className:"flex flex-col gap-2",children:t.options.map(e=>{let t=a.includes(e.number);return(0,r.jsxs)("label",{className:h(t),children:[(0,r.jsx)(u.Sc,{checked:t,onCheckedChange:t=>l(e.number,!0===t),disabled:n,className:"mt-1","data-testid":"multi-select-option-".concat(e.number),"aria-label":"".concat(e.number,". ").concat(e.label)}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("span",{className:"font-medium",children:[e.number,". ",e.label]}),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:"multi-text-input-".concat(x),className:"sr-only",children:f("customValueInput")}),(0,r.jsx)("input",{id:"multi-text-input-".concat(x),type:"text",value:i,onChange:e=>c(e.target.value),disabled:n,placeholder:f("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","data-testid":"multi-select-submit",onClick:m,disabled:n||p||g,className:"w-full ".concat(i4," ").concat(i5),children:f("submit")})]})}let oo=(0,s.memo)(function(e){let t,{promptData:n,messageId:a,decisionId:l,visible:i,answering:o,onRespond:c,onDismiss:d,cliToolName:u}=e,{shouldRender:m,animationClass:x}=A({visible:i&&null!==n,duration:200}),f=(0,s.useId)();if(!m||!n)return null;let h=(t="opacity-100","animate-fade-in"===x?t="opacity-100 transform translate-y-0":"animate-fade-out"===x&&(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(x," ").concat(t));return(0,r.jsx)(T.t,{componentName:"PromptPanel",children:(0,r.jsx)("div",{"data-testid":"prompt-panel",role:"dialog","aria-labelledby":f,"aria-modal":"true",className:h,children:(0,r.jsx)(oe,{promptData:n,answering:o,onRespond:c,decisionId:l,onDismiss:d,labelId:f,cliToolName:u})})})});var oc=n(35619),od=n(93141);let ou=(0,s.memo)(function(e){var t,n,a;let{worktreeId:l,cliToolId:i,instanceId:c,diff:d,disabled:m=!1}=e,x=(0,o.c)("worktree"),f=(0,u.SC)(),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),j=(null==d?void 0:d.revertedMessageId)!=null,w=(0,s.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,s.useCallback)(async e=>{b(null),p(e);try{let t=await fetch("/api/worktrees/".concat(l,"/opencode/diff"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,instanceId:null!=c?c:i})}),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)}},[l,i,c]),N=(0,s.useCallback)(async()=>{await f({title:x("opencodeDiff.revertConfirmTitle"),description:x("opencodeDiff.revertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.revertConfirmLabel"),variant:"danger"})&&await k("revert")},[f,x,w.length,k]),C=(0,s.useCallback)(async()=>{await f({title:x("opencodeDiff.unrevertConfirmTitle"),description:x("opencodeDiff.unrevertConfirmBody",{count:w.length}),confirmLabel:x("opencodeDiff.unrevertConfirmLabel")})&&await k("unrevert")},[f,x,w.length,k]);return"opencode"!==i?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)(oc.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?x("opencodeDiff.revertedTitle"):x("opencodeDiff.title")}),(0,r.jsx)("span",{className:"text-muted-foreground",children:j?x("opencodeDiff.revertedSubtitle",{count:w.length}):x("opencodeDiff.subtitle",{count:w.length})}),(0,r.jsxs)("span",{className:"ml-auto flex items-center gap-1",children:[null!==h?(0,r.jsx)(u.y$,{size:"sm"}):null,j?(0,r.jsxs)(u.$n,{variant:"ghost",size:"sm",onClick:C,disabled:m||null!==h,children:[(0,r.jsx)(od.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.unrevert")]}):(0,r.jsxs)(u.$n,{variant:"ghost",size:"sm",onClick:N,disabled:m||null!==h,children:[(0,r.jsx)(nL.A,{className:"mr-1 h-3.5 w-3.5","aria-hidden":"true"}),x("opencodeDiff.revert")]})]})]}),null!==g?(0,r.jsx)("p",{className:"mt-1 text-danger-foreground",role:"status",children:x("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:x("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:x("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:x("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)(u.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)(ik,{diff:null!=(n=v.patch)?n:"",filePath:null!=(a=v.file)?a:"",onClose:()=>y(null)}):null})]}):null});var om=n(2954),ox=n(63881),of=n(8355);function oh(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}var op=n(42278);let og=(0,s.memo)(function(e){var t,n,a,l,i,c,d;let{worktreeId:u,splitIndex:m,cliToolId:x,instanceId:f,instance:h,availableInstances:p,onInstanceChange:g,onFocus:b,disabled:v=!1,pendingInsertText:y,onInsertConsumed:j,onMessageSent:w,cliStatus:k="idle",cliStatusUnclassified:N=!1,autoYes:C,history:S,onDropInstance:T,draggedInstanceId:E,onRequestSessionEnd:A,agentModel:M,onAgentSessionChange:R,isMaximized:L=!1,onToggleMaximize:P}=e,D=null!=f?f:x,F=null!=(n=C.enabled)&&n,O=null!=(a=C.expiresAt)?a:null,z=null!=(l=C.lastAutoResponse)?l:null,_=C.onToggle,B=null!=(i=null==S?void 0:S.showArchived)&&i,V=null==S?void 0:S.onShowArchivedChange,U=null==S?void 0:S.historyDisplayLimit,H=null==S?void 0:S.onHistoryDisplayLimitChange,K=null!=(c=null==S?void 0:S.historyUserOnly)&&c,q=null==S?void 0:S.onHistoryUserOnlyChange,$=null==S?void 0:S.onInsertToMessage,G=null==S?void 0:S.onFilePathClick,J=null==S?void 0:S.showToast,Y=(0,o.c)("worktree"),Z=(0,to.Ym)(),[et,en]=(0,s.useState)(null),[ea,er]=(0,s.useState)(null),es=(0,ox.b4)(et,ea,of.LA),el=(0,s.useMemo)(()=>(0,of.h0)(m),[m]),ei=(0,s.useMemo)(()=>(0,t5.$2)(u,m),[u,m]),[ec,ed]=(0,s.useState)(X.wf);(0,s.useEffect)(()=>{ed((0,t5.TR)(ei))},[ei]);let em=(0,s.useCallback)(e=>{ed(e),(0,t5.If)(ei,e)},[ei]),ex=(0,s.useRef)(ec);ex.current=ec,(0,s.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"m"!==e.key.toLowerCase())return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==m)return}else if(0!==m||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;e.preventDefault(),em("chat"===ex.current?"terminal":"chat")}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m,em]);let ef=(0,s.useRef)(P);ef.current=P,(0,s.useEffect)(()=>{function e(e){if(!e.shiftKey||e.altKey||!e.metaKey&&!e.ctrlKey||"Enter"!==e.key)return;let t=e.target instanceof Element?e.target:null,n=null==t?void 0:t.closest("[data-split-index]");if(n){if(Number(n.getAttribute("data-split-index"))!==m)return}else if(0!==m||(null==t?void 0:t.closest('input, textarea, select, [contenteditable="true"]')))return;let a=ef.current;a&&(e.preventDefault(),a())}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[m]);let{terminal:eh,prompt:ep,agentSession:eg,setAutoScroll:eb,setPromptAnswering:ev,clearPrompt:ey,refresh:ej}=(0,tH.NK)({worktreeId:u,cliToolId:x,instanceId:D,enabled:!v}),[ew,ek]=(0,s.useState)(!1);(0,s.useEffect)(()=>{ek(!1)},[u,x,D]),(0,s.useEffect)(()=>{eh.isRunning||ek(!1)},[eh.isRunning]);let eN=Y("directInput.toggle"),eC=Y("directInput.toggleAria"),eS=(0,s.useCallback)(()=>{ek(e=>!e)},[]),eI=(0,s.useCallback)(()=>{ek(!1)},[]),{messages:eT,isLoading:eE,refresh:eA}=(0,tK.Md)({worktreeId:u,cliToolId:x,instanceId:D,limit:U,includeArchived:B,enabled:!v}),eM=(0,s.useCallback)((e,t)=>tm.y.sendMessage(u,e,t),[u]),eR=(0,tq.Fx)(),eD=(0,s.useMemo)(()=>({offline:(0,tq.sV)(eR.signals),reachable:(0,tq._X)(eR.signals)}),[eR.signals]),{messages:eF,sendOptimistic:eO,retry:ez,discard:e_}=(0,tW.v4)({worktreeId:u,serverMessages:eT,sendFn:eM,onSent:eA,connectivity:eD}),{visible:eB,width:eV,toggle:eU,setWidth:eH}=(0,i$.TG)(),eK=s.useRef(null),eW=(0,s.useCallback)(e=>{let t=eK.current;if(!t)return;let n=t.offsetWidth;0!==n&&eH(eV+e/n*100)},[eV,eH]),eq="opencode"===x||"copilot"===x,{compactTuiLayoutPadding:e$,preservePaintedPanelRows:eG}=(0,s.useMemo)(()=>(0,t4.EK)(x),[x]),eJ=(0,s.useCallback)(e=>eb(e),[eb]),eY=(0,s.useCallback)(e=>{ej(),eA(),null==w||w(e)},[ej,eA,w]),eQ=(0,s.useCallback)(e=>{let t=e_(e);t&&(null==$||$(t))},[e_,$]),eX=(0,s.useCallback)(async(e,t)=>{ev(!0);try{let n=t?{decisionId:t,answer:e,cliTool:x,...D&&D!==x?{instanceId:D}:{}}:oh(e,x,(0,I.XF)(ep.data)?ep.data:null,D),a=await fetch(t?"/api/worktrees/".concat(u,"/respond"):"/api/worktrees/".concat(u,"/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));let r=await a.json().catch(()=>null);if((null==r?void 0:r.success)===!1){null==J||J(Y("promptResponse.refused"),"warning"),await ej();return}ey(),await ej()}catch(e){console.error("[TerminalSplitPaneContent] prompt response error:",e)}finally{ev(!1)}},[u,x,D,ep.data,ev,ey,ej,J,Y]),eZ=(0,s.useCallback)(()=>{ey()},[ey]),e0="chat"===ec,e1=eh.isSelectionListActive,e2=e1&&!e0,e4=(0,s.useMemo)(()=>e2&&!0===(0,op.S$)(eh.output).offersPlanApprove,[e2,eh.output]),e5="running"===eh.sessionStatus&&!N,e3=ep.visible&&(!F||(null==(d=ep.data)?void 0:d.type)==="multiple_choice"&&!0===d.multiSelect),e6=i2(ep.data),e9=eh.isUnclassifiedActive&&!e1&&!ep.visible&&!e0,e8=tR(eh.composerText),e7=t_(x,eh.realtimeSnippet||eh.output),te=(0,s.useMemo)(()=>({messages:eF,worktreeId:u,onFilePathClick:null!=G?G:()=>{},isLoading:eE,className:"h-full",showToast:J,onInsertToMessage:$,onRetryPending:ez,onDiscardPending:eQ,showArchived:B,onShowArchivedChange:V,historyDisplayLimit:U,onHistoryDisplayLimitChange:H,historyUserOnly:K,onHistoryUserOnlyChange:q,splitIndex:m,cliToolId:x}),[eF,ez,eQ,u,G,eE,J,$,B,V,U,H,K,q,m,x]),tt=(0,s.useMemo)(()=>(0,r.jsx)(nn.bl,{...te,onCollapse:eU}),[te,eU]),tn=(0,s.useMemo)(()=>(0,r.jsx)(tE.D,{output:eh.output,isActive:eh.isRunning,attaching:eh.attaching,isThinking:eh.isThinking,autoScroll:eh.autoScroll,onScrollChange:eJ,disableAutoFollow:eq,compactTuiLayoutPadding:e$,preservePaintedPanelRows:eG}),[eh.output,eh.isRunning,eh.attaching,eh.isThinking,eh.autoScroll,eJ,eq,e$,eG]),ta=(0,s.useMemo)(()=>(0,r.jsx)("div",{"data-testid":"split-chat-slot-".concat(m),"aria-label":Y("surfaceMode.chatSurfaceLabel"),className:"flex h-full min-h-0 w-full overflow-hidden bg-surface text-surface-foreground",children:(0,r.jsx)("div",{className:"min-w-0 min-h-0 flex-1 overflow-hidden",children:(0,r.jsx)(tU.wY,{messages:te.messages,worktreeId:u,cliToolId:x,instanceId:D,history:te,live:{isRunning:eh.isRunning,attaching:eh.attaching,sessionStatus:eh.sessionStatus,isThinking:eh.isThinking,isPromptWaiting:ep.visible,promptData:ep.data,isSelectionListActive:eh.isSelectionListActive,isPagerActive:eh.isPagerActive,isDismissablePanelActive:eh.isDismissablePanelActive,isUnclassifiedActive:eh.isUnclassifiedActive},onSurfaceModeChange:em,frame:eh.output,onKeysSent:ej})})}),[te,m,Y,u,x,D,eh.isRunning,eh.attaching,eh.sessionStatus,eh.isThinking,eh.isSelectionListActive,eh.isPagerActive,eh.isDismissablePanelActive,eh.isUnclassifiedActive,eh.output,ej,ep.visible,ep.data,em]),tr=(0,s.useMemo)(()=>eB?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{id:(0,nn.Ce)(m),"data-testid":"split-history-slot-".concat(m),"aria-label":"History pane",style:{width:"".concat(eV,"%")},className:"flex-shrink-0 overflow-hidden min-h-0",children:tt}),(0,r.jsx)(lS.f,{onResize:eW,orientation:"horizontal",ariaValueNow:eV})]}):null,[eB,eV,tt,eW,m]),ts=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:eK,"data-testid":"split-terminal-row-".concat(m),className:"flex h-full min-h-0 w-full",children:[tr,(0,r.jsx)("div",{"data-testid":"split-terminal-slot-".concat(m),style:eB?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0 relative",children:tn})]}),[eB,tr,tn,m]),tl=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:eK,"data-testid":"split-chat-row-".concat(m),className:"flex h-full min-h-0 w-full",children:[tr,(0,r.jsx)("div",{"data-testid":"split-chat-output-".concat(m),style:eB?void 0:{width:"100%"},className:"flex-grow overflow-hidden min-w-0 min-h-0",children:ta})]}),[eB,tr,ta,m]),ti=(0,s.useMemo)(()=>(0,r.jsxs)("div",{ref:er,className:"space-y-2","data-testid":"split-footer-".concat(m),children:[e2?(0,r.jsx)(eP.y,{worktreeId:u,cliToolId:x,instanceId:D,onKeysSent:ej,showPagerKeys:eh.isPagerActive,hideEnterKey:e4}):null,e9?(0,r.jsx)(tA.U,{worktreeId:u,cliToolId:x,instanceId:D,onKeysSent:ej}):null,e8?(0,r.jsx)(tL,{worktreeId:u,cliToolId:x,instanceId:D,composerText:eh.composerText,onActionSent:ej}):null,e7?(0,r.jsx)(tB,{cliToolId:x,frame:eh.realtimeSnippet||eh.output}):null,e3?(0,r.jsx)(oo,{promptData:ep.data,messageId:ep.messageId,decisionId:e6,visible:ep.visible,answering:ep.answering,onRespond:eX,onDismiss:eZ,cliToolName:(0,Q.oo)(x)}):null,eh.isRunning?(0,r.jsx)(tV.XU,{worktreeId:u,cliToolId:x,instanceId:D,hasAgentSession:null!==eg.session,onKeysSent:ej,collapsible:!0,layout:"desktop"}):null,(0,r.jsx)(ou,{worktreeId:u,cliToolId:x,instanceId:D,diff:eg.diff,disabled:!eh.isRunning}),ew?(0,r.jsx)(i1,{worktreeId:u,cliToolId:x,instanceId:D,onKeysSent:ej,onClose:eI}):null,(0,r.jsx)(eL.E,{worktreeId:u,onMessageSent:eY,onOptimisticSend:eO,cliToolId:x,instanceId:D,isSessionRunning:eh.isRunning,pendingInsertText:null!=y?y:null,onInsertConsumed:j,splitIndex:m,onFocus:b,heightScope:el,maxHeight:es,isProcessing:e5,showToast:J,agentModeSlot:(0,r.jsx)(i0,{worktreeId:u,cliToolId:x,instanceId:D,agentMode:eh.agentMode,sessionStatus:eh.sessionStatus,isPromptWaiting:ep.visible,isSelectionListActive:eh.isSelectionListActive,isDismissablePanelActive:eh.isDismissablePanelActive,isUnclassifiedActive:eh.isUnclassifiedActive,onKeysSent:ej}),autoYesSlot:(0,r.jsx)(om.T,{enabled:F,expiresAt:null!=O?O:null,onToggle:_,lastAutoResponse:null!=z?z:null,cliToolName:x,inline:!0}),directInputSlot:(0,r.jsxs)("button",{type:"button","data-testid":"direct-input-toggle","aria-pressed":ew,"aria-label":eC,title:eC,disabled:!eh.isRunning,onClick:eS,className:"shrink-0 inline-flex items-center gap-1 h-[22px] px-1 @min-[520px]:px-2 rounded-md border text-[11px] font-medium leading-none whitespace-nowrap transition-colors disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ".concat(ew?"bg-info-subtle border-info-border text-info-foreground":"bg-surface border-border text-muted-foreground hover:bg-muted"),children:[(0,r.jsx)(W.A,{size:14,"aria-hidden":"true",className:"shrink-0"}),(0,r.jsx)("span",{className:"hidden @min-[520px]:inline","data-testid":"direct-input-toggle-label",children:eN})]})})]}),[e2,e4,e3,e9,e8,e7,eh.realtimeSnippet,eh.output,eg.session,eh.composerText,eh.agentMode,eh.sessionStatus,eh.isSelectionListActive,eh.isDismissablePanelActive,eh.isUnclassifiedActive,eh.isPagerActive,u,x,D,ej,ep.data,ep.messageId,e6,ep.visible,ep.answering,eX,eZ,eY,eO,eh.isRunning,e5,y,j,m,b,F,O,z,_,ew,eS,eI,eN,eC,J,el,es,eg.diff]),tc=(0,Q.sw)(null!=h?h:{cliTool:x}),td=(0,s.useCallback)(()=>{null==A||A({cliToolId:x,instanceId:D,label:tc})},[A,x,D,tc]),tu=(0,s.useMemo)(()=>{if(!A||!eh.isRunning)return null;let e=Y("terminal.endSessionFor",{name:tc});return(0,r.jsx)(ee.m_,{content:e,placement:"bottom",children:(0,r.jsx)("button",{type:"button",onClick:td,"aria-label":e,"data-testid":"terminal-end-session-button-".concat(m),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)(eu.A,{size:14,"aria-hidden":"true"})})})},[A,eh.isRunning,Y,tc,td,m]);(0,s.useEffect)(()=>{null==R||R(D,eg)},[R,D,eg]);let tx=lf(M,null,null==(t=eg.session)?void 0:t.agent),tf=lg(eg.session,eg.context,Y,Z),th=lb(eg.session,eg.context,Y,Z);return(0,r.jsx)(eo,{worktreeId:u,splitIndex:m,cliToolId:x,instanceId:D,instance:h,availableInstances:p,onInstanceChange:g,headerExtras:tu,status:k,statusUnclassified:N,agentModel:tx,agentUsage:tf,agentUsageDetail:th,onFocus:b,attaching:eh.attaching,surfaceMode:ec,onSurfaceModeChange:em,isMaximized:L,onToggleMaximize:P,terminal:"chat"===ec?tl:ts,footer:ti,bodyRef:en,onDropInstance:T,draggedInstanceId:E})}),ob=(0,s.memo)(function(e){var t;let{task:n,latestRun:a,latestRunGates:l,onOpen:i,className:c=""}=e,d=(0,o.c)("worktree"),[u,m]=(0,s.useState)(!1),x=(0,s.useRef)(null),f=(0,s.useId)(),h=function(e,t){var n;let a=(0,s.useRef)(null);return(null!==e&&t&&t.length>0&&(a.current={runId:e.id,gates:t}),t&&t.length>0)?t:null!==e&&(null==(n=a.current)?void 0:n.runId)===e.id?a.current.gates:null}(a,l),p=(0,s.useMemo)(()=>{let e=[n?d("verification.chip.taskReason",{title:n.title,status:d("task.status.".concat(n.status))}):d("verification.chip.noTask")];if(a){if(e.push(d("verification.chip.runReason",{verdict:d("verification.runStatus.".concat(a.status)),runId:a.id})),e.push(d("verification.runStatusGloss.".concat(a.status))),h&&h.length>0){let t=h.filter(e=>r_.includes(e.status));e.push(t.length>0?d("verification.chip.failingGates",{gates:t.map(e=>e.gateId).join(", ")}):d("verification.chip.gatesPassed",{count:h.length}))}}else e.push(d("verification.chip.noRun"));return e.push(d("verification.chip.openHint")),e},[n,a,h,d]),g=p.join(" \xb7 "),b=(0,s.useCallback)(()=>{m(!1),i()},[i]),v=(0,s.useCallback)(()=>{m(e=>!e)},[]);return(0,s.useEffect)(()=>{if(!u)return;let e=e=>{var t;null!=(t=x.current)&&t.contains(e.target)||m(!1)},t=e=>{"Escape"===e.key&&m(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[u]),(0,r.jsxs)("div",{ref:x,className:"relative inline-flex max-w-full ".concat(c).trim(),children:[(0,r.jsxs)("div",{className:"inline-flex min-w-0 max-w-full grow items-center gap-1 rounded-full border border-border bg-surface-2 pr-1 text-xs text-foreground",children:[(0,r.jsxs)("button",{type:"button",onClick:b,"data-testid":"verification-status-chip","aria-label":g,title:g,className:"inline-flex min-w-0 flex-1 items-center gap-1.5 rounded-full px-2 py-1 transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring touch-manipulation",children:[(0,r.jsx)(rL.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:n?(t=n.title,t.length<=36?t:"".concat(t.slice(0,35),"…")):d("verification.title")}),n&&(0,r.jsx)(rP.E,{variant:rF[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)(rP.E,{variant:a?rO[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.unverified")})]}),(0,r.jsx)("button",{type:"button",onClick:v,"data-testid":"verification-chip-reason-toggle","aria-expanded":u,"aria-controls":f,"aria-label":d(u?"verification.chip.hideReason":"verification.chip.showReason"),className:"inline-flex min-h-[32px] min-w-[32px] flex-shrink-0 items-center justify-center rounded-full 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)(k.A,{size:14,"aria-hidden":"true"})})]}),u&&(0,r.jsxs)("div",{id:f,role:"tooltip","data-testid":"verification-chip-reason-popover",className:"absolute left-0 top-full z-50 mt-1 w-72 max-w-[80vw] rounded-lg border border-border bg-surface p-3 text-xs leading-relaxed text-foreground shadow-lg",children:[(0,r.jsx)("p",{className:"mb-1 font-semibold",children:d("verification.chip.reasonHeading")}),(0,r.jsx)("ul",{className:"space-y-1",children:p.map(e=>(0,r.jsx)("li",{className:"break-words",children:e},e))})]})]})}),ov=(0,s.memo)(function(e){let{isBranchMismatch:t,currentBranch:n,initialBranch:a}=e,l=(0,o.c)("worktree"),[i,c]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{c(!1)},[n]),!t||i||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)(aU.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:[l("branchMismatch.changedFrom")," ",(0,r.jsx)("span",{className:"font-medium",children:a})," ",l("branchMismatch.to")," ",(0,r.jsx)("span",{className:"font-medium",children:n})]})}),(0,r.jsx)("button",{type:"button",onClick:()=>c(!0),className:"p-1 rounded hover:bg-warning-subtle transition-colors","aria-label":l("branchMismatch.dismiss"),children:(0,r.jsx)(eu.A,{className:"w-4 h-4"})})]})});var oy=n(58734),oj=n(59847);let ow=(0,s.memo)(function(e){let{isOpen:t,onClose:n,onConfirm:a,worktreeId:l,sourcePath:i,sourceType:c}=e,d=(0,o.c)("worktree"),m=(0,o.c)("common"),[x,f]=(0,s.useState)(""),[h,p]=(0,s.useState)(new Set([""])),[g,b]=(0,s.useState)([]),[v,y]=(0,s.useState)(!1),[j,w]=(0,s.useState)(new Set),k=i.includes("/")?i.substring(0,i.lastIndexOf("/")):"";(0,s.useEffect)(()=>{t&&(f(k),p(new Set([""])),b([]),N())},[t,l]);let N=(0,s.useCallback)(async()=>{y(!0);try{let e=await fetch("/api/worktrees/".concat(l,"/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{y(!1)}},[l]),C=(0,s.useCallback)(async e=>{w(t=>new Set(t).add(e));try{let t=await fetch("/api/worktrees/".concat(l,"/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{w(t=>{let n=new Set(t);return n.delete(e),n})}},[l]),S=(0,s.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 C(e)},[g,C]),I=(0,s.useCallback)(e=>!(e===k||"directory"===c&&(e===i||e.startsWith(i+"/")))&&!0,[k,i,c]),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=h.has(e.path),a=x===e.path,s=j.has(e.path),l=I(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&&f(e.path)},children:[(0,r.jsx)("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",onClick:t=>{t.stopPropagation(),S(e.path)},children:s?(0,r.jsx)(u.y$,{size:"xs",variant:"muted"}):(0,r.jsx)(aJ.A,{className:"w-3 h-3 text-muted-foreground transition-transform ".concat(n?"rotate-90":"")})}),n?(0,r.jsx)(oy.A,{className:"w-4 h-4 text-warning flex-shrink-0"}):(0,r.jsx)(oj.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=>T(e,t+1))})]},e.path)},E=I(x);return(0,r.jsx)(tN.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:i})]}),(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(""===x?"bg-accent-100 text-accent-800":"hover:bg-muted text-foreground"," ").concat(I("")?"":"opacity-40 cursor-not-allowed"),onClick:()=>{I("")&&f("")},children:[(0,r.jsx)("span",{className:"w-4 h-4"}),(0,r.jsx)(oj.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)(u.y$,{size:"md",variant:"muted"})}):g.map(e=>T(e,1))]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(u.$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:m("cancel")}),(0,r.jsx)(u.$n,{variant:"ghost",onClick:()=>a(x),disabled:!E,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 ok(e,t){let n=e.trim();return n?0>=n.lastIndexOf(".")?n+t:n:""}let oN=(0,s.memo)(function(e){let{isOpen:t,parentPath:n,onConfirm:a,onCancel:l}=e,i=(0,o.c)("worktree"),c=(0,o.c)("common"),[d,u]=(0,s.useState)(""),[m,x]=(0,s.useState)(".md"),f=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(t){u(""),x(".md");let e=setTimeout(()=>{var e;null==(e=f.current)||e.focus()},100);return()=>clearTimeout(e)}},[t]);let h=(0,s.useCallback)(()=>{let e=ok(d,m);e&&a(e)},[d,m,a]),p=(0,s.useCallback)(e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),h())},[h]),g=ok(d,m),b=n?"".concat(n,"/").concat(g):g;return(0,r.jsx)(tN.a,{isOpen:t,onClose:l,title:i("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:i("newFileDialog.fileNameLabel")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{ref:f,id:"new-file-name","data-testid":"new-file-name-input",type:"text",value:d,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:i("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=>x(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:eY.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:l,className:"px-4 py-2 text-sm font-medium text-foreground bg-muted hover:bg-muted/80 rounded-lg transition-colors",children:c("cancel")}),(0,r.jsx)("button",{type:"button","data-testid":"new-file-confirm-button",onClick:h,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:i("newFileDialog.create")})]})]})})}),oC=(0,s.memo)(function(e){var t,n,a,l,i;let{worktreeId:c,worktree:d,worktreeName:u,worktreeStatus:m,instances:x,rosterReady:f,activeInstanceId:h,setActiveInstanceId:p,instanceSelectionRequest:g=null,onInstanceSelectionHandled:b,hasUpdate:v,lastAutoResponse:y,activeActivity:j,onActivityToggle:w,onActivityOpen:k,verification:N,onInfoClick:C,onWorktreeStatusChange:S,pendingInsertTextMap:I,setFocusedSplitIndex:E,handleInsertToSplit:A,handleInsertConsumed:M,handleInsertToMessage:R,autoYesStateMap:L,makeAutoYesToggleHandler:P,showArchived:D,onShowArchivedChange:F,historyDisplayLimit:O,onHistoryDisplayLimitChange:z,historyUserOnly:_,onHistoryUserOnlyChange:B,onMessageSent:V,onFilePathClick:U,showToast:H,tabsState:K,tabsActions:W,onLoadContent:q,onLoadError:$,onSetLoading:G,onFilePanelSave:J,onDirtyChange:Y,onOpenFile:Q,diffContent:X,diffFilePath:Z,onCloseDiff:ee,fileSearch:et,fileTreeRefresh:en,onFileSelect:ea,onNewFile:er,onNewDirectory:es,onRename:el,onDelete:ei,onUpload:eo,onMove:ec,onFileTreeReset:ed,onDiffSelect:eu,onAgentInstancesChange:em,vibeLocalModel:ex,onVibeLocalModelChange:ef,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ep,isInfoModalOpen:eg,onInfoModalClose:eb,onWorktreeUpdate:ev,fileInputRef:ey,onFileInputChange:ej,onKillSession:ew,onRequestSessionEnd:ek,killTarget:eN,isKillPending:eC,onKillCancel:eS,onKillConfirm:eI,moveTarget:eT,isMoveDialogOpen:eE,onMoveCancel:eA,onMoveConfirm:eM,showNewFileDialog:eR,newFileParentPath:eL,onNewFileConfirm:eP,onNewFileCancel:eD,killDialogTitle:eF,killDialogWarning:eO,cancelLabel:ez,endLabel:e_}=e,eB=(0,o.c)("worktree"),[eV,eU]=s.useState(null),eH=(0,s.useCallback)(e=>eU(e),[]),eK=(0,s.useCallback)(()=>eU(null),[]),eW=(0,s.useMemo)(()=>lv(null==d?void 0:d.sessionStatusByInstance),[null==d?void 0:d.sessionStatusByInstance]),[eq,e$]=(0,s.useState)({}),eG=(0,s.useCallback)((e,t)=>{e$(n=>n[e]===t?n:{...n,[e]:t})},[]),[eY,eQ]=s.useState(null),eX=s.useRef(0),eZ=(0,s.useCallback)(e=>{p(e),eX.current+=1,eQ({instanceId:e,token:eX.current})},[p]),e0=s.useRef(0);s.useEffect(()=>{g&&g.token!==e0.current&&(e0.current=g.token,eZ(g.instanceId),null==b||b(g.token))},[g,eZ,b]);let e1=(0,s.useCallback)(()=>{k("verification")},[k]),e2=(0,s.useCallback)(e=>{var t,n,a,s,l,i,o,u,m,x;let{splitIndex:f,cliToolId:h,instanceId:g,instance:b,availableInstances:v,onInstanceChange:j,onFocus:w,onDropInstance:k,isMaximized:N,onToggleMaximize:C}=e,S=null!=(o=I.get(f))?o:null,T=L.get(g),E=null!=(u=null==T?void 0:T.enabled)&&u,R=null!=(m=null==T?void 0:T.expiresAt)?m:null,K=null!=(x=null==d||null==(t=d.sessionStatusByInstance)?void 0:t[g])?x:null==d||null==(n=d.sessionStatusByCli)?void 0:n[h],W=(0,tC.kA)(K),q=(0,tC.px)(K);return(0,r.jsx)(og,{worktreeId:c,splitIndex:f,cliToolId:h,instanceId:g,instance:b,availableInstances:v,onInstanceChange:e=>{j(e),0===f&&p(e)},onFocus:w,pendingInsertText:S,onInsertConsumed:()=>M(f),onMessageSent:V,cliStatus:W,cliStatusUnclassified:q,onAgentSessionChange:eG,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:E,expiresAt:R,lastAutoResponse:y,onToggle:P(h,g)},history:{showArchived:D,onShowArchivedChange:F,historyDisplayLimit:O,onHistoryDisplayLimitChange:z,historyUserOnly:_,onHistoryUserOnlyChange:B,onInsertToMessage:e=>A(f,e),onFilePathClick:U,showToast:H},onDropInstance:k,draggedInstanceId:eV,isMaximized:N,onToggleMaximize:C,onRequestSessionEnd:ek})},[c,I,L,M,V,p,y,P,null==d?void 0:d.sessionStatusByCli,null==d?void 0:d.sessionStatusByInstance,U,H,A,D,F,O,z,_,B,eV,ek,eG]),e4=(0,s.useMemo)(()=>(0,r.jsx)(iG,{worktreeId:c,instances:x,rosterReady:f,renderPane:e2,onFocusedSplitChange:E,showToast:H,onActiveInstanceChange:p,headerInstanceSelection:eY}),[c,x,f,e2,E,H,p,eY]),e5=(0,s.useMemo)(()=>(0,r.jsx)(iE,{terminal:e4,terminalHeader:null,fileTabs:K,worktreeId:c,onCloseTab:W.closeTab,onActivateTab:W.activateTab,onLoadContent:q,onLoadError:$,onSetLoading:G,onFileSaved:J,diffContent:X,diffFilePath:Z,onCloseDiff:ee,onDirtyChange:Y,onMoveToFront:W.moveToFront,onOpenFile:Q}),[e4,K,c,W.closeTab,W.activateTab,q,$,G,J,X,Z,ee,Y,W.moveToFront,Q]),e3=(0,s.useMemo)(()=>(0,r.jsx)(lJ,{active:j,onToggle:w}),[j,w]),e6=(0,s.useMemo)(()=>{var e;return{files:(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsx)(nB,{query:et.query,mode:et.mode,isSearching:et.isSearching,error:et.error,onQueryChange:et.setQuery,onModeChange:et.setMode,onClear:et.clearSearch}),(0,r.jsx)(nD,{worktreeId:c,onFileSelect:ea,onNewFile:er,onNewDirectory:es,onRename:el,onDelete:ei,onUpload:eo,onMove:ec,onResetView:ed,refreshTrigger:en,pollingEnabled:"files"===j,searchQuery:et.query,searchMode:et.mode,searchResults:null==(e=et.results)?void 0:e.results,className:"flex-1 min-h-0"})]}),git:(0,r.jsx)(lo,{worktreeId:c,onDiffSelect:eu,isMobile:!1,worktree:null!=d?d:void 0,onInsertToMessage:R,className:"h-full"}),notes:(0,r.jsx)(nG,{worktreeId:c,className:"h-full",onInsertToMessage:R}),schedules:(0,r.jsx)(aR,{worktreeId:c,className:"h-full",onInsertToMessage:R,instances:x}),agent:(0,r.jsx)(a9,{worktreeId:c,instances:x,onInstancesChange:em,vibeLocalModel:ex,onVibeLocalModelChange:ef,vibeLocalContextWindow:eh,onVibeLocalContextWindowChange:ep,modelByInstance:eW,className:"h-full"}),timer:(0,r.jsx)(rl,{worktreeId:c,instances:x}),todo:(0,r.jsx)(n0,{worktreeId:c,className:"h-full"}),skills:(0,r.jsx)(rM,{worktreeId:c,className:"h-full"}),verification:(0,r.jsx)(so,{state:N,className:"h-full"}),env:(0,r.jsx)(sP,{worktreeId:c,className:"h-full"})}},[c,d,j,et.query,et.mode,et.isSearching,et.error,et.setQuery,et.setMode,et.clearSearch,null==(t=et.results)?void 0:t.results,ea,er,es,el,ei,eo,ec,ed,en,eu,R,x,em,ex,ef,eh,ep,eW,N]),e9=(0,s.useMemo)(()=>null===j?null:(0,r.jsx)(lX,{active:j,activities:e6}),[j,e6]);return(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsxs)("div",{className:"flex h-full overflow-hidden relative",children:[e3,(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!=(l=null!=(a=null==d?void 0:d.repositoryDisplayName)?a:null==d?void 0:d.repositoryName)?l:eB("detail.unknownRepository"),description:null==d?void 0:d.description,status:m,gitStatus:null==d?void 0:d.gitStatus,onInfoClick:C,hasUpdate:v,worktreeStatus:null!=(i=null==d?void 0:d.status)?i:null,onWorktreeStatusChange:S,sessionStatusByCli:null==d?void 0:d.sessionStatusByCli,sessionStatusByInstance:null==d?void 0:d.sessionStatusByInstance,instances:x,activeInstanceId:h,onActiveInstanceChange:eZ,onAgentDragStart:eH,onAgentDragEnd:eK,onKillSession:ew,agentSessionByInstance:eq,verificationChip:(0,r.jsx)(ob,{task:N.task,latestRun:N.latestRun,latestRunGates:null!==N.selectedRun&&N.selectedRun.id===(null==(n=N.latestRun)?void 0:n.id)?N.selectedRun.gates:null,onOpen:e1})}),(null==d?void 0:d.gitStatus)&&(0,r.jsx)(ov,{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)(lI,{activityPane:e9,rightPane:(0,r.jsx)(lT.cV,{terminal:e5})})})]}),(0,r.jsx)(lk,{worktreeId:c,worktree:d,isOpen:eg,onClose:eb,onWorktreeUpdate:ev}),(0,r.jsx)("input",{ref:ey,type:"file",accept:eJ.join(","),onChange:ej,className:"hidden","aria-label":eB("detail.uploadFile")}),(0,r.jsx)(tN.a,{isOpen:null!==eN,onClose:eS,title:eF,size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:eO}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:eS,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:ez}),(0,r.jsx)("button",{type:"button",onClick:eI,disabled:eC,"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:e_})]})]})}),eT&&(0,r.jsx)(ow,{isOpen:eE,onClose:eA,onConfirm:eM,worktreeId:c,sourcePath:eT.path,sourceType:eT.type}),(0,r.jsx)(oN,{isOpen:eR,parentPath:eL,onConfirm:eP,onCancel:eD})]})})});Q.oo;var oS=n(51434),oI=n(68955);function oT(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:{...X.kQ}};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:{...X.mS}};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}}function oE(e,t){try{window.localStorage.setItem(lU(e),null!=t?t:lV)}catch(e){}}function oA(e,t){if(e.length!==t.length)return!1;let n=new Set(e);return t.every(e=>n.has(e))}function oM(e,t){return e instanceof Error&&e.message?e.message:t}function oR(e){return e instanceof DOMException&&"AbortError"===e.name}var oL=n(88731);let oP="commandmate:showArchived";var oD=n(7636);let oF="activeCliTab-",oO="activeInstanceId-",oz=[2e3,5e3,1e4],o_={timeoutMs:l4.K3,retries:0};function oB(){let e=(0,o.c)("worktree");return(0,r.jsxs)("div",{className:"flex items-center justify-center h-full bg-surface text-muted-foreground",children:[(0,r.jsx)(d.y,{size:"lg",className:"mr-2"}),(0,r.jsx)("span",{children:e("detail.loadingEditor")})]})}let oV=(0,i.default)(()=>n.e(3922).then(n.bind(n,33922)).then(e=>({default:e.MarkdownEditor})),{loadableGenerated:{webpack:()=>[33922]},ssr:!1,loading:()=>(0,r.jsx)(oB,{})}),oU=(0,s.memo)(function(e){let{label:t}=e;return(0,r.jsxs)("div",{role:"status","aria-live":"polite","data-testid":"worktree-detail-reconnecting-banner",className:"fixed top-2 left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-full border border-warning-border bg-warning-subtle px-3 py-1 text-xs text-warning-foreground shadow-sm",children:[(0,r.jsx)(d.y,{size:"xs"}),(0,r.jsx)("span",{children:t})]})}),oH=(0,s.memo)(function(e){let{message:t,loginLabel:n,onLogin:a}=e;return(0,r.jsx)("div",{className:"flex h-full min-h-[200px] items-center justify-center",role:"alert","aria-live":"assertive","data-testid":"worktree-detail-session-expired",children:(0,r.jsxs)("div",{className:"max-w-md rounded-lg border border-border bg-surface p-6 text-center",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:t}),(0,r.jsx)(eD.$,{variant:"primary",type:"button",onClick:a,className:"mt-4","data-testid":"worktree-detail-relogin",children:n})]})})}),oK=()=>{},oW=["terminal","history","files","memo","info"],oq=(0,s.memo)(function(e){let{worktreeId:t,cliToolId:n,instanceId:a,onMessageSent:s,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,autoYesSlot:u,agentModeSlot:m}=e,x=tQ({cliToolId:n,instanceId:a});return(0,r.jsx)(eL.E,{worktreeId:t,onMessageSent:s,cliToolId:n,instanceId:a,isSessionRunning:l,isProcessing:i,showToast:o,pendingInsertText:c,onInsertConsumed:d,onOptimisticSend:x,autoYesSlot:u,agentModeSlot:m})}),o$=(0,s.memo)(function(e){var t,n,a,i,d,u,f,p,g,v,y,j,w;let{worktreeId:k}=e,{activeActivity:N,activeCliTab:C,activeInstanceId:E,activeTab:A,agentInstances:M,autoYesEnabled:L,autoYesExpiresAt:P,autoYesStateMap:D,diffContent:F,diffFilePath:O,disableAutoFollow:_,displayedInstances:B,editorFilePath:V,error:U,fetchCurrentOutput:H,fileInputRef:K,fileSearch:W,fileTreeRefresh:q,handleActivityOpen:$,handleActivityToggle:G,handleAgentInstancesChange:J,handleAutoYesToggle:Y,handleCloseDiff:Z,handleDelete:ee,handleDiffSelect:en,handleDirtyChange:ea,handleEditorClose:er,handleEditorSave:es,handleFileInputChange:el,handleFilePanelSave:ei,handleFilePathClick:eo,handleFileSelect:ec,handleHistoryDisplayLimitChange:eu,handleHistoryUserOnlyChange:em,handleInfoClick:ex,handleInfoModalClose:ef,handleInsertConsumed:eh,handleInsertConsumedSingle:ep,handleInsertToMessage:eg,handleInsertToSplit:eb,handleKillCancel:ev,handleKillConfirm:ey,openKillConfirm:ej,openActiveKillConfirm:ew,killTarget:ek,isKillPending:eN,handleLoadContent:eC,handleLoadError:eS,handleMessageSent:eI,handleMobileFileViewerClose:eT,handleMobileTabChange:eE,handleMove:eA,handleMoveCancel:eM,handleMoveConfirm:eL,handleNewDirectory:eD,handleNewFile:eO,handleNewFileCancel:ez,handleNewFileConfirm:e_,handleOpenFile:eB,handlePromptDismiss:eV,handlePromptRespond:eU,handleRename:eH,handleReLogin:eK,handleRetry:eW,handleSetLoading:eq,handleShowArchivedChange:e$,handleUpload:eY,handleVibeLocalContextWindowChange:eQ,handleVibeLocalModelChange:eX,handleWorktreeStatusChange:eZ,hasUpdate:e0,historyDisplayLimit:e1,historySubTab:e2,historyUserOnly:e5,isAuthExpired:e3,isEditorMaximized:e6,isInfoModalOpen:e9,isMobile:e8,isMoveDialogOpen:e7,isReconnecting:te,isSelectionListActive:tt,isPagerActive:tn,offersPlanApprove:ta,isDismissablePanelActive:tr,isUnclassifiedActive:ts,sessionStatus:tl,agentMode:to,lastAutoResponse:tc,loading:td,makeAutoYesToggleHandler:tx,mobileFileViewerPath:th,mobileSelectedAgents:tp,moveTarget:tg,newFileParentPath:tb,openMobileDrawer:tv,pendingInsertText:ty,pendingInsertTextMap:tj,rosterReady:tw,instanceSelectionRequest:tk,acknowledgeInstanceSelection:tS,setActiveInstanceId:tI,setFocusedSplitIndex:tT,setHistorySubTab:tE,setIsEditorMaximized:tA,setWorktree:tM,showArchived:tR,showNewFileDialog:tL,showToast:tP,state:tD,tCommon:tF,tWorktree:tO,tabsActions:tz,tabsState:t_,resetFileTreeView:tB,toggleInstanceVisible:tV,verification:tU,vibeLocalContextWindow:tH,vibeLocalModel:tK,visibleInstanceIds:tW,worktree:tq,worktreeName:t$,worktreeStatus:tG}=function(e){var t,n,a,r,i,c,d,u,m,x;let{worktreeId:f}=e,p=(0,nF.a)(),g=(0,s.useRef)(p);g.current=p;let{openMobileDrawer:b}=(0,lH.VF)(),v=(0,l.useRouter)(),y=(0,l.usePathname)(),j=(0,l.useSearchParams)(),w=null!=(i=null==j?void 0:j.get(oD.Kp))?i:null,{state:k,actions:N}=function(){let[e,t]=(0,s.useReducer)(oT,void 0,X.mR),{value:n,setValue:a}=(0,sO.V)({key:"commandmate.worktree.leftPaneCollapsed",defaultValue:!1,validate:e=>"boolean"==typeof e}),r=(0,s.useRef)(e.layout.leftPaneCollapsed);r.current=e.layout.leftPaneCollapsed;let l=(0,s.useRef)(!1);(0,s.useEffect)(()=>{l.current||(l.current=!0,n!==r.current&&t({type:"SET_LEFT_PANE_COLLAPSED",collapsed:n}))},[n]);let i=(0,s.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:i}}(),C=(0,o.c)("worktree"),S=(0,o.c)("error"),T=(0,o.c)("common"),E=(0,o.c)("autoYes"),A=(0,eF.SC)(),M=(0,et.rC)(),R=null!=(c=null==M?void 0:M.worktrees.find(e=>e.id===f))?c:null,[L,P]=(0,s.useState)(R),[D,F]=(0,s.useState)(null===R),[O,z]=(0,s.useState)(null),[_,B]=(0,s.useState)(!1),[V,U]=(0,s.useState)(!1),[H,K]=(0,s.useState)(0),W=(0,s.useRef)(0),q=(0,s.useRef)(0),$=(0,s.useRef)(null),G=(0,s.useRef)(async()=>null),J=(0,s.useCallback)(()=>{null!==$.current&&(clearTimeout($.current),$.current=null)},[]),Y=(0,s.useRef)(null!==R),[Z,ee]=(0,s.useState)(!1),[en,ea]=function(e){let[t,n]=(0,s.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:ih(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=ip(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=ip(t.tabs,n.path,e=>({...e,loading:n.loading}));if(!e)return t;return{...t,tabs:e}}case"SET_ERROR":{let e=ip(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:ih(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:ih(e),content:null,loading:!1,error:null,isDirty:!1}));if(0===e.length)return ib;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=ip(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 ib;case"CLOSE_OTHERS":case"CLOSE_TO_RIGHT":{let e="CLOSE_OTHERS"===n.type?"others":"right",a=new Set(ig(t.tabs,n.path,e));if(0===a.size)return t;let r=t.tabs.filter(e=>!a.has(e.path));return{tabs:r,activeIndex:function(e,t,n){var a;if(0===t.length)return null;let r=null!==e.activeIndex?null==(a=e.tabs[e.activeIndex])?void 0:a.path:void 0;if(void 0!==r){let e=t.findIndex(e=>e.path===r);if(-1!==e)return e}let s=t.findIndex(e=>e.path===n);return -1!==s?s:0}(t,r,n.path)}}default:return t}},ib),a=(0,s.useRef)(!1),r=(0,s.useRef)(e);(0,s.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(ix+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,s.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(ix+e,JSON.stringify(a))}catch(e){}}},[e,t]);let l=(0,s.useRef)(t);l.current=t;let i=(0,s.useCallback)(e=>{let t=l.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,s.useCallback)(e=>{n({type:"CLOSE_TAB",path:e})},[]),c=(0,s.useCallback)(e=>{n({type:"ACTIVATE_TAB",path:e})},[]),d=(0,s.useCallback)((e,t)=>{n({type:"RENAME_FILE",oldPath:e,newPath:t})},[]),u=(0,s.useCallback)(e=>{n({type:"DELETE_FILE",path:e})},[]),m=(0,s.useCallback)(e=>{n({type:"MOVE_TO_FRONT",path:e})},[]),x=(0,s.useCallback)(()=>{n({type:"CLOSE_ALL"})},[]),f=(0,s.useCallback)(e=>{n({type:"CLOSE_OTHERS",path:e})},[]),h=(0,s.useCallback)(e=>{n({type:"CLOSE_TO_RIGHT",path:e})},[]),p=(0,s.useMemo)(()=>({dispatch:n,openFile:i,closeTab:o,activateTab:c,onFileRenamed:d,onFileDeleted:u,moveToFront:m,closeAllTabs:x,closeOtherTabs:f,closeTabsToRight:h}),[n,i,o,c,d,u,m,x,f,h]);return[t,p]}(f),[er,es]=(0,s.useState)(null),[el,ei]=(0,s.useState)(null),[eo,ec]=(0,s.useState)(!1),[ed,eu]=(0,s.useState)(new Map),[em,ex]=(0,s.useState)(null),[ef,eh]=(0,s.useState)(!1),[ep,eg]=(0,s.useState)(!1),[eb,ev]=(0,s.useState)(!1),[ey,ej]=(0,s.useState)(!1),[ew,ek]=(0,s.useState)(!1),[eN,eC]=(0,s.useState)(!1),[eS,eI]=(0,s.useState)(""),[eT,eE]=(0,s.useState)(oI.J_),eA=(0,s.useRef)(!1),[eM,eR]=(0,s.useState)(null),[eL,eP]=(0,s.useState)(aZ.sA),eD=(0,s.useRef)(eL);eD.current=eL;let eO=(0,s.useRef)(L);eO.current=L;let[ez,e_]=(0,s.useState)(()=>(0,Q.lu)((0,aZ.sA)())),eB=(0,s.useRef)(ez);eB.current=ez;let[eV,eU]=(0,s.useState)(null),eH=eV===f,[eK,eW]=(0,s.useState)(null),[eq,e$]=(0,s.useState)(null),[eY,eQ]=(0,s.useState)(()=>{try{let e=window.localStorage.getItem(oF+f);if(e&&(0,Q.hR)(e))return e}catch(e){}return(0,aZ.sA)()[0]}),eX=(0,s.useCallback)(e=>{eQ(e);try{window.localStorage.setItem(oF+f,e)}catch(e){}},[f]),eZ=(0,s.useRef)(eY);eZ.current=eY;let[e0,e1]=(0,s.useState)(()=>{try{let e=window.localStorage.getItem(oO+f);if(e&&(0,Q.n6)(e))return e;let t=window.localStorage.getItem(oF+f);if(t&&(0,Q.hR)(t))return t}catch(e){}return(0,aZ.sA)()[0]}),e2=(0,s.useCallback)(e=>{e1(e);try{window.localStorage.setItem(oO+f,e)}catch(e){}let t=eB.current.find(t=>t.id===e);t&&eX(t.cliTool)},[f,eX]),e5=(0,s.useRef)(e0);e5.current=e0;let e3=(0,s.useRef)(0),e6=(0,s.useRef)(0),e9=(0,s.useRef)(0),e8=null!=(d=null==(t=ed.get(e0))?void 0:t.enabled)&&d,e7=null!=(u=null==(n=ed.get(e0))?void 0:n.expiresAt)?u:null,[te,tt]=(0,s.useState)(0),[tn,ta]=(0,s.useState)(!1),[tr,ts]=(0,s.useState)(""),{active:tl,setActive:ti,toggle:to}=function(e){let[t,n]=(0,s.useState)(lB),a=(0,s.useRef)(t);a.current=t;let r=(0,s.useRef)(e);return r.current=e,(0,s.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(lU(e));if(t===lV)return null;if(t&&"string"==typeof t&&l_.has(t))return t}catch(e){}return lB}(e);t!==a.current&&n(t)},[e]),{active:t,setActive:(0,s.useCallback)(e=>{n(e),oE(r.current,e)},[]),toggle:(0,s.useCallback)(e=>{if(a.current===e){n(null),oE(r.current,null);return}n(e),oE(r.current,e)},[])}}(f),{historySubTab:tc,setHistorySubTab:td,showArchived:tx,handleShowArchivedChange:th,historyUserOnly:tp,handleHistoryUserOnlyChange:tg,historyDisplayLimit:tb,handleHistoryDisplayLimitChange:tv}=function(){let[e,t]=(0,s.useState)("message"),[n,a]=(0,s.useState)(()=>"true"===localStorage.getItem(oP)),r=(0,s.useCallback)(e=>{a(e),localStorage.setItem(oP,String(e))},[]),[l,i]=(0,s.useState)(()=>{try{return"true"===localStorage.getItem(oL.gP)}catch(e){return!1}}),o=(0,s.useCallback)(e=>{i(e);try{localStorage.setItem(oL.gP,String(e))}catch(e){}},[]),[c,d]=(0,s.useState)(()=>{try{let e=localStorage.getItem(oL.wP);if(null===e)return oL.v8;let t=parseInt(e,10);return(0,oL.UK)(t)?t:oL.v8}catch(e){return oL.v8}});return{historySubTab:e,setHistorySubTab:t,showArchived:n,handleShowArchivedChange:r,historyUserOnly:l,handleHistoryUserOnlyChange:o,historyDisplayLimit:c,handleHistoryDisplayLimitChange:(0,s.useCallback)(e=>{d(e);try{localStorage.setItem(oL.wP,String(e))}catch(e){}},[])}}(),ty=(0,s.useRef)(tx);(0,s.useEffect)(()=>{ty.current=tx},[tx]);let tj=(0,s.useRef)(tb);(0,s.useEffect)(()=>{tj.current=tb},[tb]),(0,s.useEffect)(()=>{(0,aZ.qD)()},[]);let{pendingInsertTextMap:tw,pendingInsertText:tk,setFocusedSplitIndex:tN,handleInsertToMessage:tC,handleInsertToSplit:tS,handleInsertConsumed:tI,handleInsertConsumedSingle:tT}=function(){var e;let[t,n]=(0,s.useState)(()=>new Map),[a,r]=(0,s.useState)(0),l=(0,s.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(a,e),n})},[a]),i=(0,s.useCallback)((e,t)=>{n(n=>{let a=new Map(n);return a.set(e,t),a})},[]),o=(0,s.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,s.useCallback)(()=>o(0),[o]);return{pendingInsertTextMap:t,pendingInsertText:c,focusedSplitIndex:a,setFocusedSplitIndex:r,handleInsertToMessage:l,handleInsertToSplit:i,handleInsertConsumed:o,handleInsertConsumedSingle:d}}(),{diffContent:tE,diffFilePath:tA,handleDiffSelect:tM,handleCloseDiff:tR}=function(e){let[t,n]=(0,s.useState)(null),[a,r]=(0,s.useState)(null);return{diffContent:t,diffFilePath:a,handleDiffSelect:(0,s.useCallback)((t,a)=>{e||(n(t),r(a))},[e]),handleCloseDiff:(0,s.useCallback)(()=>{n(null),r(null)},[])}}(p),tL=function(e){let{worktreeId:t,initialMode:n="name",debounceMs:a=300}=e,[r,l]=(0,s.useState)(""),[i,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(n),[u,m]=(0,s.useState)(!1),[x,f]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useMemo)(()=>(0,h.sg)(e=>{o(e)},a),[a]),y=(0,s.useCallback)(e=>{l(e),v(e),g(null)},[v]),j=(0,s.useCallback)(()=>{l(""),o(""),f(null),g(null),m(!1),b.current&&(b.current.abort(),b.current=null)},[]),w=(0,s.useCallback)(e=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t))},[i]),k=(0,s.useCallback)(()=>x&&0!==x.results.length?(0,h.q3)(x.results.map(e=>e.filePath)):new Set,[x]);return(0,s.useEffect)(()=>{if("content"!==c||!i.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(i),"&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:i,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,i,t]),(0,s.useEffect)(()=>{"name"===c&&(f(null),m(!1),g(null))},[c]),{query:r,mode:c,isSearching:u,results:x,error:p,setQuery:y,setMode:d,clearSearch:j,filterByName:w,getMatchedPaths:k}}({worktreeId:f}),tP=(0,s.useRef)(!1),tD=(0,s.useRef)(f);(0,s.useEffect)(()=>{tD.current!==f&&(N.clearMessages(),tP.current=!1,eu(new Map),W.current=0,q.current=0,J(),B(!1),tD.current=f)},[f,N,J]);let tF=(0,s.useCallback)(async()=>{try{var e,t;let n=await (0,tm.E)("/api/worktrees/".concat(f),o_),a=(0,tm.O0)(n);if(a)throw a;if(!n.ok)throw new tm.hD("Failed to fetch worktree: ".concat(n.status),n.status);let r=(0,tm.xd)(n);if(r)throw r;let s=await n.json();if(P(s),s.selectedAgents){let e=eD.current;s.selectedAgents.length===e.length&&s.selectedAgents.every((t,n)=>t===e[n])||eP(s.selectedAgents)}if(s.agentInstances){let e=eB.current,t=s.agentInstances;t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.cliTool===e[n].cliTool&&t.alias===e[n].alias)||e_(t),eU(f)}return"vibeLocalModel"in s&&eW(null!=(e=s.vibeLocalModel)?e:null),"vibeLocalContextWindow"in s&&e$(null!=(t=s.vibeLocalContextWindow)?t:null),W.current=0,q.current=0,J(),B(!1),U(!1),z(null),s}catch(a){let e=a instanceof Error?a.message:"Unknown error",t=a instanceof tm.hD?a.status:0;if(W.current+=1,401===t)return U(!0),B(!1),z(null),null;if(null!==eO.current)return W.current>=3&&B(!0),console.error("[WorktreeDetailRefactored] Error fetching worktree:",a),null;z(e);let n=q.current;return n<oz.length&&(q.current=n+1,J(),$.current=setTimeout(()=>{$.current=null,G.current()},oz[n])),null}},[f,J]);G.current=tF;let tO=(0,s.useCallback)(async()=>{let e=eZ.current,t=g.current,n=e5.current,a=++e3.current;try{let r=new URLSearchParams({cliTool:e,unit:"pairs"});t&&r.set("instance",n),ty.current&&r.set("includeArchived","true"),r.set("limit",String(tj.current));let s=await (0,tm.E)("/api/worktrees/".concat(f,"/messages?").concat(r.toString()),o_);if(!s.ok)throw Error("Failed to fetch messages: ".concat(s.status));let l=await s.json();if(e3.current!==a||eZ.current!==e||t&&e5.current!==n)return;N.setMessages(l.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(r){if(e3.current!==a||eZ.current!==e||t&&e5.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching messages:",r)}},[f,N]),tz=(0,s.useCallback)(async()=>{let e=eZ.current,t=g.current,n=e5.current,a=++e6.current;try{var r,s,l,i,o,c,d,u;let m=t?"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e,"&instance=").concat(encodeURIComponent(n)):"/api/worktrees/".concat(f,"/current-output?cliTool=").concat(e),x=await (0,tm.E)(m,o_);if(!x.ok)return;let h=await x.json();if(e6.current!==a||eZ.current!==e||t&&e5.current!==n||h.cliToolId&&h.cliToolId!==e)return;if(h.isPromptWaiting&&h.promptData?N.showPrompt(h.promptData,"prompt-".concat(Date.now())):!h.isPromptWaiting&&k.prompt.visible&&N.clearPrompt(),eg(null!=(r=h.isSelectionListActive)&&r),ev(null!=(s=h.isPagerActive)&&s),ej((0,op.S$)(h.realtimeSnippet||h.fullOutput).offersPlanApprove),ek(null!=(l=h.isDismissablePanelActive)&&l),eC(null!=(i=h.isUnclassifiedActive)&&i),eI(null!=(o=h.sessionStatus)?o:""),eE(null!=(c=h.agentMode)?c:oI.J_),ex(null!=(d=h.lastServerResponseTimestamp)?d:null),eh(null!=(u=h.serverPollerActive)&&u),h.autoYes){let a=eA.current,r=h.autoYes,s=t?n:e;eu(e=>{let t=new Map(e);return t.set(s,{enabled:r.enabled,expiresAt:r.expiresAt}),t}),eA.current=r.enabled,a&&!h.autoYes.enabled&&("stop_pattern_matched"===h.autoYes.stopReason||"consecutive_errors"===h.autoYes.stopReason)&&eR(h.autoYes.stopReason)}}catch(r){if(e6.current!==a||eZ.current!==e||t&&e5.current!==n)return;console.error("[WorktreeDetailRefactored] Error fetching current output:",r)}},[f,N,k.prompt.visible]),t_=(0,s.useCallback)(async()=>{let e=++e9.current;try{let a=await (0,tm.E)("/api/worktrees/".concat(f,"/auto-yes"),o_);if(!a.ok)return;let r=await a.json();if(e9.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})}eu(l)}catch(t){if(e9.current!==e)return;console.error("[WorktreeDetailRefactored] Error fetching auto-yes states:",t)}},[f]),{visibleInstances:tB,visibleInstanceIds:tV,toggleInstanceVisible:tU,showInstances:tH}=function(e){let{worktreeId:t,roster:n}=e,[a,r]=(0,s.useState)(null);(0,s.useEffect)(()=>{r(function(e){try{let t=window.localStorage.getItem(a_(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 l=(0,s.useMemo)(()=>aB(a,n),[a,n]),i=(0,s.useMemo)(()=>l.map(e=>e.id),[l]),o=(0,s.useMemo)(()=>null!==a&&n.some(e=>a.includes(e.id)),[a,n]),c=(0,s.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(a_(t),JSON.stringify(s))}catch(e){}}},[n,t]),d=(0,s.useCallback)(e=>c(e),[c]);return{visibleInstances:l,visibleInstanceIds:i,hasStoredPreference:o,toggleInstanceVisible:(0,s.useCallback)(e=>{let t=aB(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,s.useCallback)(e=>{null!==a&&c([...aB(a,n).map(e=>e.id),...e])},[a,n,c])}}({worktreeId:f,roster:ez}),tK=p?tB:ez,tW=(0,s.useMemo)(()=>Array.from(new Set(tB.map(e=>e.cliTool))),[tB]),tq=p?tW:eL;(0,s.useEffect)(()=>{0!==tK.length&&(tK.some(e=>e.id===e0)||e2(tK[0].id))},[tK,e0,e2]),(0,s.useEffect)(()=>{let e=tK.find(e=>e.id===e0);e&&e.cliTool!==eY&&eX(e.cliTool)},[tK,e0,eY,eX]);let[t$,tG]=(0,s.useState)(null),tJ=(0,s.useRef)(0),tY=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;if(null===w){tY.current=null;return}if(!eH||tY.current===w)return;tY.current=w,ez.some(e=>e.id===w)&&(g.current?(tH([w]),e2(w)):(e2(w),tJ.current+=1,tG({instanceId:w,token:tJ.current})));let t=new URLSearchParams(null!=(e=null==j?void 0:j.toString())?e:"");t.delete(oD.Kp);let n=t.toString(),a=null!=y?y:"/worktrees/".concat(f);v.replace(n?"".concat(a,"?").concat(n):a,{scroll:!1})},[w,eH,ez,tH,e2,j,y,f,v]);let tQ=(0,s.useCallback)(e=>{tG(t=>null!==t&&t.token===e?null:t)},[]),tX="opencode"===eY||"copilot"===eY,tZ=(0,s.useCallback)(e=>{eP(e)},[]),t0=(0,s.useCallback)(e=>{e_(e),eU(f)},[f]),t1=(0,s.useCallback)(e=>{eW(e)},[]),t2=(0,s.useCallback)(e=>{e$(e)},[]),t4=(0,s.useRef)(eY);(0,s.useEffect)(()=>{t4.current!==eY&&(t4.current=eY,N.clearMessages(),N.clearPrompt(),eg(!1),ej(!1),tO(),tz())},[eY,N,tO,tz]),(0,s.useEffect)(()=>{tO()},[tx,tO]),(0,s.useEffect)(()=>{tO()},[tb,tO]);let{showToast:t5}=(0,tu.dj)(),t3=(0,s.useCallback)(()=>{t5("Maximum ".concat(30," file tabs. Close a tab first."),"info")},[t5]),t6=(0,s.useCallback)(e=>{p?es(e):"limit_reached"===ea.openFile(e)&&t3()},[p,ea,t3]),t9=(0,s.useCallback)(e=>{p?es(e):"limit_reached"===ea.openFile(e)&&t3()},[p,ea,t3]),t8=(0,s.useCallback)(e=>{"limit_reached"===ea.openFile(e)&&t3()},[ea,t3]),t7=(0,s.useCallback)(()=>{es(null)},[]),ne=(0,s.useCallback)(e=>{tt(e=>e+1)},[]),nt=(0,s.useCallback)(()=>{ei(null)},[]),nn=(0,s.useCallback)(()=>{tL.clearSearch(),ea.closeAllTabs(),es(null),ei(null)},[tL,ea]),na=(0,s.useCallback)(e=>{tt(e=>e+1)},[]),nr=(0,s.useCallback)(e=>{to(e)},[to]),ns=(0,s.useCallback)(e=>{ti(e)},[ti]),nl=(0,s.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();P(e)}}catch(e){}},[f]),ni=(0,s.useCallback)(()=>{ee(!0)},[]),no=(0,s.useCallback)(()=>{ee(!1)},[]),nc=(0,s.useCallback)(async e=>{N.setPromptAnswering(!0);try{let t=oh(e,eY,(0,I.XF)(k.prompt.data)?k.prompt.data:null,g.current?e5.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));let a=await n.json().catch(()=>null);if((null==a?void 0:a.success)===!1){t5(C("promptResponse.refused"),"warning"),await tz();return}N.clearPrompt(),await tz()}catch(e){console.error("[WorktreeDetailRefactored] Error sending prompt response:",e)}finally{N.setPromptAnswering(!1)}},[f,N,tz,eY,k.prompt.data,t5,C]),nd=(0,s.useCallback)(()=>{N.clearPrompt()},[N]),nu=(0,s.useCallback)(e=>{N.setMobileActivePane(e)},[N]),nm=(0,s.useCallback)(()=>{tO(),tz()},[tO,tz]),nx=(0,s.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();eu(t=>{let n=new Map(t);return n.set(a,{enabled:e.enabled,expiresAt:e.expiresAt}),n}),a===e5.current&&(eA.current=e.enabled)}}catch(e){console.error("[WorktreeDetailRefactored] Error toggling auto-yes:",e)}},[f]),nf=(0,s.useCallback)(e=>nx(eY,e0)(e),[nx,eY,e0]),[nh,np]=(0,s.useState)(null),[ng,nb]=(0,s.useState)(!1),nv=(0,s.useRef)(!1),ny=(0,s.useCallback)(e=>{np(e)},[]),nj=(0,s.useCallback)(()=>{let e=e5.current,t=eZ.current,n=(0,Q.O6)(eB.current,e,t);np({cliToolId:t,instanceId:e,label:n})},[]),nw=(0,s.useCallback)(async()=>{if(!nh||nv.current)return;nv.current=!0,nb(!0);let e=()=>{nh.instanceId===e5.current&&(N.clearMessages(),N.clearPrompt())};try{await tm.y.killSession(f,nh.cliToolId,nh.instanceId),e(),await tF(),np(null)}catch(t){t instanceof tm.hD&&404===t.status?(e(),await tF(),np(null)):t5(C("session.failedToKill"),"error")}finally{nv.current=!1,nb(!1)}},[nh,f,N,tF,t5,C]),nk=(0,s.useCallback)(()=>{nv.current||np(null)},[]),nN=(0,s.useCallback)(e=>{ts(e),ta(!0)},[]),nC=(0,s.useCallback)(async e=>{ta(!1);let t=tr?"".concat(tr,"/").concat(e):e;try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,e4.o)(t)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"file",content:""})})).ok)throw Error("Failed to create file");tt(e=>e+1)}catch(e){window.alert(S("fileOps.failedToCreateFile"))}},[f,tr,S]),nS=(0,s.useCallback)(()=>{ta(!1)},[]),nI=(0,s.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,e4.o)(n)),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"directory"})})).ok)throw Error("Failed to create directory");tt(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to create directory:",e),window.alert(S("fileOps.failedToCreateDirectory"))}},[f,S]),nT=(0,s.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,e4.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):"";ea.onFileRenamed(e,"".concat(t).concat(n)),tt(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to rename:",e),window.alert(S("fileOps.failedToRename"))}},[f,ea,S]),nE=(0,s.useCallback)(async e=>{let t=e.split("/").pop()||e;if(await A({description:T("confirmDelete",{name:t}),variant:"danger"}))try{if(!(await fetch("/api/worktrees/".concat(f,"/files/").concat((0,e4.o)(e),"?recursive=true"),{method:"DELETE"})).ok)throw Error("Failed to delete");(el===e||(null==el?void 0:el.startsWith("".concat(e,"/"))))&&ei(null),ea.onFileDeleted(e),tt(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to delete:",e),window.alert(S("fileOps.failedToDelete"))}},[f,el,ea,T,S,A]);(0,s.useEffect)(()=>{"stop_pattern_matched"===eM?(t5(E("stopPatternMatched"),"info"),eR(null)):"consecutive_errors"===eM&&(t5(E("consecutiveErrorsStopped"),"warning"),eR(null))},[eM,t5,E]);let{moveTarget:nA,isMoveDialogOpen:nM,handleMove:nR,handleMoveConfirm:nL,handleMoveCancel:nP}=function(e,t,n,a){let[r,l]=(0,s.useState)(null),[i,o]=(0,s.useState)(!1),c=(0,s.useCallback)((e,t)=>{l({path:e,type:t}),o(!0)},[]),d=(0,s.useCallback)(async s=>{if(r)try{let l=await fetch("/api/worktrees/".concat(e,"/files/").concat(r.path),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",destination:s})}),o=await l.json();if(!l.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{l(null),o(!1)}},[r,e,t,n,a]);return{moveTarget:r,isMoveDialogOpen:i,handleMove:c,handleMoveConfirm:d,handleMoveCancel:(0,s.useCallback)(()=>{l(null),o(!1)},[])}}(f,()=>tt(e=>e+1),e=>t5(e,"success"),e=>t5(e,"error")),nD=(0,s.useRef)(null),nO=(0,s.useRef)(""),nz=(0,s.useCallback)(e=>{var t;nO.current=e,null==(t=nD.current)||t.click()},[]),n_=(0,s.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=nO.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 eJ.includes(t)}(l))return void t5("Unsupported file type: ".concat(l,". Allowed: ").concat(eJ.join(", ")),"error");let i=function(e){var t;let n=function(e){let t=e.toLowerCase();return eG.find(e=>e.extension===t)}(e);return null!=(t=null==n?void 0:n.maxFileSize)?t:0x1400000}(l);if(r.size>i)return void t5("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,e4.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";t5(n,"error");return}let t=await e.json();t5("Uploaded: ".concat(t.filename),"success"),tt(e=>e+1)}catch(e){console.error("[WorktreeDetailRefactored] Failed to upload:",e),t5("Upload failed. Please try again.","error")}},[f,t5]),{hasUpdate:nB}=(0,tf.Y)(),{lastAutoResponse:nV}=function(e){let{worktreeId:t,cliTool:n,isPromptWaiting:a,promptData:r,autoYesEnabled:l,lastServerResponseTimestamp:i,serverPollerActive:o}=e,c=(0,s.useRef)(null),[d,u]=(0,s.useState)(null);return(0,s.useEffect)(()=>{var e;if(!a){c.current=null;return}if(!r||!l||!(0,I.XF)(r)||o||i&&Date.now()-i<3e3)return;let s=(e={type:r.type,question:r.question},"".concat(e.type,":").concat(e.question));if(c.current===s)return;let d=function(e,t){let n=function(e){if("yes_no"===e.type)return"y";if("multiple_choice"===e.type){if(!0===e.multiSelect)return null;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||!(0,re.P0)(e).valid)return{outcome:"unusable",pattern:e};let t=new RegExp(e);for(let a of n){let n=(0,re.eJ)(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=s,u(d);let m=oh(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,l,t,n,i,o]),{lastAutoResponse:d}}({worktreeId:f,cliTool:eY,isPromptWaiting:k.prompt.visible,promptData:k.prompt.data,autoYesEnabled:e8,lastServerResponseTimestamp:em,serverPollerActive:ef}),nU=(0,s.useCallback)(async()=>{z(null),B(!1),U(!1),W.current=0,q.current=0,J(),F(!0),await tF()&&await Promise.all([tO(),tz()]),F(!1)},[tF,tO,tz,J]),nH=(0,s.useCallback)(()=>{window.location.href="/login"},[]);(0,s.useEffect)(()=>J,[J]),function(e){let{error:t,handleRetry:n,fetchWorktree:a,fetchMessages:r,fetchCurrentOutput:l,setError:i}=e,o=(0,s.useRef)(0),c=(0,s.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(),l()])}finally{i(null)}}},[t,n,a,r,l,i]);(0,s.useEffect)(()=>(document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c)}),[c])}({error:O,handleRetry:nU,fetchWorktree:tF,fetchMessages:tO,fetchCurrentOutput:tz,setError:z}),(0,s.useEffect)(()=>{if(tP.current)return;let e=!0;return(async()=>{Y.current||F(!0),await Promise.all([tF(),tO(),tz()]),e&&(F(!1),tP.current=!0)})(),()=>{e=!1}},[tF,tO,tz]);let nK=null!=(m=null==L||null==(r=L.sessionStatusByCli)||null==(a=r[eY])?void 0:a.isRunning)&&m;(0,s.useEffect)(()=>{if(D)return;let e=setInterval(async()=>{let e=[tz(),tF()];p&&e.push(tO()),await Promise.all(e),K(e=>e+1)},nK?2e3:5e3);return()=>clearInterval(e)},[D,tz,tF,tO,nK,p]),(0,s.useEffect)(()=>{t_()},[f,eH,t_]),(0,s.useEffect)(()=>{N.setLayoutMode(p?"tabs":"split")},[p,N]);let nW=(0,s.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"})(L,null!==k.error.type,eY),[L,k.error.type,eY]),nq=(0,s.useMemo)(()=>k.layout.mobileActivePane,[k.layout.mobileActivePane]),n$=null!=(x=null==L?void 0:L.name)?x:"Unknown",nG=(0,s.useCallback)((e,t)=>{ea.dispatch({type:"SET_CONTENT",path:e,content:t})},[ea]),nJ=(0,s.useCallback)((e,t)=>{ea.dispatch({type:"SET_ERROR",path:e,error:t})},[ea]),nY=(0,s.useCallback)((e,t)=>{ea.dispatch({type:"SET_LOADING",path:e,loading:t})},[ea]),nQ=(0,s.useCallback)((e,t)=>{ea.dispatch({type:"SET_DIRTY",path:e,isDirty:t})},[ea]),nX=function(e){var t,n,a;let{worktreeId:r,refreshToken:l=0,enabled:i=!0,limit:o=10}=e,[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[h,p]=(0,s.useState)(null),[g,b]=(0,s.useState)(!0),[v,y]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[I,T]=(0,s.useState)(null),[E,A]=(0,s.useState)(null),[M,R]=(0,s.useState)(null),[L,P]=(0,s.useState)(!1),[D,F]=(0,s.useState)(null),[O,z]=(0,s.useState)(null),[_,B]=(0,s.useState)(!1),[V,U]=(0,s.useState)(null),[H,K]=(0,s.useState)(null),[W,q]=(0,s.useState)(null),[$,G]=(0,s.useState)(o),[J,Y]=(0,s.useState)(o),[Q,X]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)([]),[et,en]=(0,s.useState)(!1),[ea,er]=(0,s.useState)(null),[es,el]=(0,s.useState)(0),ei=(0,s.useRef)(0),eo=(0,s.useRef)(0),ec=(0,s.useRef)(!1),ed=(0,s.useRef)(!1),eu=(0,s.useRef)(!1),em=(0,s.useRef)(!1),ex=(0,s.useRef)(!1),ef=(0,s.useRef)(!1),eh=(0,s.useRef)(null);eh.current=W;let ep=(0,s.useRef)(o);ep.current=$,ed.current=(null==c?void 0:c.status)==="verifying"||u.some(e=>"running"===e.status),(0,s.useEffect)(()=>{if(ei.current+=1,eo.current=0,ec.current=!1,!ef.current){ef.current=!0;return}d(null),m([]),f(null),p(null),b(!0),y(null),w(null),T(null),A(null),R(null),F(null),z(null),U(null),q(null),G(o),Y(o),K(null)},[r]),(0,s.useEffect)(()=>{if(!i)return;let e=new AbortController,t=!1;return(async()=>{try{let n=await rJ(r,e.signal);if(t)return;A(n),R(null)}catch(e){if(t||oR(e))return;A(null),R(oM(e,"Failed to load the verification config"))}})(),()=>{t=!0,e.abort()}},[r,i,es]),(0,s.useEffect)(()=>{if(!i)return;let e=0===eo.current,t=15e3*!ed.current;if(!e&&Date.now()-eo.current<t||ec.current)return;let n=ei.current;ec.current=!0,eo.current=Date.now(),(async()=>{try{let[e,t]=await Promise.all([rW(r),rq(r,$)]);if(n!==ei.current)return;d(e),m(t),Y($),y(null)}catch(e){if(n!==ei.current||oR(e))return;y(oM(e,"Failed to load verification data"))}finally{ec.current=!1,n===ei.current&&(b(!1),ep.current!==$&&(eo.current=0,el(e=>e+1)))}})()},[r,l,es,i,$]);let eg=null!=(n=null!=x?x:null==(t=u[0])?void 0:t.id)?n:null,eb=(0,s.useMemo)(()=>{var e,t;if(null===eg)return null;let n=u.find(e=>e.id===eg);return(null==n?void 0:n.status)==="running"?"".concat(eg,":running:").concat(l,":").concat(es):"".concat(eg,":").concat(null!=(e=null==n?void 0:n.status)?e:"unlisted",":").concat(null!=(t=null==n?void 0:n.finishedAt)?t:"")},[eg,u,l,es]);(0,s.useEffect)(()=>{if(!i||null===eg){p(null),w(null),N(!1);return}let e=new AbortController,t=!1;return N(!0),(async()=>{try{let n=await r$(r,eg,e.signal);if(t)return;p(n),w(null===n?"not-found":null)}catch(e){if(t||oR(e))return;p(null),w(oM(e,"Failed to load the verification run"))}finally{t||N(!1)}})(),()=>{t=!0,e.abort()}},[r,i,eb]),(0,s.useEffect)(()=>{if(!i||!Q)return;let e=new AbortController,t=!1;return en(!0),(async()=>{try{let n=await rX({days:7,limit:20},e.signal);if(t)return;ee(n),er(null)}catch(e){if(t||oR(e))return;er(oM(e,"Failed to load the verification history"))}finally{t||en(!1)}})(),()=>{t=!0,e.abort()}},[i,Q,es]);let ev=(0,s.useMemo)(()=>{var e;return null!=(e=null==E?void 0:E.plannedGateIds)?e:[]},[E]),ey=(0,s.useMemo)(()=>{var e;return(null!=(e=null==h?void 0:h.gates)?e:[]).filter(e=>r_.includes(e.status)).map(e=>e.gateId)},[h]),ej=(0,s.useMemo)(()=>{var e;return null!=(e=u.find(e=>"running"===e.status))?e:null},[u]),ew=(0,s.useCallback)(e=>{q(null===e||oA(e,ev)?null:e)},[ev]),ek=(0,s.useCallback)(e=>{q(t=>{let n=new Set(null!=t?t:ev);n.has(e)?n.delete(e):n.add(e);let a=ev.filter(e=>n.has(e));return oA(a,ev)?null:a})},[ev]),eN=(0,s.useCallback)(()=>{let e=ev.filter(e=>ey.includes(e));q(0===e.length||oA(e,ev)?null:e)},[ev,ey]),eC=(0,s.useCallback)(()=>{eo.current=0,G(e=>Math.min(e+10,100))},[]),eS=(0,s.useCallback)(()=>{X(e=>!e)},[]),eI=(0,s.useCallback)(()=>{eo.current=0,el(e=>e+1)},[]),eT=(0,s.useCallback)(e=>{f(e)},[]),eE=(0,s.useCallback)(async e=>{if(!eu.current){eu.current=!0,S(!0),T(null),U(null);try{let t=void 0===e?eh.current:e,n=await rG(r,null!==t&&t.length>0?{gateIds:t}:{});f(n),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof rU&&409===t.status;T({kind:e?"conflict":"error",message:oM(t,"Failed to start verification"),runningRunId:t instanceof rU?t.runningRunId:null}),e&&(eo.current=0,el(e=>e+1))}finally{eu.current=!1,S(!1)}}},[r]),eA=(0,s.useCallback)(async()=>{if(!ex.current&&null!==ej){ex.current=!0,B(!0),U(null);try{let e=await rQ(r,ej.id);K("running"===e.status?ej.id:null)}catch(e){U({kind:409===(e instanceof rU?e.status:0)?"gone":"error",message:oM(e,"Failed to cancel the verification run")})}finally{ex.current=!1,B(!1),eo.current=0,el(e=>e+1)}}},[r,ej]),eM=(0,s.useCallback)(async()=>{if(!em.current){em.current=!0,P(!0),F(null);try{let e=await rY(r);z(e),eo.current=0,el(e=>e+1)}catch(t){let e=t instanceof rU?t.status:0;F({kind:409===e?"conflict":422===e?"empty":"error",message:oM(t,"Failed to draft the verification config")}),409===e&&(eo.current=0,el(e=>e+1))}finally{em.current=!1,P(!1)}}},[r]);return{worktreeId:r,task:c,runs:u,latestRun:null!=(a=u[0])?a:null,selectedRunId:eg,selectedRun:h,loading:g,error:v,detailError:j,detailLoading:k,rerunPending:C,rerunFailure:I,config:E,configError:M,phase:u.some(e=>"running"===e.status)?"running":null===E?"unknown":E.exists?0===u.length?"configured":"result":"no-config",draftPending:L,draftFailure:D,draftResult:O,availableGateIds:ev,selectedGateIds:W,failedGateIds:ey,toggleGate:ek,setGateSelection:ew,selectFailedGates:eN,runningRun:ej,cancelPending:_,cancelSettling:null!==H&&(null==ej?void 0:ej.id)===H,cancelFailure:V,historyLimit:$,canLoadMore:u.length>=J&&J<100,repositoryHistoryOpen:Q,repositoryHistory:Z,repositoryHistoryLoading:et,repositoryHistoryError:ea,selectRun:eT,refresh:eI,rerun:eE,cancelRun:eA,loadMore:eC,toggleRepositoryHistory:eS,draftConfig:eM}}({worktreeId:f,refreshToken:H,enabled:!D&&!O});return{activeActivity:tl,activeCliTab:eY,activeInstanceId:e0,activeTab:nq,agentInstances:ez,autoYesEnabled:e8,autoYesExpiresAt:e7,autoYesStateMap:ed,diffContent:tE,diffFilePath:tA,disableAutoFollow:tX,displayedAgents:tq,displayedInstances:tK,editorFilePath:el,error:O,fetchCurrentOutput:tz,fileInputRef:nD,fileSearch:tL,fileTreeRefresh:te,handleActivityOpen:ns,handleActivityToggle:nr,handleAgentInstancesChange:t0,handleAutoYesToggle:nf,handleCloseDiff:tR,handleDelete:nE,handleDiffSelect:tM,handleDirtyChange:nQ,handleEditorClose:nt,handleEditorSave:na,handleFileInputChange:n_,handleFilePanelSave:ne,handleFilePathClick:t6,handleFileSelect:t9,handleHistoryDisplayLimitChange:tv,handleHistoryUserOnlyChange:tg,handleInfoClick:ni,handleInfoModalClose:no,handleInsertConsumed:tI,handleInsertConsumedSingle:tT,handleInsertToMessage:tC,handleInsertToSplit:tS,handleKillCancel:nk,handleKillConfirm:nw,openKillConfirm:ny,openActiveKillConfirm:nj,killTarget:nh,isKillPending:ng,handleLoadContent:nG,handleLoadError:nJ,handleMessageSent:nm,handleMobileFileViewerClose:t7,handleMobileTabChange:nu,handleMove:nR,resetFileTreeView:nn,handleMoveCancel:nP,handleMoveConfirm:nL,handleNewDirectory:nI,handleNewFile:nN,handleNewFileCancel:nS,handleNewFileConfirm:nC,handleOpenFile:t8,handlePromptDismiss:nd,handlePromptRespond:nc,handleRename:nT,handleReLogin:nH,handleRetry:nU,handleSelectedAgentsChange:tZ,handleSetLoading:nY,handleShowArchivedChange:th,handleUpload:nz,handleVibeLocalContextWindowChange:t2,rosterReady:eH,instanceSelectionRequest:t$,acknowledgeInstanceSelection:tQ,handleVibeLocalModelChange:t1,handleWorktreeStatusChange:nl,hasUpdate:nB,historyDisplayLimit:tb,historySubTab:tc,historyUserOnly:tp,isAuthExpired:V,isEditorMaximized:eo,isInfoModalOpen:Z,isMobile:p,isMoveDialogOpen:nM,isReconnecting:_,isSelectionListActive:ep,isPagerActive:eb,offersPlanApprove:ey,isDismissablePanelActive:ew,isUnclassifiedActive:eN,sessionStatus:eS,agentMode:eT,lastAutoResponse:nV,loading:D,makeAutoYesToggleHandler:nx,mobileFileViewerPath:er,mobileSelectedAgents:tW,moveTarget:nA,newFileParentPath:tr,openMobileDrawer:b,pendingInsertText:tk,pendingInsertTextMap:tw,selectedAgents:eL,setActiveCliTab:eX,setActiveInstanceId:e2,setEditorFilePath:ei,setFocusedSplitIndex:tN,setHistorySubTab:td,setIsEditorMaximized:ec,setWorktree:P,showArchived:tx,showNewFileDialog:tn,showToast:t5,state:k,tCommon:T,tWorktree:C,tabsActions:ea,tabsState:en,toggleInstanceVisible:tU,vibeLocalContextWindow:eq,verification:nX,vibeLocalModel:eK,visibleInstanceIds:tV,worktree:L,worktreeName:n$,worktreeStatus:nW}}({worktreeId:k}),tJ=(0,o.c)("auth"),[tQ,tZ]=(0,s.useState)(!1),[t1,t2]=(0,s.useState)(null),[t4,t5]=(0,s.useState)(X.wf),t3="terminal"===A&&"chat"===t4,t6=(0,s.useCallback)(e=>{"memo"!==e&&t2(null),eE(e)},[eE]),t9=(0,s.useCallback)(()=>{t2(e=>{var t;return{tab:"verification",token:(null!=(t=null==e?void 0:e.token)?t:0)+1}}),eE("memo")},[eE]),t8=function(e){let{worktreeId:t,active:n}=e,{addListener:a}=(0,t0.xM)(),[r,l]=(0,s.useState)(!1),i=(0,s.useRef)(n);return i.current=n,(0,s.useEffect)(()=>{n&&l(!1)},[n]),(0,s.useEffect)(()=>a(e=>{e.worktreeId===t&&("terminal_snapshot"===e.type||"message"===e.type)&&(i.current||l(!0))}),[a,t]),!n&&r}({worktreeId:k,active:"terminal"===A}),{viewportHeight:t7}=(0,oS.C)(),ne=(0,s.useCallback)(e=>{let t=oW.indexOf(A);if(-1===t)return;let n=t+e;n<0||n>=oW.length||t6(oW[n])},[A,t6]),{ref:nt}=(0,R.hU)({axis:"horizontal",threshold:60,edgeStartZone:32*("terminal"===A),onSwipeLeft:()=>ne(1),onSwipeRight:()=>ne(-1)}),nn=(0,s.useMemo)(()=>({worktreePath:null==tq?void 0:tq.path,openFile:eo}),[null==tq?void 0:tq.path,eo]),na=null!=(g=null==(t=null!=(p=null==tq||null==(n=tq.sessionStatusByInstance)?void 0:n[E])?p:null==tq||null==(a=tq.sessionStatusByCli)?void 0:a[C])?void 0:t.isRunning)&&g,[nr,ns]=(0,s.useState)(!1),nl="terminal"!==A?"tab":"chat"===t4?"chat":na?null:"session",ni=nr&&null===nl;(0,s.useEffect)(()=>{ns(!1)},[k,C,E]),(0,s.useEffect)(()=>{na||ns(!1)},[na]),(0,s.useEffect)(()=>{("terminal"!==A||"chat"===t4)&&ns(!1)},[A,t4]);let no=(0,s.useCallback)(()=>ns(!0),[]),nc=(0,s.useCallback)(()=>ns(!1),[]);if(td)return(0,r.jsx)(lN,{});if(e3)return(0,r.jsx)(oH,{message:tO("editor.sessionExpired"),loginLabel:tJ("login.submitButton"),onLogin:eK});if(U)return(0,r.jsx)(lC,{message:U,onRetry:eW});let nd=(0,Q.O6)(M,E,C),nu=null!=(v=null==ek?void 0:ek.label)?v:nd,nm=null!=(j=null==(i=null!=(y=null==tq||null==(d=tq.sessionStatusByInstance)?void 0:d[E])?y:null==tq||null==(u=tq.sessionStatusByCli)?void 0:u[C])?void 0:i.isProcessing)&&j;return e8?(0,r.jsx)(T.t,{componentName:"WorktreeDetailRefactored",children:(0,r.jsx)(tY,{onInsertToComposer:eg,children:(0,r.jsxs)(tX.k,{value:nn,children:[te&&(0,r.jsx)(oU,{label:tF("connection.reconnecting")}),(0,r.jsxs)("div",{className:"flex flex-col overflow-hidden",style:{height:null!=t7?"".concat(t7,"px"):"100%"},"data-testid":"mobile-worktree-shell",children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(b,{worktreeName:t$,repositoryName:null==tq?void 0:tq.repositoryName,status:tG,statusUnclassified:lx(tG,null==tq?void 0:tq.sessionStatusByCli,C),gitStatus:null==tq?void 0:tq.gitStatus,onMenuClick:tv})}),tU.task&&!ni&&(0,r.jsx)("div",{className:"flex-shrink-0 border-b border-border bg-surface px-3 py-1.5",children:(0,r.jsx)(ob,{task:tU.task,latestRun:tU.latestRun,latestRunGates:null!==tU.selectedRun&&tU.selectedRun.id===(null==(f=tU.latestRun)?void 0:f.id)?tU.selectedRun.gates:null,onOpen:t9,className:"w-full justify-start"})}),(null==tq?void 0:tq.gitStatus)&&tq.gitStatus.isBranchMismatch&&!ni&&(0,r.jsx)("div",{className:"z-35 flex-shrink-0",children:(0,r.jsx)(ov,{isBranchMismatch:tq.gitStatus.isBranchMismatch,currentBranch:tq.gitStatus.currentBranch,initialBranch:tq.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":tO("detail.agentInstanceSelection"),children:B.map(e=>{var t,n,a;let s=null!=(a=null==tq||null==(t=tq.sessionStatusByInstance)?void 0:t[e.id])?a:null==tq||null==(n=tq.sessionStatusByCli)?void 0:n[e.cliTool],l=(0,tC.kA)(s),i=(0,x.Mq)(l,(0,tC.px)(s)),o=tF(i?x.rH:"status.".concat(l)),c=E===e.id;return(0,r.jsxs)("button",{onClick:()=>tI(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(c?"text-accent-600 dark:text-accent-400 border-accent-500":"text-muted-foreground hover:text-foreground border-transparent"),"aria-current":c?"page":void 0,children:[(0,r.jsx)(m.m,{status:l,size:"sm",label:tO("detail.statusPill",{label:(0,Q.sw)(e),status:o}),className:i?x.Jd:void 0,"data-unclassified":i?"true":void 0}),(0,Q.sw)(e)]},e.id)})}),(0,r.jsx)("button",{type:"button",onClick:()=>tZ(!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":tO("terminal.moreActions"),"data-testid":"mobile-more-actions-button",children:(0,r.jsx)(c.A,{size:18,"aria-hidden":"true"})})]}),(0,r.jsx)("main",{className:"flex-1 min-h-0 overflow-y-auto",ref:nt,children:(0,r.jsx)(ld,{activeTab:A,worktreeId:k,worktree:tq,messages:tD.messages,cliToolId:C,instanceId:E,onFilePathClick:eo,onFileSelect:ec,onWorktreeUpdate:tM,onNewFile:eO,onNewDirectory:eD,onRename:eH,onDelete:ee,onUpload:eY,onMove:eA,onFileTreeReset:tB,refreshTrigger:q,fileSearch:W,showToast:tP,selectedAgents:tp,onSelectedAgentsChange:oK,useInstanceManagement:!0,instances:M,onInstancesChange:J,visibleInstanceIds:tW,onToggleInstanceVisible:tV,vibeLocalModel:tK,onVibeLocalModelChange:eX,vibeLocalContextWindow:tH,onVibeLocalContextWindowChange:eQ,disableAutoFollow:_,historySubTab:e2,onHistorySubTabChange:tE,onDiffSelect:en,onInsertToMessage:eg,showArchived:tR,onShowArchivedChange:e$,historyDisplayLimit:e1,onHistoryDisplayLimitChange:eu,historyUserOnly:e5,onHistoryUserOnlyChange:em,verification:tU,toolsSubTabRequest:t1,onSurfaceModeChange:t5,directInputOpen:ni})}),(0,r.jsxs)("div",{className:"flex-shrink-0 border-t border-border bg-surface z-30",children:[ni?(0,r.jsx)(eR,{worktreeId:k,cliToolId:C,instanceId:E,onKeysSent:H,onClose:nc},"".concat(k,":").concat(C,":").concat(E)):null,tt&&!t3&&!ni&&(0,r.jsx)("div",{className:"px-2 pt-1 border-b border-border",children:(0,r.jsx)(eP.y,{worktreeId:k,cliToolId:C,instanceId:E,onKeysSent:H,showPagerKeys:tn,hideEnterKey:ta})}),(0,r.jsx)("div",{className:ni?"p-2 hidden":"p-2","aria-hidden":!!ni||void 0,"data-testid":"mobile-composer-wrapper",children:(0,r.jsx)(oq,{worktreeId:k,onMessageSent:eI,cliToolId:C,instanceId:E,isSessionRunning:na,isProcessing:nm,showToast:tP,pendingInsertText:ty,onInsertConsumed:ep,agentModeSlot:(0,r.jsx)(i0,{worktreeId:k,cliToolId:C,instanceId:E,agentMode:to,sessionStatus:tl,isPromptWaiting:tD.prompt.visible,isSelectionListActive:tt,isDismissablePanelActive:tr,isUnclassifiedActive:ts,onKeysSent:H}),autoYesSlot:(0,r.jsx)(om.T,{enabled:L,expiresAt:P,onToggle:Y,lastAutoResponse:tc,cliToolName:C,inline:!0,showToolName:!1})})})]}),(0,r.jsx)(S,{activeTab:A,onTabChange:t6,hasNewOutput:t8,hasPrompt:tD.prompt.visible,hasUpdate:e0,inFlow:!0}),!ni&&(!L||(null==(w=tD.prompt.data)?void 0:w.type)==="multiple_choice"&&!0===w.multiSelect)&&(0,r.jsx)(z,{promptData:tD.prompt.data,visible:tD.prompt.visible,answering:tD.prompt.answering,onRespond:eU,onDismiss:eV,cliToolName:(0,Q.oo)(C)}),(0,r.jsx)(ed,{open:tQ,onClose:()=>tZ(!1),searchTarget:t3?"chat":"terminal",onSearch:()=>window.dispatchEvent(new CustomEvent(t3?"chat-search-open":"terminal-search-open")),onEnd:ew,endDisabled:!na,onDirectInput:no,directInputUnavailableReason:nl}),(0,r.jsx)(ti,{isOpen:null!==th,onClose:eT,worktreeId:k,filePath:null!=th?th:"",onFileSaved:es,onOpenFile:eo}),(0,r.jsx)("input",{ref:K,type:"file",accept:eJ.join(","),onChange:el,className:"hidden","aria-label":tO("detail.uploadFile")}),(0,r.jsx)(tN.a,{isOpen:null!==ek,onClose:ev,title:tO("session.confirmEnd",{tool:nu}),size:"sm",showCloseButton:!0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-foreground",children:tO("session.endWarning")}),(0,r.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,r.jsx)("button",{type:"button",onClick:ev,className:"px-4 py-2 text-sm font-medium rounded-md bg-muted hover:bg-muted/80 text-foreground",children:tF("cancel")}),(0,r.jsx)("button",{type:"button",onClick:ey,disabled:eN,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:tF("end")})]})]})}),tg&&(0,r.jsx)(ow,{isOpen:e7,onClose:eM,onConfirm:eL,worktreeId:k,sourcePath:tg.path,sourceType:tg.type}),(0,r.jsx)(oN,{isOpen:tL,parentPath:tb,onConfirm:e_,onCancel:ez})]})]})})}):(0,r.jsxs)(tX.k,{value:nn,children:[te&&(0,r.jsx)(oU,{label:tF("connection.reconnecting")}),(0,r.jsx)(oC,{worktreeId:k,worktree:tq,worktreeName:t$,worktreeStatus:tG,instances:M,rosterReady:tw,activeInstanceId:E,setActiveInstanceId:tI,instanceSelectionRequest:tk,onInstanceSelectionHandled:tS,hasUpdate:e0,lastAutoResponse:tc,activeActivity:N,onActivityToggle:G,onActivityOpen:$,verification:tU,onInfoClick:ex,onWorktreeStatusChange:eZ,pendingInsertTextMap:tj,setFocusedSplitIndex:tT,handleInsertToSplit:eb,handleInsertConsumed:eh,handleInsertToMessage:eg,autoYesStateMap:D,makeAutoYesToggleHandler:tx,showArchived:tR,onShowArchivedChange:e$,historyDisplayLimit:e1,onHistoryDisplayLimitChange:eu,historyUserOnly:e5,onHistoryUserOnlyChange:em,onMessageSent:eI,onFilePathClick:eo,showToast:tP,tabsState:t_,tabsActions:tz,onLoadContent:eC,onLoadError:eS,onSetLoading:eq,onFilePanelSave:ei,onDirtyChange:ea,onOpenFile:eB,diffContent:F,diffFilePath:O,onCloseDiff:Z,fileSearch:W,fileTreeRefresh:q,onFileSelect:ec,onNewFile:eO,onNewDirectory:eD,onRename:eH,onDelete:ee,onUpload:eY,onMove:eA,onFileTreeReset:tB,onDiffSelect:en,onAgentInstancesChange:J,vibeLocalModel:tK,onVibeLocalModelChange:eX,vibeLocalContextWindow:tH,onVibeLocalContextWindowChange:eQ,isInfoModalOpen:e9,onInfoModalClose:ef,onWorktreeUpdate:tM,fileInputRef:K,onFileInputChange:el,onKillSession:ew,onRequestSessionEnd:ej,killTarget:ek,isKillPending:eN,onKillCancel:ev,onKillConfirm:ey,moveTarget:tg,isMoveDialogOpen:e7,onMoveCancel:eM,onMoveConfirm:eL,showNewFileDialog:tL,newFileParentPath:tb,onNewFileConfirm:e_,onNewFileCancel:ez,killDialogTitle:tO("session.confirmEnd",{tool:nu}),killDialogWarning:tO("session.endWarning"),cancelLabel:tF("cancel"),endLabel:tF("end")}),V&&(0,r.jsx)(tN.a,{isOpen:!0,onClose:er,title:V.split("/").pop()||tO("fileViewer.editor"),size:"full",disableClose:e6,children:(0,r.jsx)("div",{className:"h-[80vh]",children:(0,r.jsx)(oV,{worktreeId:k,filePath:V,onClose:er,onSave:es,onMaximizedChange:tA})})})]})});var oG=n(43424);function oJ(){let e=(0,l.useParams)().id;return(0,s.useEffect)(()=>{(0,oG.hO)(e)},[e]),(0,r.jsx)(o$,{worktreeId:e})}},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")})]})}}},e=>{e.O(0,[6481,6809,4909,2770,2619,8566,6322,8283,3778,6192,1642,8407,2407,344,5449,6966,8606,4768,2751,8165,2039,7705,9619,2053,8441,1255,7358],()=>e(e.s=20252)),_N_E=e.O()}]);
|