@jingyi0605/codingns 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/{AdaptiveButlerPage-CUyNL98E.js → AdaptiveButlerPage-uFwDdN-F.js} +3 -3
- package/dist/public/assets/{App-BFP7LCSC.js → App-BZvapsi8.js} +3 -3
- package/dist/public/assets/App-CcDXqFl1.css +1 -0
- package/dist/public/assets/{BootstrapPage-G74dX2Us.js → BootstrapPage-gHSoa4JN.js} +1 -1
- package/dist/public/assets/ConversationPage-z3sXtKZ7.js +4 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-IV7oEdOX.js → DesktopDetachPreviewPage-4eMRxiBW.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +2 -0
- package/dist/public/assets/FileContextPanel-C3qex8bb.js +1 -0
- package/dist/public/assets/GitSidebar-BK6H16XU.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-DqVwz_Hp.js → MobileCreateSessionSheet-BYfbvK8o.js} +1 -1
- package/dist/public/assets/MobileSheet-Ckug8hTb.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-COTc7cRr.js → MobileTopHeaderFrame-Bwv8Ovm_.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +1 -0
- package/dist/public/assets/RelayConnectEntryPage-D_4YL-YH.js +1 -0
- package/dist/public/assets/ServerSettingsModal-CMSm3BZU.js +1 -0
- package/dist/public/assets/SessionIndexPage-DuK10DL5.js +1 -0
- package/dist/public/assets/SettingsPage-fyD-xaHL.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +1 -0
- package/dist/public/assets/{TerminalPage-DpsvQQVR.js → TerminalPage-DaooFaJ4.js} +19 -19
- package/dist/public/assets/{TerminalRuntimeFallbackModal-CNzOt5v5.js → TerminalRuntimeFallbackModal-aUzjEBwP.js} +1 -1
- package/dist/public/assets/ToolFilesPage-CGxBvYG0.js +1 -0
- package/dist/public/assets/ToolGitPage-C264yjS9.js +1 -0
- package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +1 -0
- package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +1 -0
- package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +3 -0
- package/dist/public/assets/{WorkbenchModal-CbDxaCOR.js → WorkbenchModal-0tPIIhca.js} +1 -1
- package/dist/public/assets/{WorkbenchShellRoute-BMcnFadA.css → WorkbenchShellRoute-BF0nHWOk.css} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +1 -0
- package/dist/public/assets/client-runtime-manager-BZpL17fc.js +1 -0
- package/dist/public/assets/{default-session-permission-mode-Cu5SreTG.js → default-session-permission-mode-DT4SGiwp.js} +1 -1
- package/dist/public/assets/{file-tree-icon-BMKuc5pw.js → file-tree-icon-Db5LXC8h.js} +7 -7
- package/dist/public/assets/index-BZLcEHW3.js +42 -0
- package/dist/public/assets/index-BbspQPC2.css +1 -0
- package/dist/public/assets/login-direct-candidate-resolver-1mxe_Oh8.js +1 -0
- package/dist/public/assets/{preferences-service-gv_9vGKz.js → preferences-service-DWnzl5a0.js} +1 -1
- package/dist/public/assets/relay-entry-C5_Iay0I.js +1 -0
- package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +17 -0
- package/dist/public/assets/{styles-BWPBZvze.css → styles-CsEMfdaS.css} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-B9xJGY__.js → terminal-runtime-meta-cdtWVfCm.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-CDfl54Wt.js → useRegisteredDebugTemplates-oFAQNIqh.js} +1 -1
- package/dist/public/assets/window-BVUB8gMK.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +3 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/client/npm-global-package-service.d.ts +7 -1
- package/dist/server/modules/client/npm-global-package-service.js +149 -43
- package/dist/server/modules/client/npm-global-package-service.js.map +1 -1
- package/dist/server/modules/client/service-update-task-service.js +6 -2
- package/dist/server/modules/client/service-update-task-service.js.map +1 -1
- package/dist/server/modules/client/service-update-types.d.ts +2 -0
- package/dist/server/modules/git/git-controller.d.ts +3 -0
- package/dist/server/modules/git/git-controller.js +3 -0
- package/dist/server/modules/git/git-controller.js.map +1 -1
- package/dist/server/modules/git/git-read-service.js +47 -1
- package/dist/server/modules/git/git-read-service.js.map +1 -1
- package/dist/server/modules/git/git-write-service.d.ts +4 -0
- package/dist/server/modules/git/git-write-service.js +24 -0
- package/dist/server/modules/git/git-write-service.js.map +1 -1
- package/dist/server/modules/git/types.d.ts +1 -0
- package/dist/server/modules/git/workspace-repo-guard.d.ts +2 -0
- package/dist/server/modules/git/workspace-repo-guard.js +24 -10
- package/dist/server/modules/git/workspace-repo-guard.js.map +1 -1
- package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +53 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js +70 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +83 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +591 -0
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.d.ts +56 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js +483 -0
- package/dist/server/modules/parallel-sessions/session-isolated-workspace-service.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.d.ts +2 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js +129 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-candidate-endpoints.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +12 -9
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +1 -128
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +3 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +56 -45
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-process.js +21 -2
- package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +10 -1
- package/dist/server/modules/sessions/session-history-service.js +142 -14
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +8 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +208 -25
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/workbench/codex-archive-watcher.d.ts +16 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js +50 -0
- package/dist/server/modules/workbench/codex-archive-watcher.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +11 -2
- package/dist/server/modules/workbench/workbench-service.js +37 -8
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +26 -3
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.d.ts +3 -1
- package/dist/server/modules/workspace/workspace-service.js +10 -2
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-base-ref-resolver.d.ts +20 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js +111 -0
- package/dist/server/modules/worktree/worktree-base-ref-resolver.js.map +1 -0
- package/dist/server/modules/worktree/worktree-cleanup-service.js +9 -3
- package/dist/server/modules/worktree/worktree-cleanup-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-manager.d.ts +0 -1
- package/dist/server/modules/worktree/worktree-manager.js +14 -20
- package/dist/server/modules/worktree/worktree-manager.js.map +1 -1
- package/dist/server/routes/git.js +1 -0
- package/dist/server/routes/git.js.map +1 -1
- package/dist/server/routes/parallel-groups.d.ts +3 -0
- package/dist/server/routes/parallel-groups.js +9 -0
- package/dist/server/routes/parallel-groups.js.map +1 -0
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +38 -4
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/server/workbench-runtime-terminal-sync.d.ts +14 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js +17 -0
- package/dist/server/server/workbench-runtime-terminal-sync.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.d.ts +11 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js +131 -0
- package/dist/server/storage/repositories/parallel-session-group-repository.js.map +1 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.d.ts +12 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js +150 -0
- package/dist/server/storage/repositories/parallel-session-member-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.d.ts +15 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js +230 -0
- package/dist/server/storage/repositories/session-isolated-workspace-repository.js.map +1 -0
- package/dist/server/storage/sqlite/schema.sql +73 -0
- package/dist/server/types/domain.d.ts +72 -0
- package/dist/server/ws/workbench-ws-hub.d.ts +3 -1
- package/dist/server/ws/workbench-ws-hub.js +23 -4
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +34 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +3 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +46 -22
- package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +488 -281
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +29 -5
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/App-DUAg5urj.css +0 -1
- package/dist/public/assets/ConversationPage-Bz0_tvvM.js +0 -2
- package/dist/public/assets/DesktopWindowPage-BBmHyRg5.js +0 -2
- package/dist/public/assets/FileContextPanel--FVTxDrq.js +0 -1
- package/dist/public/assets/GitSidebar-DAiSi9oc.js +0 -6
- package/dist/public/assets/MobileSheet-D1lMrcvD.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-DJPV9ym2.js +0 -1
- package/dist/public/assets/RelayConnectEntryPage-dSwU8VzK.js +0 -1
- package/dist/public/assets/ServerSettingsModal-B34ms3ze.js +0 -1
- package/dist/public/assets/SessionIndexPage-D3tG1gmM.js +0 -1
- package/dist/public/assets/SettingsPage-B3-6-5GL.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-DhuTEdzV.js +0 -1
- package/dist/public/assets/ToolFilesPage-BX9QDi9Y.js +0 -1
- package/dist/public/assets/ToolGitPage-4VtFox3p.js +0 -1
- package/dist/public/assets/ToolProcessesPage-DZJC6Qnt.js +0 -1
- package/dist/public/assets/ToolsHomePage-D7JbrAWv.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-C0yqnzqh.js +0 -1
- package/dist/public/assets/WorkbenchLayout-Brlj8K3i.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-puGpdDFY.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-fTGweC9N.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-BtaIzSDB.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-CUmmYDrM.js +0 -1
- package/dist/public/assets/client-runtime-manager-RHFa_iWo.js +0 -1
- package/dist/public/assets/index-Cq3ue0za.css +0 -1
- package/dist/public/assets/index-DEbFT-Aq.js +0 -42
- package/dist/public/assets/session-runtime-machine-Bfnxkk9B.js +0 -17
- package/dist/public/assets/window-BWqRixxq.js +0 -1
- /package/dist/public/assets/{styles-CSUx5LGe.js → styles-DRVvx_kv.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-C3qex8bb.js","assets/index-BZLcEHW3.js","assets/index-BbspQPC2.css","assets/App-BZvapsi8.js","assets/App-CcDXqFl1.css","assets/MobileSheet-Ckug8hTb.js","assets/WorkbenchModal-0tPIIhca.js","assets/file-tree-icon-Db5LXC8h.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-C5_Iay0I.js","assets/GitSidebar-BK6H16XU.js","assets/default-session-permission-mode-DT4SGiwp.js","assets/TerminalManagerPanel-CCLr1Ypk.js","assets/terminal-runtime-meta-cdtWVfCm.js","assets/TerminalRuntimeFallbackModal-aUzjEBwP.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Ec=Object.defineProperty;var Ac=(e,t,s)=>t in e?Ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Ne=(e,t,s)=>Ac(e,typeof t!="symbol"?t+"":t,s);import{C as ne,t as r,b as o,j as n,e as _t,m as pr,H as rl,J as Wc,E as Lc,K as Bc,w as al,A as il,p as ba,L as Dc,M as _c,N as ol,i as ll,O as qa,f as ri,h as Ka,P as Fc,l as cl,y as Oc,n as Hc,z as $c,_ as ai}from"./index-BZLcEHW3.js";import{m as Ee,e as Ln,h as ga,u as br,g as gr,f as as,i as Uc,j as Gc,O as Mi}from"./App-BZvapsi8.js";import{e as ii,l as zc,m as qc,a1 as dl,a2 as Kc,M as Vc,i as Xc,j as Yc,a3 as Jc,a4 as Zc,p as Qc,q as Pi,f as Ei,h as sr,a as Va,x as ed,n as da,a5 as td,a6 as nd,a7 as sd,u as Ur,g as rd,a8 as ad,a9 as id,aa as od,ab as ul,ac as ld,ad as hl,ae as cd,af as dd,ag as pl,H as ud,o as hd,S as pd,O as fd,r as md,ah as bd}from"./MobileSheet-Ckug8hTb.js";import{t as Ws,P as ua,g as fl}from"./window-BVUB8gMK.js";import{R as gd,_ as Ai,a as Wi,C as ml,i as ce}from"./event-DvH9tcej.js";import{W as Ye,D as kd}from"./WorkbenchModal-0tPIIhca.js";import{r as wd,b as xd}from"./relay-entry-C5_Iay0I.js";const Ls=new Map,bl=48;function is(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function Li(e,t){return!Number.isFinite(e)||Date.now()-e>t}function vd(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function gl(e){try{const t=JSON.parse(e);return vd(t)?t:null}catch{return null}}function yd(){if(!is())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function kl(){if(!is())return[];const e=[];for(const t of yd()){let s=null;try{s=window.sessionStorage.getItem(t)}catch{continue}if(!s)continue;const a=gl(s);a&&e.push({key:t,savedAt:a.savedAt})}return e.sort((t,s)=>t.savedAt-s.savedAt)}function fr(e){if(is())try{window.sessionStorage.removeItem(e)}catch{}}function Gr(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),s=(e==null?void 0:e.maxCount)??bl,a=kl().filter(c=>!t.has(c.key)),i=Math.max(0,t.size+a.length-s);for(let c=0;c<i;c+=1){const h=a[c];if(!h)break;fr(h.key)}}function Sd(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Pa(e,t){if(!is())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(s){return Sd(s)?"quota_exceeded":"failed"}}function jd(e,t){const s=Pa(e,t);if(s==="success"){Gr({preserveKeys:[e]});return}if(s==="quota_exceeded"){if(fr(e),Gr({maxCount:Math.max(0,bl-1)}),Pa(e,t)==="success"){Gr({preserveKeys:[e]});return}for(const a of kl())if(a.key!==e&&(fr(a.key),Pa(e,t)==="success")){Gr({preserveKeys:[e]});return}}}function ha(e,t){const s=Ls.get(e);if(s){if(!Li(s.savedAt,t))return s.value;Ls.delete(e)}if(!is())return null;let a=null;try{a=window.sessionStorage.getItem(e)}catch{return null}if(!a)return null;const i=gl(a);return!i||Li(i.savedAt,t)?(fr(e),Ls.delete(e),null):(Ls.set(e,i),i.value)}function ur(e,t){const s={savedAt:Date.now(),value:t};if(Ls.set(e,s),!!is())try{jd(e,JSON.stringify(s))}catch{}}function im(e){Ls.delete(e),is()&&fr(e)}const Nd="codingns.debug.perf",Cd="codingns.debug.sessionMessageDedup";function Id(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Nd)==="1"}catch{return!1}}function Je(e,t){if(!Id()||typeof performance>"u")return;const s=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${s}ms`,t);return}console.info(`[perf-ui] ${e} ${s}ms`)}function Td(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Cd)==="1"}catch{return!1}}function om(e,t){if(!Td()||typeof performance>"u")return;const s=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${s}ms`,t);return}console.info(`[session-dedup] ${e} ${s}ms`)}function lm(e,t,s,a){return ne.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:s,expectedVersion:a??void 0})})}function cm(e){return ne.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function dm(e){return ne.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function um(e,t){const s=new URLSearchParams({workspaceId:e,path:t});return ne.request(`/api/files/download?${s.toString()}`)}function Rd(e,t,s=1,a=20){const i=new URLSearchParams({workspaceId:e,keyword:t,page:String(s),pageSize:String(a)});return ne.request(`/api/files/search?${i.toString()}`)}function hm(e,t){const s=new URLSearchParams({workspaceId:e,path:t});return ne.request(`/api/files/preview?${s.toString()}`)}function pm(e){return ne.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function fm(e){return ne.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function mm(e,t,s){const a=new URLSearchParams({workspaceId:e,path:t,staged:String(s)});return ne.request(`/api/git/diff?${a.toString()}`)}function bm(e,t){return ne.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function gm(e,t){return ne.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function km(e,t){return ne.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function wm(e,t){return ne.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function xm(e,t){return ne.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function vm(e){return ne.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function ym(e,t=5,s=null){const a=new URLSearchParams({workspaceId:e,limit:String(t)});return s&&a.set("cursor",s),ne.request(`/api/git/history?${a.toString()}`)}function Sm(e,t){const s=new URLSearchParams({workspaceId:e,commitHash:t});return ne.request(`/api/git/commit-detail?${s.toString()}`)}function Md(e){return ne.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function Pd(e){return ne.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function jm(e,t,s){return ne.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:s})})}function Nm(e,t,s,a,i){return ne.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...s?{remote:s}:{},...a?{auth:a}:{},...i?{remember:i}:{}})})}function Cm(e){return ne.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var ia,oa;function wl(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(s=>"rid"in s?s:wl(s));else if("action"in e&&e.action){const s=new ml;return s.onmessage=e.action,delete e.action,{...e,handler:s}}return e}async function _s(e,t){const s=new ml;if(t&&typeof t=="object"&&("action"in t&&t.action&&(s.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Ws(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Ws(t.icon)),"items"in t&&t.items)){let a=function(i){var c;return"rid"in i?[i.rid,i.kind]:("item"in i&&typeof i.item=="object"&&(!((c=i.item.About)===null||c===void 0)&&c.icon)&&(i.item.About.icon=Ws(i.item.About.icon)),"icon"in i&&i.icon&&(i.icon=Ws(i.icon)),"items"in i&&i.items&&(i.items=i.items.map(a)),wl(i))};t.items=t.items.map(a)}return ce("plugin:menu|new",{kind:e,options:t,handler:s})}class Fs extends gd{get id(){return Ai(this,ia,"f")}get kind(){return Ai(this,oa,"f")}constructor(t,s,a){super(t),ia.set(this,void 0),oa.set(this,void 0),Wi(this,ia,s),Wi(this,oa,a)}}ia=new WeakMap,oa=new WeakMap;class oi extends Fs{constructor(t,s){super(t,s,"MenuItem")}static async new(t){return _s("MenuItem",t).then(([s,a])=>new oi(s,a))}async text(){return ce("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ce("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ce("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ce("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ce("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class li extends Fs{constructor(t,s){super(t,s,"Check")}static async new(t){return _s("Check",t).then(([s,a])=>new li(s,a))}async text(){return ce("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ce("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ce("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ce("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ce("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return ce("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return ce("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var Bi;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(Bi||(Bi={}));class ci extends Fs{constructor(t,s){super(t,s,"Icon")}static async new(t){return _s("Icon",t).then(([s,a])=>new ci(s,a))}async text(){return ce("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ce("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ce("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ce("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return ce("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return ce("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ws(t)})}}class di extends Fs{constructor(t,s){super(t,s,"Predefined")}static async new(t){return _s("Predefined",t).then(([s,a])=>new di(s,a))}async text(){return ce("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ce("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function Ds([e,t,s]){switch(s){case"Submenu":return new ui(e,t);case"Predefined":return new di(e,t);case"Check":return new li(e,t);case"Icon":return new ci(e,t);case"MenuItem":default:return new oi(e,t)}}class ui extends Fs{constructor(t,s){super(t,s,"Submenu")}static async new(t){return _s("Submenu",t).then(([s,a])=>new ui(s,a))}async text(){return ce("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return ce("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return ce("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return ce("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return ce("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(t){return ce("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(t,s){return ce("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(a=>"rid"in a?[a.rid,a.kind]:a),position:s})}async remove(t){return ce("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ce("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(Ds)}async items(){return ce("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(Ds))}async get(t){return ce("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(s=>s?Ds(s):null)}async popup(t,s){var a;return ce("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(a=s==null?void 0:s.label)!==null&&a!==void 0?a:null,at:t instanceof ua?t:t?new ua(t):null})}async setAsWindowsMenuForNSApp(){return ce("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return ce("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return ce("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Ws(t)})}}class Bs extends Fs{constructor(t,s){super(t,s,"Menu")}static async new(t){return _s("Menu",t).then(([s,a])=>new Bs(s,a))}static async default(){return ce("plugin:menu|create_default").then(([t,s])=>new Bs(t,s))}async append(t){return ce("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async prepend(t){return ce("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(s=>"rid"in s?[s.rid,s.kind]:s)})}async insert(t,s){return ce("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(a=>"rid"in a?[a.rid,a.kind]:a),position:s})}async remove(t){return ce("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return ce("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(Ds)}async items(){return ce("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(Ds))}async get(t){return ce("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(s=>s?Ds(s):null)}async popup(t,s){var a;return ce("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(a=s==null?void 0:s.label)!==null&&a!==void 0?a:null,at:t instanceof ua?t:t?new ua(t):null})}async setAsAppMenu(){return ce("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Bs(t[0],t[1]):null)}async setAsWindowMenu(t){var s;return ce("plugin:menu|set_as_window_menu",{rid:this.rid,window:(s=t==null?void 0:t.label)!==null&&s!==void 0?s:null}).then(a=>a?new Bs(a[0],a[1]):null)}}async function Ed(e){if(e.length===0)return;await(await Bs.new({items:e.map(s=>({id:s.id,text:s.label,enabled:!s.disabled,accelerator:s.accelerator,action:()=>{s.onSelect()}}))})).popup(void 0,fl())}const Di={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},Ad=2400,xl="workbench.parallel.pane.palette";let Es=null;const _i=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function vl(e){var s,a;const t=(s=e.displayParentSessionId)==null?void 0:s.trim();return t||((a=e.parentSessionId)==null?void 0:a.trim())||null}function Wd(e){var a;const t=(a=e==null?void 0:e.colorToken)==null?void 0:a.trim();if(!t)return;const s=Di[t]??Di["parallel-group-1"];return{"--parallel-group-accent":s.accent,"--parallel-group-soft":s.soft,"--parallel-group-surface":s.surface}}function Im(e){const t=pa(e.overrideColor)??Ld(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":Fi(t,.08),"--parallel-group-surface":Fi(t,.03)}}function Tm(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const s=yl();return pa(s[t]??null)}function Rm(e,t){if(typeof window>"u")return pa(t);const s=e.trim();if(!s)return null;const a=yl(),i=pa(t);return i?a[s]=i:delete a[s],window.localStorage.setItem(xl,JSON.stringify(a)),i}function Ld(e,t){const s=_i.length,a=Math.abs(Hd(e))%s;return _i[(a+t*5)%s]}function Mm(e){return e?e.role==="anchor"?r("shell.parallelGroupAnchorBadge"):r("shell.parallelGroupMemberBadge"):null}function Bd(e){return e?r("shell.parallelGroupBadge",{count:e.memberCount}):null}function Pm(e){var s;return((s=e==null?void 0:e.branchName)==null?void 0:s.trim())||null}function Dd(e){var s,a,i;return((a=(s=e==null?void 0:e.parallelGroup)==null?void 0:s.groupId)==null?void 0:a.trim())?((i=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:i.lifecycleStatus)!=="promoted":!1}function _d(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function Fd(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function Od(e){Es={groupId:e,createdAt:Date.now()}}function Em(e){return!Es||Es.groupId!==e?!1:Date.now()-Es.createdAt>Ad?(Es=null,!1):(Es=null,!0)}function yl(){if(typeof window>"u")return{};const e=window.localStorage.getItem(xl);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function Hd(e){let t=0;for(const s of e)t=t*31+s.charCodeAt(0)|0;return t}function pa(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function Fi(e,t){const s=Math.max(0,Math.min(t,1)),a=Number.parseInt(e.slice(1,3),16),i=Number.parseInt(e.slice(3,5),16),c=Number.parseInt(e.slice(5,7),16);return`rgba(${a}, ${i}, ${c}, ${s})`}function Sl(e,t){const s=new Map(e.map(c=>[t.getId(c),c])),a=new Map,i=[];for(const c of e){const h=$d(c,s,t);if(!h){i.push(c);continue}const p=a.get(h)??[];a.set(h,[...p,c])}return[...i].sort(t.compare).map(c=>Cl(c,0,a,t,new Set))}function Os(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function jl(e){return e.flatMap(t=>[t.item,...jl(Os(t))])}function Pn(e){return e.flatMap(t=>[t,...Pn(Os(t))])}function hi(e,t){return e.some(s=>t(s.item)||hi(Os(s),t))}function Nl(e,t,s){return e?s(e.item)===t?!0:Os(e).some(a=>Nl(a,t,s)):!1}function As(e,t,s){for(const a of e){const i=s(a.item);if(i===t)return[];const c=As(Os(a),t,s);if(Nl(a,t,s)&&c.length>=0)return[i,...c]}return[]}function Cl(e,t,s,a,i){const c=a.getId(e),h=new Set(i);h.add(c);const p=[...s.get(c)??[]].filter(k=>!h.has(a.getId(k))).sort(a.compare).map(k=>Cl(k,t+1,s,a,h));return{item:e,depth:t,children:p}}function $d(e,t,s){const a=Oi(s.getParentId(e));if(!a)return null;const i=t.get(a);if(!i)return null;const c=new Set([s.getId(e)]);let h=i;for(;h;){const p=s.getId(h);if(c.has(p))return null;c.add(p);const k=Oi(s.getParentId(h));if(!k||(h=t.get(k),!h))return a}return a}function Oi(e){const t=e==null?void 0:e.trim();return t||null}function mt(){return"/workspaces"}function Qt(e){return`/workspaces/${encodeURIComponent(e)}`}function Il(e){return`${Qt(e)}/debug`}function mr(e){return`${Qt(e)}/sessions`}function Tt(e,t){return`${mr(e)}/${encodeURIComponent(t)}`}function Tl(e,t){const s=`${Qt(e)}/tools`;if(!t)return s;const a=new URLSearchParams({tab:t});return`${s}?${a.toString()}`}function Rl(e){return`${Qt(e)}/tools/files`}function Ml(e){return`${Qt(e)}/tools/git`}function Pl(e){return`${Qt(e)}/tools/processes`}function ss(e){return`${Qt(e)}/terminals`}function rs(e,t){const s=`${Qt(e)}/butler`;if(!t)return s;const a=new URLSearchParams({tab:t});return`${s}?${a.toString()}`}function Ud(e){return e.flatMap(t=>[...t.sessions.map(s=>({session:s,workspace:t.workspace})),...Al(t.childWorktrees??[])]).sort((t,s)=>(s.session.lastMessageAt??s.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function Am(e,t){return Sl(e,{getId:s=>s.session.sessionId,getParentId:s=>Gd(s.session,t),compare:qd})}function Gd(e,t){var s;return(t==null?void 0:t.mode)==="mobile"?((s=e.parentSessionId)==null?void 0:s.trim())||null:vl(e)}function El(e,t){const s=zd(),a=new URLSearchParams({provider:t});return`${Tt(e,s)}?${a.toString()}`}function zd(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function qd(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Al(e){return e.flatMap(t=>[...t.sessions.map(s=>({session:s,workspace:t.workspace})),...Al(t.children)])}const Kd="mobile.tools.last-primary-tool";function Wl(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(Kd)==="git"?"git":"files"}catch{return"files"}}function pi(e){var a;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const i of t){const c=Ee(i.pattern,e),h=((a=c==null?void 0:c.params.workspaceId)==null?void 0:a.trim())??null;if(h)return{workspaceId:h,routeKind:i.routeKind,legacy:!1}}const s=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const i of s)if(Ee(i.pattern,e))return{workspaceId:null,routeKind:i.routeKind,legacy:!0};return null}function Vd(e,t){const s=pi(e);if((s==null?void 0:s.routeKind)==="git")return"git";if((s==null?void 0:s.routeKind)==="files")return"files";const a=new URLSearchParams(t).get("tab");return a==="git"?"git":a==="files"?"files":Wl()}function fi(e,t){const s=pi(e);return(s==null?void 0:s.routeKind)==="processes"&&s.workspaceId?ss(s.workspaceId):s!=null&&s.workspaceId?Tl(s.workspaceId,Vd(e,t)):s!=null&&s.legacy?Wl()==="git"?"/tools?tab=git":"/tools?tab=files":null}function mi({activeEntry:e,presentation:t,pathname:s,search:a,moreButtonLabel:i}){if(t==="conversation-focus"||e!=="butler")return null;const c=pi(s);return c?c.routeKind==="processes"?{title:r("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:i}:(c.routeKind==="home"||c.routeKind==="files"||c.routeKind==="git",null):null}const Ll=o.createContext({composerPortalTarget:null});function bi({composerPortalTarget:e,children:t}){return n.jsx(Ll.Provider,{value:{composerPortalTarget:e},children:t})}function Wm(){return o.useContext(Ll)}function gi(e,t,s){const[a,i]=o.useState(void 0);return o.useEffect(()=>{const c=e.current,h=t.current;if(!s||!c||!h){i(void 0),c&&c.style.removeProperty("--mobile-conversation-tabbar-height");return}const p=c,k=h;function m(){if(!e.current||!k.isConnected)return;const N=`${Math.round(k.getBoundingClientRect().height)}px`;p.style.setProperty("--mobile-conversation-tabbar-height",N),i(N)}m();const x=typeof ResizeObserver<"u"?new ResizeObserver(m):null;return x==null||x.observe(k),window.addEventListener("resize",m),()=>{x==null||x.disconnect(),window.removeEventListener("resize",m),p.style.removeProperty("--mobile-conversation-tabbar-height")}},[s,e,t]),a}const Xd=3e3,zr=10,Hi=84,$i=.36;function ki({enabled:e,rootRef:t,suspended:s=!1,resetKey:a}){const i=o.useRef(null),c=o.useRef(null),h=o.useRef("visible"),p=o.useRef(1),[k,m]=o.useState("visible"),[x,N]=o.useState(1);o.useEffect(()=>{h.current=k},[k]),o.useEffect(()=>{p.current=x},[x]);function C(){ts(i),i.current=window.setTimeout(()=>{R()},Xd)}function R(){m("hidden"),N(0)}function H(){m("visible"),N(1),C()}o.useEffect(()=>{if(ts(i),!e){ts(i),m("visible"),N(1);return}if(s){m("hidden"),N(0);return}return H(),()=>{ts(i)}},[e,a,s]),o.useEffect(()=>()=>{ts(i)},[]),o.useEffect(()=>{if(!e||s){c.current=null;return}const E=t.current;if(!E)return;function v(O){if(O.touches.length!==1){c.current=null;return}const j=O.touches[0],J=zi(O.target);if(!j||!J){c.current=null;return}c.current={surface:J,startX:j.clientX,startY:j.clientY,pointerType:"touch",initialState:h.current==="visible"?"visible":"hidden",touchId:j.identifier,dragging:!1,latestProgress:p.current},h.current==="visible"&&ts(i)}function _(O){const j=c.current;if(!j||j.pointerType!=="touch")return;const J=Ea(O.touches,j.touchId);if(!J)return;const te=J.clientX-j.startX,P=J.clientY-j.startY;if(j.surface==="conversation"){if(Math.abs(P)<=zr||Math.abs(P)<=Math.abs(te))return;c.current=null,j.initialState==="visible"&&R();return}const ue=j.initialState==="hidden"?-P:P;ue<=zr&&!j.dragging||(Ki(O),j.dragging=!0,j.latestProgress=Ui(j.initialState,ue),m("dragging"),N(j.latestProgress))}function F(O){const j=c.current;if(!(!j||j.pointerType!=="touch"||!Ea(O.changedTouches,j.touchId))){if(c.current=null,!j.dragging){j.initialState==="visible"&&C();return}Gi(j.initialState,j.latestProgress,H,m,N)}}function Z(O){const j=c.current;if(!(!j||j.pointerType!=="touch"||!Ea(O.changedTouches,j.touchId))){if(c.current=null,!j.dragging){j.initialState==="visible"&&C();return}if(j.initialState==="visible"){H();return}m("hidden"),N(0)}}function T(O){if(O.pointerType!=="touch")return;const j=zi(O.target);if(!j){c.current=null;return}if(c.current={surface:j,startX:O.clientX,startY:O.clientY,pointerType:"pointer",initialState:h.current==="visible"?"visible":"hidden",pointerId:O.pointerId,captureTarget:O.target instanceof Element?O.target:null,dragging:!1,latestProgress:p.current},O.target instanceof Element)try{O.target.setPointerCapture(O.pointerId)}catch{}h.current==="visible"&&ts(i)}function z(O){const j=c.current;if(!j||j.pointerType!=="pointer")return;const J=O.clientX-j.startX,te=O.clientY-j.startY;if(j.surface==="conversation"){if(Math.abs(te)<=zr||Math.abs(te)<=Math.abs(J))return;c.current=null,j.initialState==="visible"&&R();return}const P=j.initialState==="hidden"?-te:te;P<=zr&&!j.dragging||(Ki(O),j.dragging=!0,j.latestProgress=Ui(j.initialState,P),m("dragging"),N(j.latestProgress))}function Y(O){const j=c.current;if(!(!j||j.pointerType!=="pointer"||j.pointerId!==O.pointerId)){if(c.current=null,Yd(j),!j.dragging){j.initialState==="visible"&&C();return}Gi(j.initialState,j.latestProgress,H,m,N)}}return E.addEventListener("touchstart",v,{passive:!0}),E.addEventListener("pointerdown",T,{passive:!0}),window.addEventListener("touchmove",_,{passive:!1}),window.addEventListener("touchend",F),window.addEventListener("touchcancel",Z),window.addEventListener("pointermove",z,{passive:!1}),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y),()=>{E.removeEventListener("touchstart",v),E.removeEventListener("pointerdown",T),window.removeEventListener("touchmove",_),window.removeEventListener("touchend",F),window.removeEventListener("touchcancel",Z),window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y)}},[e,t,s]);const G=e&&!s?x:e?0:1;return{state:s&&e?"hidden":k,progress:G,isOpen:G>.01}}function ts(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function Ui(e,t){return qi(e==="hidden"?t/Hi:1-t/Hi,0,1)}function Gi(e,t,s,a,i){if(e==="hidden"){if(t>=$i){s();return}a("hidden"),i(0);return}if(t<=1-$i){a("hidden"),i(0);return}s()}function Yd(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function Ea(e,t){if(typeof t!="number")return e[0]??null;for(let s=0;s<e.length;s+=1){const a=e[s];if((a==null?void 0:a.identifier)===t)return a}return null}function zi(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function qi(e,t,s){return Math.min(Math.max(e,t),s)}function Ki(e){e.cancelable&&e.preventDefault()}function kr({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:i=!1}){return i||e==="compact"?"compact":e==="expanded"&&s&&a?"expanded":t==="butler"&&a?"medium-auxiliary":s?"medium-navigation":a?"medium-auxiliary":"compact"}function ka(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function Bl(e){return e==="medium-navigation"||e==="expanded"}function Dl(e){return e==="medium-auxiliary"||e==="expanded"}function wi({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:i=!1,children:c,navigationPanel:h,auxiliaryPanel:p}){const k=kr({viewportClass:e,activeEntry:t,hasNavigationPanel:s,hasAuxiliaryPanel:a,preferCompactLayout:i}),m=Bl(k)&&h,x=Dl(k)&&p;return n.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":k,children:[m?n.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:h}):null,n.jsx("div",{className:"mobile-adaptive-pane-main",children:c}),x?n.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:p}):null]})}function Jd({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:i,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:p,onNavigateButler:k,onNavigateToolProcesses:m,onNavigateSettings:x}){const N=Ln(),C=ii(),R=ga(),H=br(),G=o.useRef(null),E=o.useRef(null),[v,_]=o.useState(null),F=t==="conversation-focus",Z=ka({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),T=ki({enabled:F,rootRef:G,resetKey:`${R.pathname}${R.search}`}),z=kr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:Z}),Y=mi({activeEntry:e,presentation:t,pathname:R.pathname,search:R.search,moreButtonLabel:r("shell.androidMoreAction")}),O=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx(eu,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(tu,{}),onClick:p},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(su,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(nu,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(ru,{}),onClick:x}],j=F?{"--mobile-conversation-tabbar-progress":T.progress.toFixed(4)}:void 0;gi(G,E,F);function J(){const P=fi(R.pathname,R.search);if(!P){h();return}H(P,{replace:!0})}const te=n.jsx("nav",{ref:E,className:"android-workbench-bottom-nav","aria-label":r("shell.title"),children:O.map(P=>n.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":P.key===e,"aria-current":P.key===e?"page":void 0,onClick:()=>{P.key!==e&&C.trigger("selection"),P.onClick()},children:[n.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:P.icon}),n.jsx("span",{className:"android-workbench-bottom-nav-label",children:P.label})]},P.key))});return n.jsx(bi,{composerPortalTarget:F?v:null,children:n.jsxs("div",{ref:G,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":z,"data-tabbar-open":F?T.isOpen:!0,"data-conversation-tabbar-state":F?T.state:"default",style:j,children:[Y?n.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[n.jsxs("div",{className:"android-workbench-topbar-leading",children:[Y.showBackButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":r("common.back"),onClick:J,children:n.jsx(Zd,{})}):null,n.jsx("div",{className:"android-workbench-topbar-copy",children:n.jsx("h1",{children:Y.title})})]}),n.jsx("div",{className:"android-workbench-topbar-actions",children:Y.showMoreButton?n.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":Y.moreButtonLabel,onClick:m,children:n.jsx(Qd,{})}):null})]}):null,n.jsx("div",{className:"android-workbench-content",children:n.jsx(wi,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:Z,navigationPanel:a,auxiliaryPanel:i,children:s})}),F?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:_,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:te})]}):te]})})}function Zd(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function Qd(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function eu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function tu(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function nu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function su(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function ru(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const au=120,or={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function Xa(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function iu(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function ou(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(Xa);return e.length>0?Math.max(...e):0}function Vi(){if(typeof window>"u")return or;const e=window.visualViewport,t=ou(),s=(e==null?void 0:e.height)??t,a=Xa(s)?Math.round(s):null,i=Xa(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,c=a===null?0:Math.max(0,Math.round(t-a-i));return{viewportHeight:a,keyboardInset:c,keyboardOpen:iu(typeof document<"u"?document.activeElement:null)&&c>=au}}function Aa(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(a=>a instanceof HTMLElement).forEach(a=>{if(!e){delete a.dataset.mobileKeyboardOpen,delete a.dataset.mobileViewportBound,a.style.removeProperty("--mobile-shell-viewport-height"),a.style.removeProperty("--mobile-shell-keyboard-inset");return}a.dataset.mobileKeyboardOpen=String(t.keyboardOpen),a.dataset.mobileViewportBound="true",t.viewportHeight===null?a.style.removeProperty("--mobile-shell-viewport-height"):a.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),a.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function lu(e){const[t,s]=o.useState(()=>e?Vi():or),a=o.useRef(null);return o.useEffect(()=>{if(!e){s(or),Aa(!1,or);return}function i(){s(Vi())}function c(){a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{a.current=null,i()},0)}i();const h=window.visualViewport;return window.addEventListener("resize",i),window.addEventListener("orientationchange",i),h==null||h.addEventListener("resize",i),h==null||h.addEventListener("scroll",i),document.addEventListener("focusin",i),document.addEventListener("focusout",c),()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",i),h==null||h.removeEventListener("resize",i),h==null||h.removeEventListener("scroll",i),document.removeEventListener("focusin",i),document.removeEventListener("focusout",c),Aa(!1,or)}},[e]),o.useEffect(()=>{Aa(e,t)},[e,t]),t}function cu({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:i,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:p,onNavigateButler:k,onNavigateToolProcesses:m,onNavigateSettings:x}){const N=Ln(),C=ii(),R=ga(),H=br(),G=o.useRef(null),E=o.useRef(null),[v,_]=o.useState(null),F=t==="conversation-focus",Z=ka({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),T=ki({enabled:F,rootRef:G,resetKey:`${R.pathname}${R.search}`}),z=kr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:Z}),Y=mi({activeEntry:e,presentation:t,pathname:R.pathname,search:R.search,moreButtonLabel:r("shell.iosMoreAction")}),O=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx(hu,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(pu,{}),onClick:p},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(mu,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(fu,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(bu,{}),onClick:x}],j=F?{"--mobile-conversation-tabbar-progress":T.progress.toFixed(4)}:void 0;gi(G,E,F);function J(){const P=fi(R.pathname,R.search);if(!P){h();return}H(P,{replace:!0})}const te=n.jsx("nav",{ref:E,className:"ios-workbench-tabbar","aria-label":r("shell.title"),children:O.map(P=>n.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":P.key===e,"aria-current":P.key===e?"page":void 0,onClick:()=>{P.key!==e&&C.trigger("selection"),P.onClick()},children:[n.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:P.icon}),n.jsx("span",{className:"ios-workbench-tabbar-label",children:P.label})]},P.key))});return n.jsx(bi,{composerPortalTarget:F?v:null,children:n.jsxs("div",{ref:G,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":z,"data-tabbar-open":F?T.isOpen:!0,"data-conversation-tabbar-state":F?T.state:"default",style:j,children:[Y?n.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[n.jsx("div",{className:"ios-workbench-nav-leading",children:Y.showBackButton?n.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":r("common.back"),onClick:J,children:[n.jsx(du,{}),n.jsx("span",{children:r("common.back")})]}):null}),n.jsx("div",{className:"ios-workbench-nav-copy",children:n.jsx("h1",{children:Y.title})}),n.jsx("div",{className:"ios-workbench-nav-actions",children:Y.showMoreButton?n.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":Y.moreButtonLabel,onClick:m,children:n.jsx(uu,{})}):null})]}):null,n.jsx("div",{className:"ios-workbench-content",children:n.jsx(wi,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:Z,navigationPanel:a,auxiliaryPanel:i,children:s})}),F?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:_,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:te})]}):te]})})}function du(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.jsx("path",{d:"m15 18-6-6 6-6"})})}function uu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function hu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function pu(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function fu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function mu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function bu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function gu(e){const t=Ln();return t.platform==="ios"?n.jsx(cu,{...e}):t.platform==="android"?n.jsx(Jd,{...e}):n.jsx(ku,{...e})}function ku({activeEntry:e,presentation:t="default",children:s,navigationPanel:a,auxiliaryPanel:i,onNavigateWorkspaces:c,onNavigateTerminals:h,onNavigateSessions:p,onNavigateButler:k,onNavigateToolProcesses:m,onNavigateSettings:x}){const N=Ln(),C=ii(),R=ga(),H=br(),G=o.useRef(null),E=o.useRef(null),[v,_]=o.useState(null),F=lu(N.platform==="web"),Z=N.platform==="web"&&F.keyboardOpen,T=t==="conversation-focus",z=ka({isNativeMobile:N.isNativeMobile,viewportClass:N.viewportClass}),Y=ki({enabled:T,rootRef:G,suspended:Z,resetKey:`${R.pathname}${R.search}`}),O=kr({viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:z}),j=mi({activeEntry:e,presentation:t,pathname:R.pathname,search:R.search,moreButtonLabel:r("shell.iosMoreAction")}),J=[{key:"workspaces",label:r("shell.mobileWorkspacesEntry"),icon:n.jsx(vu,{}),onClick:c},{key:"sessions",label:r("shell.mobileSessionsEntry"),icon:n.jsx(yu,{}),onClick:p},{key:"terminals",label:r("shell.mobileButlerEntry"),icon:n.jsx(ju,{}),onClick:k},{key:"butler",label:r("shell.mobileTerminalsEntry"),icon:n.jsx(Su,{}),onClick:h},{key:"settings",label:r("shell.mobileSettingsEntry"),icon:n.jsx(Nu,{}),onClick:x}],te=T?{"--mobile-conversation-tabbar-progress":Y.progress.toFixed(4)}:void 0;gi(G,E,T);function P(){const K=fi(R.pathname,R.search);if(!K){h();return}H(K,{replace:!0})}const ue=n.jsx("nav",{ref:E,className:"mobile-workbench-tabbar","aria-label":r("shell.title"),hidden:Z,children:J.map(K=>n.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":K.key===e,"aria-current":K.key===e?"page":void 0,onClick:()=>{K.key!==e&&C.trigger("selection"),K.onClick()},children:[n.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:K.icon}),n.jsx("span",{className:"mobile-workbench-tabbar-label",children:K.label})]},K.key))});return n.jsx(bi,{composerPortalTarget:T?v:null,children:n.jsxs("div",{ref:G,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":N.platform,"data-mobile-keyboard-open":Z,"data-pane-layout":O,"data-tabbar-open":Z?!1:T?Y.isOpen:!0,"data-conversation-tabbar-state":T?Y.state:"default",style:te,children:[j?n.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[n.jsxs("div",{className:"mobile-workbench-header-leading",children:[j.showBackButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":r("common.back"),onClick:P,children:n.jsx(wu,{})}):null,n.jsx("div",{className:"mobile-workbench-header-copy",children:n.jsx("h1",{children:j.title})})]}),n.jsx("div",{className:"mobile-workbench-header-actions",children:j.showMoreButton?n.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":j.moreButtonLabel,onClick:m,children:n.jsx(xu,{})}):null})]}):null,n.jsx("div",{className:"mobile-workbench-content",children:n.jsx(wi,{viewportClass:N.viewportClass,activeEntry:e,hasNavigationPanel:!!a,hasAuxiliaryPanel:!!i,preferCompactLayout:z,navigationPanel:a,auxiliaryPanel:i,children:s})}),T?n.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[n.jsx("div",{ref:_,className:"mobile-conversation-bottom-layer-composer-slot"}),n.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:ue})]}):ue]})})}function wu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"m15 18-6-6 6-6"}),n.jsx("path",{d:"M21 12H9"})]})}function xu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),n.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function vu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M8 13h8"})]})}function yu(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Su(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),n.jsx("path",{d:"m7.5 9 3 3-3 3"}),n.jsx("path",{d:"M12.5 15H17"})]})}function ju(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),n.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),n.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Nu(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class Cu{constructor(t){Ne(this,"maxAttempts");Ne(this,"baseDelayMs");Ne(this,"reconnectAttempts",0);Ne(this,"reconnectTimer",null);Ne(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!_t.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class Iu{constructor(t){Ne(this,"socket",null);Ne(this,"disposed",!1);Ne(this,"authRecoveryInFlight",!1);Ne(this,"pendingRefresh",!1);Ne(this,"workbenchKnownRevision");Ne(this,"lastWorkbenchSnapshot",null);Ne(this,"fileTreeSubscription",null);Ne(this,"gitSubscription",null);Ne(this,"terminalManagerSubscription",null);Ne(this,"workspaceManagementSubscription",null);Ne(this,"pendingFileTreeRefresh",null);Ne(this,"pendingGitRefresh",null);Ne(this,"pendingTerminalManagerRefresh",null);Ne(this,"pendingWorkspaceManagementRefresh",null);Ne(this,"fileTreeRevisionByPath",new Map);Ne(this,"gitRevisionByWorkspaceId",new Map);Ne(this,"terminalManagerRevisionByWorkspaceId",new Map);Ne(this,"workspaceManagementRevisionByWorkspaceId",new Map);Ne(this,"fileTreeListeners",new Set);Ne(this,"gitListeners",new Set);Ne(this,"terminalManagerListeners",new Set);Ne(this,"workspaceManagementListeners",new Set);Ne(this,"workbenchSubscribeStartedAtMs",null);Ne(this,"workbenchRefreshStartedAtMs",null);Ne(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new Cu({onReconnect:s=>{this.connect(s)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!Xi(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Je("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=It(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=It(t.revision)??null}subscribeFileTree(t,s,a){this.fileTreeSubscription={workspaceId:t,paths:Yi(s),knownRevisionByPath:Wa(a==null?void 0:a.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:La(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,s,a){const i=Yi(s),c={type:"fileTree.refresh",workspaceId:t,paths:i,knownRevisions:La(t,i,Wa(a==null?void 0:a.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(c)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:i,knownRevisionByPath:Wa(a==null?void 0:a.knownRevisionByPath)}}subscribeGit(t,s){this.gitSubscription={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,s){const a={type:"git.refresh",workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)}}subscribeTerminalManager(t,s){this.terminalManagerSubscription={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,s){const a={type:"terminalManager.refresh",workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)}}subscribeWorkspaceManagement(t,s){this.workspaceManagementSubscription={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,s){const a={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(a)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:It(s==null?void 0:s.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var k;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const s=(k=pr.getState().session)==null?void 0:k.accessToken;if(!s){this.options.onUnauthorized();return}const a=rl(),i=Wc(a),c=i.baseUrl,h=`${Lc("/ws",c)}?access_token=${encodeURIComponent(s)}`,p=i.transport.createWebSocket({path:"/ws",baseUrl:c,url:h});this.socket=p,p.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),p.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),Je("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:c}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&p.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:La(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&p.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&p.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&p.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),p.addEventListener("message",m=>{var N,C,R,H,G,E,v,_,F,Z;if(!(m instanceof MessageEvent)||typeof m.data!="string")return;const x=JSON.parse(m.data);if(x.type==="system.connected"){this.connectionManager.markConnected();return}if(x.type==="session.error"){x.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(x.type==="workbench.snapshot"&&(Je("workbench.snapshot.received",{unchanged:x.unchanged,revision:x.revision,workspaceCount:((N=x.snapshot)==null?void 0:N.items.length)??0,sessionCount:x.snapshot?Mu(x.snapshot):0,subscribeDurationMs:qr(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qr(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),x.type==="workbench.delta"){Je("workbench.delta.received",{baseRevision:x.baseRevision,revision:x.revision,changedWorkspaceCount:x.changedItems.length,removedWorkspaceCount:x.removedWorkspaceIds.length,subscribeDurationMs:qr(this.workbenchSubscribeStartedAtMs),refreshDurationMs:qr(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const T=Ru(this.lastWorkbenchSnapshot,x);if(!T){Je("workbench.delta.mismatch",{currentRevision:((C=this.lastWorkbenchSnapshot)==null?void 0:C.revision)??null,baseRevision:x.baseRevision,revision:x.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=T,this.workbenchKnownRevision=x.revision,this.options.onSnapshot(T);return}if(x.type==="fileTree.snapshot"){const T=x.snapshot;if(T)T.revision=x.revision,this.fileTreeRevisionByPath.set(Ya(T.workspaceId,T.path),x.revision);else if(x.unchanged&&this.fileTreeSubscription)for(const z of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(Ya(this.fileTreeSubscription.workspaceId,z),x.revision);if(!T)return;(H=(R=this.options).onFileTreeSnapshot)==null||H.call(R,T),this.fileTreeListeners.forEach(z=>z(T));return}if(x.type==="git.snapshot"){const T=x.snapshot;if(T?(T.revision=x.revision,this.gitRevisionByWorkspaceId.set(T.workspaceId,x.revision)):x.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,x.revision),!T)return;(E=(G=this.options).onGitSnapshot)==null||E.call(G,T),this.gitListeners.forEach(z=>z(T));return}if(x.type==="terminalManager.snapshot"){const T=x.snapshot;if(T?(T.revision=x.revision,this.terminalManagerRevisionByWorkspaceId.set(T.workspaceId,x.revision)):x.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,x.revision),!T)return;(_=(v=this.options).onTerminalManagerSnapshot)==null||_.call(v,T),this.terminalManagerListeners.forEach(z=>z(T));return}if(x.type==="workspaceManagement.snapshot"){const T=x.snapshot;if(T?(T.revision=x.revision,this.workspaceManagementRevisionByWorkspaceId.set(T.workspaceId,x.revision)):x.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,x.revision),!T)return;(Z=(F=this.options).onWorkspaceManagementSnapshot)==null||Z.call(F,T),this.workspaceManagementListeners.forEach(z=>z(T));return}x.type==="workbench.snapshot"&&x.snapshot&&Tu(x.snapshot)?(x.snapshot.revision=x.revision,this.lastWorkbenchSnapshot=x.snapshot,this.workbenchKnownRevision=x.revision,this.options.onSnapshot(x.snapshot)):x.type==="workbench.snapshot"&&x.unchanged&&(this.workbenchKnownRevision=x.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:x.revision}))}),p.addEventListener("close",()=>{this.disposed||this.socket!==p||this.connectionManager.markDisconnected()}),p.addEventListener("error",()=>{this.disposed||this.socket!==p||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),pr.refresh().then(s=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(s.status==="refreshed"){this.connectionManager.reconnectNow();return}if(s.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const s=this.socket;return Xi(s)?(s.send(JSON.stringify(t)),!0):!1}}function Xi(e){return e!==null&&e.readyState===1}function Tu(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function Yi(e){const t=new Set;for(const s of e??[""])t.add(s.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function It(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function Ru(e,t){if(!e||e.revision!==t.baseRevision)return null;const s=new Map(e.items.map(i=>[i.workspace.id,i]));for(const i of t.removedWorkspaceIds)s.delete(i);for(const i of t.changedItems)s.set(i.workspace.id,i);const a=[];for(const i of t.orderedWorkspaceIds){const c=s.get(i);if(!c)return null;a.push(c)}return{revision:t.revision,items:a}}function Wa(e){return e?Object.fromEntries(Object.entries(e).map(([t,s])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),It(s)]).filter(t=>t[1]!==null)):{}}function La(e,t,s,a){const i=t.map(c=>{const h=c.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[h,s[h]??a.get(Ya(e,h))??null]}).filter(c=>!!c[1]);if(i.length!==0)return Object.fromEntries(i)}function Ya(e,t){return`${e}::${t}`}function Mu(e){return e.items.reduce((t,s)=>t+s.sessions.length+_l(s.childWorktrees??[]),0)}function _l(e){return e.reduce((t,s)=>{if(typeof s!="object"||s===null)return t;const a=s,i=Array.isArray(a.sessions)?a.sessions.length:0,c=Array.isArray(a.children)?_l(a.children):0;return t+i+c},0)}function qr(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const Ji=6,Pu=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function Eu(e){return e instanceof HTMLElement?!e.closest(Pu):!0}function Ja(e,t,s){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&Eu(s)}function Fl(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Ol(e){return Fl(e)?"":void 0}function Au(e){if(!Ja(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,s=e.clientY;let a=!0;const i=()=>{a&&(a=!1,window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",h),window.removeEventListener("blur",p))},c=k=>{Math.abs(k.clientX-t)<Ji&&Math.abs(k.clientY-s)<Ji||(i(),Wu())},h=()=>{i()},p=()=>{i()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",h),window.addEventListener("blur",p)}async function Wu(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await fl().startDragging()}const fa=.78,Lu=1;function Bu(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Hl(e,t,s,a){const i=Math.hypot(s-e,a-t),c=Math.min(1,i/120);return fa+(Lu-fa)*c}function En(e){return Math.round(Number.isFinite(e)?e:0)}function Du(e){if(!Bu())return null;const t=En(e.x),s=En(e.y);let a=!1,i=Promise.resolve();const c=(p,k)=>(i=i.then(async()=>{await window.__TAURI_INTERNALS__.invoke(p,k)}).catch(()=>{}),i),h=async()=>{a||(a=!0,await c("close_detach_preview"))};return c("show_detach_preview",{title:e.title,x:t,y:s,scale:fa}),{updatePosition(p,k){if(a)return;const m=En(p),x=En(k);c("update_detach_preview_position",{x:m,y:x,scale:Hl(t,s,m,x)})},complete(){return h()},cancel(){return h()}}}function _u(e){if(typeof document>"u")return null;const t=En(e.x),s=En(e.y),a=document.createElement("div");a.className="desktop-window-detach-animation",a.setAttribute("aria-hidden","true"),a.dataset.state="preview",a.style.left=`${t}px`,a.style.top=`${s}px`,a.style.setProperty("--detach-preview-scale",fa.toFixed(3));const i=document.createElement("div");i.className="desktop-window-detach-animation-bar";const c=document.createElement("strong");c.className="desktop-window-detach-animation-title",c.textContent=e.title;const h=document.createElement("div");h.className="desktop-window-detach-animation-body",i.append(c),a.append(i,h),document.body.append(a);let p=!1;const k=()=>{p||(p=!0,a.remove())};return{updatePosition(m,x){if(p)return;const N=En(m),C=En(x),R=Hl(t,s,N,C);a.style.left=`${N}px`,a.style.top=`${C}px`,a.style.setProperty("--detach-preview-scale",R.toFixed(3))},async complete(){k()},async cancel(){k()}}}function Zi(e){return Du(e)??_u(e)}const Fu={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function Ou(e){return{...e,bounds:{...e.bounds}}}function Hu(e,t,s){t&&(e.windows.registerDescriptor(t),s?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function $u(e){return Fu[e]}function $l(e,t){return`${e}-${t}`}async function wa(e,t,s){const a=s.workspaceId.trim(),i=$u(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!a)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${i.label}外部窗口必须绑定工作区。`};const c=$l(t,a),h=e.windows.getDescriptor(c),p=h?Ou(h):null,k=e.windows.isWindowOpen(c),m=Bc({windowId:c,kind:t,workspaceId:a,workspaceName:s.workspaceName??(p==null?void 0:p.workspaceName)??null,sessionId:s.sessionId??(p==null?void 0:p.sessionId)??null,mode:"external",bounds:p==null?void 0:p.bounds,focusOwner:s.focusOwner??i.defaultFocusOwner});e.windows.registerDescriptor(m);const x=await e.bridge.createWindow(m);return x.ok?(e.windows.markWindowOpen(c),{ok:!0,value:m}):(p?Hu(e,p,k):e.windows.removeWindow(c),{ok:!1,errorCode:x.errorCode,detail:x.detail})}function Lm(e){return $l("terminals",e)}function Uu(e,t){return wa(e,"files",t)}function Gu(e,t){return wa(e,"git",t)}function zu(e,t){return wa(e,"processes",t)}function Bm(e,t){return wa(e,"terminals",t)}async function Qi(){return await ne.request("/api/skills/overview")}async function qu(e){await ne.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function Ku(e){await ne.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Vu(e){await ne.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}function Xu({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:s}){const a=al(g=>{var S;return((S=g.session)==null?void 0:S.accessToken)??null}),i=o.useRef(null),[c,h]=o.useState(null),[p,k]=o.useState(!1),[m,x]=o.useState(null),[N,C]=o.useState(null),[R,H]=o.useState(null),[G,E]=o.useState(!1),[v,_]=o.useState(!1),[F,Z]=o.useState(null),[T,z]=o.useState("file"),[Y,O]=o.useState("workspace"),[j,J]=o.useState(""),[te,P]=o.useState(()=>ar("workspace"));o.useEffect(()=>{let g=!0;if(!G)return;if(!a){h(null),C(null),H(null),k(!1);return}return(async()=>{k(!0);try{const B=await Qi();if(!g)return;h(B),C(null)}catch(B){if(!g)return;C(Ms(B))}finally{g&&k(!1)}})(),()=>{g=!1}},[a,G]);async function ue(){const g=await Qi();h(g),C(null)}async function K(){if(a){x("refresh"),C(null),H(null);try{await ue(),H(r("settings.skillRefreshSuccess"))}catch(g){C(Ms(g))}finally{x(null)}}}async function Q(g){if(a){x(eo(g)),C(null),H(null);try{await Ku({targetCli:g.targetCli,directoryPath:g.directoryPath,expectedContentHash:g.contentHash}),await ue(),H(r("settings.skillImportSuccess",{name:g.name,target:An(g.targetCli)}))}catch(S){C(Ms(S))}finally{x(null)}}}async function D(g){if(!a)return;const S=g.bindings.filter(B=>B.enabled).map(B=>B.targetCli);if(S.length===0){C(r("settings.skillSyncTargetMissing"));return}x(to(g.skill.id)),C(null),H(null);try{await Vu({skillId:g.skill.id,targetCli:S}),await ue(),H(r("settings.skillSyncSuccess",{name:g.skill.name}))}catch(B){C(Ms(B))}finally{x(null)}}async function y(g){var B;const S=((B=g.target.files)==null?void 0:B[0])??null;if(g.target.value="",!!S){C(null),H(null);try{const L=await uh(S),we=zl(S.name,L);Z(we),P(ar(Y))}catch(L){C(Ms(L))}}}async function I(){const g=no({sourceMode:T,fileDraft:F,pastedMarkdown:j});if(!a)return;if(!g){C(T==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty"));return}const S=g.directoryName;if(!S){C(r("settings.skillUploadDirectoryInvalid"));return}const B=Za(Y).filter(L=>te[L]).map(L=>L);if(B.length===0){C(r("settings.skillUploadTargetRequired"));return}x("upload"),C(null),H(null);try{await qu({markdownContent:g.rawContent,scope:Y,fileName:g.fileName,directoryName:S,targetCli:B}),await ue(),H(r("settings.skillUploadSuccess",{name:S})),ve(Y),_(!1)}catch(L){C(Ms(L))}finally{x(null)}}function q(g){O(g),P(ar(g))}function se(g){z(g),Z(null),J(""),P(ar(Y)),C(null)}function Ce(g){P(S=>({...S,[g]:!S[g]}))}function ie(){_(!0),C(null)}function oe(){_(!1),C(null),ve(Y)}function ve(g){Z(null),J(""),z("file"),P(ar(g))}const ke=(c==null?void 0:c.summary)??{managedSkillCount:0,managedEntryCount:0},he=lh((c==null?void 0:c.assistantRuntimeSkills)??[],(c==null?void 0:c.conflictedEntries)??[],(c==null?void 0:c.diagnostics)??[]),de=((c==null?void 0:c.conflictedEntries)??[]).filter(g=>!Gl(g,(c==null?void 0:c.diagnostics)??[])),ge=((c==null?void 0:c.diagnostics)??[]).filter(g=>!wr(g)),ye=no({sourceMode:T,fileDraft:F,pastedMarkdown:j}),V=t??r("settings.skillManageAction");return n.jsxs(n.Fragment,{children:[n.jsxs("button",{className:e,type:"button","data-open":G?"true":"false","aria-haspopup":"dialog","aria-expanded":G,onClick:()=>{E(!0)},children:[s,n.jsx("span",{children:V})]}),n.jsxs(Ye,{open:G,title:r("settings.skillConfigModalTitle"),description:r("settings.skillConfigModalDescription"),className:"settings-skill-modal",headerActions:n.jsxs("div",{className:"settings-skill-modal-actions",children:[n.jsx("button",{className:"secondary-button",type:"button",disabled:!a||p||m!==null,onClick:ie,children:r("settings.skillCreateAction")}),n.jsx("button",{className:"secondary-button",type:"button",disabled:!a||p||m!==null,onClick:()=>{K()},children:m==="refresh"?r("common.loading"):r("settings.skillRefresh")})]}),onClose:()=>E(!1),children:[n.jsxs("section",{className:"settings-skill-summary-block",children:[n.jsxs("div",{className:"settings-skill-summary-grid",children:[n.jsx(Kr,{label:r("settings.skillSummaryManagedSkills"),value:String(ke.managedSkillCount)}),n.jsx(Kr,{label:r("settings.skillSummaryManagedEntries"),value:String(ke.managedEntryCount)}),n.jsx(Kr,{label:r("settings.skillSummaryConflictedEntries"),value:String(de.length)}),n.jsx(Kr,{label:r("settings.skillSummaryDiagnostics"),value:String(ge.length)})]}),n.jsx("div",{className:"settings-release-meta",children:n.jsxs("span",{children:[r("settings.skillScannedAt"),": ",p?r("common.loading"):oh(c==null?void 0:c.scannedAt)]})}),R?n.jsx("p",{className:"settings-release-status",children:R}):null,N?n.jsx("p",{className:"settings-release-status",children:N}):null]}),n.jsx(rr,{title:r("settings.skillManagedListTitle"),emptyText:r("settings.skillManagedEmpty"),items:(c==null?void 0:c.managedSkills)??[],renderItem:g=>{const S=to(g.skill.id);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:g.skill.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:sh(g.bindings)}),n.jsx("div",{className:"settings-skill-tags",children:g.bindings.map(B=>n.jsxs("span",{className:"settings-skill-tag","data-status":B.syncStatus,children:[An(B.targetCli)," · ",nh(B.syncStatus)]},`${g.skill.id}-${B.targetCli}`))})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:p||m!==null,onClick:()=>{D(g)},children:m===S?r("common.loading"):r("settings.skillSyncAction")})})]},g.skill.id)}}),n.jsx(rr,{title:r("settings.skillUnmanagedListTitle"),emptyText:r("settings.skillUnmanagedEmpty"),items:(c==null?void 0:c.unmanagedEntries)??[],renderItem:g=>{const S=eo(g);return n.jsxs("div",{className:"settings-skill-entry",children:[n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:g.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:rh(g)})]}),n.jsx("div",{className:"settings-skill-entry-actions",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:p||m!==null,onClick:()=>{Q(g)},children:m===S?r("common.loading"):r("settings.skillImportAction")})})]},`${g.targetCli}:${g.directoryPath}`)}}),n.jsx(rr,{title:r("settings.skillAssistantRuntimeListTitle"),description:r("settings.skillAssistantRuntimeListDescription"),emptyText:r("settings.skillAssistantRuntimeEmpty"),items:he,renderItem:g=>n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:g.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:r("settings.skillAssistantRuntimeItemDescription")}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillAssistantRuntimeUsedBy"),": ",Ul(g.usedByTargetCli)]}),n.jsxs("div",{className:"settings-skill-tags",children:[n.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:r("settings.skillTagAssistantOnly")}),g.usedByTargetCli.map(S=>n.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:An(S)},`${g.directoryName}:${S}`))]})]})},`${g.directoryName}:${g.sourcePath}`)}),n.jsx(rr,{title:r("settings.skillConflictedListTitle"),emptyText:r("settings.skillConflictedEmpty"),items:de,renderItem:g=>{const S=ch(g,(c==null?void 0:c.diagnostics)??[]);return n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:g.name}),n.jsx("p",{className:"settings-skill-entry-meta",children:ah(g)}),S.length>0?n.jsx("div",{className:"settings-skill-tags",children:S.map(B=>n.jsx("span",{className:"settings-skill-tag","data-status":B.status,children:B.label},B.key))}):null]})},`${g.targetCli}:${g.directoryPath}`)}}),n.jsx(rr,{title:r("settings.skillDiagnosticsTitle"),emptyText:r("settings.skillDiagnosticsEmpty"),items:ge,renderItem:g=>{const S=dh(g),B=ih(g);return n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:B.title}),n.jsx("p",{className:"settings-skill-entry-meta",children:B.detail}),S.length>0?n.jsx("div",{className:"settings-skill-tags",children:S.map(L=>n.jsx("span",{className:"settings-skill-tag","data-status":L.status,children:L.label},L.key))}):null]})},`${g.targetCli}:${g.code}:${g.directoryPath??g.rootDir}`)}})]}),n.jsx(Ye,{open:v,title:r("settings.skillCreateModalTitle"),description:r("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:oe,children:n.jsxs("section",{className:"settings-skill-section",children:[n.jsx("h3",{className:"settings-skill-section-title",children:r("settings.skillUploadSectionTitle")}),n.jsx("p",{className:"settings-skill-section-description",children:r("settings.skillUploadSectionDescription")}),n.jsxs("div",{className:"settings-skill-create-panel",children:[n.jsx("input",{ref:i,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:g=>{y(g)}}),n.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":r("settings.skillCreateSourceTabsLabel"),children:Qu.map(g=>{const S=T===g;return n.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":S,"data-active":S?"true":"false",onClick:()=>se(g),children:th(g)},g)})}),n.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":r("settings.skillUploadScopeLabel"),children:Zu.map(g=>n.jsxs("label",{className:"settings-skill-upload-target","data-selected":Y===g?"true":"false",children:[n.jsx("input",{type:"radio",name:"skill-upload-scope",checked:Y===g,onChange:()=>q(g)}),n.jsx("span",{children:eh(g)})]},g))}),T==="file"?n.jsx("div",{className:"settings-skill-create-toolbar",children:n.jsx("button",{className:"secondary-button",type:"button",disabled:p||m!==null,onClick:()=>{var g;(g=i.current)==null||g.click()},children:r("settings.skillUploadPickAction")})}):n.jsxs("label",{className:"settings-skill-upload-field",children:[n.jsx("span",{children:r("settings.skillPasteLabel")}),n.jsx("textarea",{className:"settings-skill-create-textarea",value:j,onChange:g=>J(g.target.value),placeholder:r("settings.skillPastePlaceholder")})]}),ye?n.jsx("div",{className:"settings-skill-entry",children:n.jsxs("div",{className:"settings-skill-entry-main",children:[n.jsx("strong",{className:"settings-skill-entry-title",children:ye.previewTitle}),n.jsxs("p",{className:"settings-skill-entry-meta",children:[r("settings.skillUploadPickedFile"),": ",ye.fileName]})]})}):n.jsx("div",{className:"settings-skill-empty",children:T==="paste"?r("settings.skillPasteEmpty"):r("settings.skillUploadEmpty")}),n.jsxs("div",{className:"settings-skill-upload-field",children:[n.jsx("span",{children:r("settings.skillUploadTargetsLabel")}),n.jsx("div",{className:"settings-skill-upload-targets",children:Za(Y).map(g=>n.jsxs("label",{className:"settings-skill-upload-target","data-selected":te[g]?"true":"false",children:[n.jsx("input",{type:"checkbox",checked:te[g],onChange:()=>Ce(g)}),n.jsx("span",{children:An(g)})]},g))})]}),ye!=null&&ye.notes.length?n.jsx("div",{className:"settings-skill-tags",children:ye.notes.map((g,S)=>n.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:g},`${ye.fileName}:${S}`))}):null,N?n.jsx("p",{className:"settings-release-status",children:N}):null,n.jsx("div",{className:"settings-skill-create-actions",children:n.jsx("button",{className:"primary-button",type:"button",disabled:p||m!==null,onClick:()=>{I()},children:m==="upload"?r("common.loading"):r("settings.skillCreateSubmitAction")})})]})]})})]})}function rr({title:e,description:t,emptyText:s,items:a,renderItem:i}){return n.jsxs("section",{className:"settings-skill-section",children:[n.jsx("h3",{className:"settings-skill-section-title",children:e}),t?n.jsx("p",{className:"settings-skill-section-description",children:t}):null,a.length>0?n.jsx("div",{className:"settings-skill-entry-list",children:a.map(c=>i(c))}):n.jsx("div",{className:"settings-skill-empty",children:s})]})}function Kr({label:e,value:t}){return n.jsxs("div",{className:"settings-skill-summary-card",children:[n.jsx("span",{children:e}),n.jsx("strong",{children:t})]})}function eo(e){return`import:${e.targetCli}:${e.directoryPath}`}function to(e){return`sync:${e}`}const Yu=["codex","claude-code","gemini","opencode"],Ju=["codex","claude-code"],Zu=["workspace","assistant"],Qu=["file","paste"];function Ms(e){return e instanceof il?e.message||r("settings.skillLoadFailed"):e instanceof Error?e.message:r("settings.skillLoadFailed")}function An(e){switch(e){case"claude-code":return r("settings.skillTargetClaudeCode");case"gemini":return r("settings.skillTargetGemini");case"opencode":return r("settings.skillTargetOpenCode");default:return r("settings.skillTargetCodex")}}function eh(e){return e==="assistant"?r("settings.skillUploadScopeAssistant"):r("settings.skillUploadScopeWorkspace")}function th(e){return e==="paste"?r("settings.skillCreateSourcePaste"):r("settings.skillCreateSourceFile")}function ar(e){return{codex:new Set(Za(e)).has("codex"),"claude-code":!1,gemini:!1,opencode:!1}}function Za(e){return e==="assistant"?Ju:Yu}function no({sourceMode:e,fileDraft:t,pastedMarkdown:s}){return e==="file"?t:s.trim()?zl(hh(s),s):null}function nh(e){switch(e){case"conflicted":return r("settings.skillBindingConflicted");case"failed":return r("settings.skillBindingFailed");case"pending":return r("settings.skillBindingPending");default:return r("settings.skillBindingSynced")}}function Ul(e){return e.map(An).join(" / ")}function sh(e){const t=e.filter(s=>s.enabled);return t.length===0?r("settings.skillManagedItemNoTarget"):r("settings.skillManagedItemDescription",{targets:Ul(t.map(s=>s.targetCli))})}function rh(e){return r("settings.skillUnmanagedItemDescription",{target:An(e.targetCli)})}function ah(e){return r("settings.skillConflictedItemDescription",{target:An(e.targetCli)})}function ih(e){const t=An(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:r("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:r("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:r("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:r("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:r("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:r("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:r("settings.skillDiagnosticGenericTitle",{target:t}),detail:r("settings.skillDiagnosticGenericDetail",{target:t})}}}function oh(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function lh(e,t,s){if(e.length>0)return e.map(i=>({name:i.name,directoryName:i.directoryName,sourcePath:i.sourcePath,usedByTargetCli:i.usedByTargetCli}));const a=new Map;for(const i of t)Gl(i,s)&&a.set(so(i.targetCli,i.directoryPath),{name:i.name,directoryName:i.directoryName,sourcePath:i.directoryPath,usedByTargetCli:[i.targetCli]});for(const i of s){if(!wr(i))continue;const c=i.directoryPath??i.rootDir,h=so(i.targetCli,c);a.has(h)||a.set(h,{name:i.directoryName??"codingns-assistant",directoryName:i.directoryName??"codingns-assistant",sourcePath:c,usedByTargetCli:[i.targetCli]})}return[...a.values()]}function so(e,t){return`${e}:${t}`}function Gl(e,t){return t.some(s=>wr(s)&&s.targetCli===e.targetCli&&s.directoryPath===e.directoryPath&&s.directoryName===e.directoryName)}function wr(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function ch(e,t){return t.find(a=>wr(a)&&a.targetCli===e.targetCli&&a.directoryName===e.directoryName&&a.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function dh(e){return wr(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:r("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function zl(e,t){const s=[],a=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
3
|
+
`).trim();if(!a)throw new Error(r("settings.skillUploadContentEmpty"));a!==t.trim()&&s.push(r("settings.skillUploadNormalizedNote"));const i=ql(a),c=Qa(e)??Qa(i)??"";return c||s.push(r("settings.skillUploadDirectoryRequiredNote")),i||s.push(r("settings.skillUploadHeadingNote")),{fileName:e,rawContent:a,directoryName:c,previewTitle:i||ph(c||"skill"),notes:s}}async function uh(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(r("settings.skillUploadReadFailed"));return await new Promise((t,s)=>{const a=new FileReader;a.onerror=()=>{s(a.error??new Error(r("settings.skillUploadReadFailed")))},a.onload=()=>{if(typeof a.result=="string"){t(a.result);return}s(new Error(r("settings.skillUploadReadFailed")))},a.readAsText(e)})}function Qa(e){const a=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return a.length>0?a:null}function hh(e){const t=Qa(ql(e));return t?`${t}.md`:"pasted-skill.md"}function ql(e){var t,s;return((s=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:s.trim())??""}function ph(e){return e.split(/[._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")||e}function xi(e){var t,s;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((s=e.lastErrorDetail)!=null&&s.trim())}function fh(e,t,s){return`${e} is-${Kl(t,s)}`}function Kl(e,t){t==null||t.isActive;const s=gh(e);return t!=null&&t.hasSubagents?s==="error"?"error":s==="unread"?"subagent-unread":s==="running"||s==="running_inferred"?"subagent-running":"subagent":s==="running_inferred"?"running-inferred":s.replace("_","-")}function mh(e){return e.runningState==="stale"?r("conversation.runtimeStale"):e.runningState==="unknown"?r("conversation.runtimeUnknown"):null}function bh(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function Dm(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function gh(e){return xi(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?kh(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function kh(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function wh(e){return vi(e)!==null}function xh(e){return e.isSubagent===!0&&!wh(e)}function vi(e){return e.forkMethod==="reconstructed_message_fork"||e.forkMethod==="reconstructed_session_fork"?"reconstructed":e.forkMethod==="native_message_fork"||e.forkSourceType==="message"?"message":e.forkMethod==="native_session_fork"||e.forkSourceType==="session"?"session":null}function vh(e){const t=vi(e);return t==="reconstructed"?r("shell.sessionForkReconstructed"):t==="message"?r("shell.sessionForkMessage"):t==="session"?r("shell.sessionForkSession"):null}function yh(e){return e.sessionKind==="annotation"?"annotation":null}function _m(e){return yh(e)==="annotation"?r("conversation.actionSessionBadge"):null}const ro=48;function Sh(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function yi(e,t){const s=Sh(e)||t,a=s.length>ro?s.slice(0,ro).trimEnd():s;return{fullTitle:s,displayTitle:a}}function Vr(e,t){return(t??"").localeCompare(e??"")}function ao(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function Xr(e){return(e==null?void 0:e.trim())??""}function Si(e,t,s){if(s==="updatedAt"){const h=Vr(e.updatedAt,t.updatedAt);if(h!==0)return h}if(s==="title"){const h=ao(Xr(e.title),Xr(t.title));if(h!==0)return h}else{const h=Vr(e.createdAt,t.createdAt);if(h!==0)return h}const a=Vr(e.updatedAt,t.updatedAt);if(a!==0)return a;const i=Vr(e.createdAt,t.createdAt);if(i!==0)return i;const c=ao(Xr(e.title),Xr(t.title));return c!==0?c:e.sessionId.localeCompare(t.sessionId)}function xr(e,t){return[...e].sort((s,a)=>Si(s,a,t))}function ji(e,t){return Array.isArray(e)?e.map(s=>({...s,sessions:xr(s.sessions,t),children:ji(s.children,t)})):[]}const Ba=5,Da=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function jh(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function Nh(e,t){const s=e.reduce((p,k)=>p+k.count,0);if(s<=0)return[];const i=e.slice(0,Ba).map((p,k)=>({...p,key:p.type,ratio:p.count/s,color:Da[k]??Da[0]})),c=e.slice(Ba);if(c.length===0)return i;const h=c.reduce((p,k)=>p+k.count,0);return i.push({key:"other",type:t,count:h,ratio:h/s,color:Da[Ba]}),i}function Ch(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((a,i)=>{const c=t,h=i===e.length-1?1:Math.min(1,t+a.ratio);return t=h,`${a.color} ${io(c)} ${io(h)}`}).join(", ")})`}function Ih(e){return{"--workbench-manage-chart-background":Ch(e)}}function io(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const Th=8,Rh=12,Mh=160,oo=96;function Ph(e,t,s,a={}){const i=a.gapPx??Th,c=a.viewportMarginPx??Rh,h=a.defaultWidthPx??Mh,p=a.estimatedHeightPx??oo,k=a.minHeightPx??oo,m=Math.max(0,s.width),x=Math.max(0,s.height),N=Math.max(0,x-c*2),C=Math.max(0,m-c*2),R=Yr(Math.max(t.width||h,h),0,C),H=Math.max(t.height||p,p),G=Math.max(0,m-e.x-c),E=Math.max(0,e.x-c),v=G<R&&E>G,_=Math.max(0,x-e.y-i-c),F=Math.max(0,e.y-i-c),Z=_<H&&F>_,z=Yr(Math.max(Z?F:_,k),0,N),Y=Math.min(H,z),O=v?e.x-R:e.x,j=Math.max(c,m-c-R),J=Z?e.y-i-Y:e.y+i,te=Math.max(c,x-c-Y),P=Yr(O,c,j),ue=Yr(J,c,te),K=v||P<e.x?"right":"left";return{top:ue,left:P,width:R,maxHeight:Math.max(0,z),transformOrigin:`${Z?"bottom":"top"} ${K}`}}function Yr(e,t,s){return!Number.isFinite(e)||s<t?t:Math.min(Math.max(e,t),s)}const Vl="workbench.navigation.snapshot",Xl=1800*1e3,Eh="workbench.navigation.snapshot.host.";function Yl(e){return`${Eh}${e}`}function Ah(e=Xl,t=ba(_t.getState())){if(t){const s=ha(Yl(t),e);if(s)return s}return ha(Vl,e)}function Jr(e,t=ba(_t.getState())){ur(Vl,e),t&&ur(Yl(t),e)}function lo(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(s=>({workspace:s.workspace,sessions:xr(s.sessions,t),childWorktrees:Wh(s.childWorktrees,t)}))}function Wh(e,t){return ji(e,t)}function ma(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function Lh(e){const t=new Map;for(const s of e)t.set(s.workspace.id,ma(s.workspace)),Jl(t,s.childWorktrees??[],s.workspace,s.workspace);return Object.fromEntries(t)}function hn(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function Jl(e,t,s,a,i=a.name){var c;for(const h of t){const p=((c=h.meta.displayName)==null?void 0:c.trim())||h.workspace.name;e.set(h.workspace.id,{workspaceId:h.workspace.id,tone:"worktree",backgroundColor:h.workspace.backgroundColor??null,displayName:p,workspaceName:h.workspace.name,branchName:h.meta.branchName||null,depth:h.meta.depth,rootWorkspaceId:s.id,rootDisplayName:s.name,parentWorkspaceId:h.meta.parentWorkspaceId||a.id,parentDisplayName:i}),Jl(e,h.children,s,h.workspace,p)}}const Bh="X-CodingNS-Assistant-Source",Dh="butler-ui",_a=new Map;async function pn(e,t={},s={}){const a=new Headers(t.headers);a.set(Bh,Dh);const i=_h();if(_a.get(i)===!1){if(s.unsupportedFallback!==void 0)return co(s.unsupportedFallback);throw uo()}try{const h=await ne.request(e,{...t,headers:a});return _a.set(i,!0),h}catch(h){if(!Fh(h))throw h;if(_a.set(i,!1),s.unsupportedFallback!==void 0)return co(s.unsupportedFallback);throw uo()}}function _h(){return rl()}function co(e){return typeof e=="function"?e():e}function Fh(e){return e instanceof il&&(e.status===404||e.status===405||e.status===501)}function uo(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function Oh(){return ne.request("/api/butler/profile")}function Fm(e){return ne.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function Om(e){return ne.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function Hm(){return ne.request("/api/butler/control-session")}function $m(){return ne.request("/api/butler/control-sessions")}function Um(e){return ne.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function Gm(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/butler/control-timers?${s}`:"/api/butler/control-timers";return ne.request(a)}function zm(){return ne.request("/api/butler/control-session/reset",{method:"POST"})}function qm(e={}){return ne.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function Km(e){return ne.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function Vm(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/assistant/automations?${s}`:"/api/assistant/automations";return pn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Xm(e={}){var i;const t=new URLSearchParams;(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const s=t.toString(),a=s?`/api/assistant/automations/runs/recent?${s}`:"/api/assistant/automations/runs/recent";return pn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function Ym(e){return pn(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function Jm(e,t){return pn(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Zm(e){return pn(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function Qm(e={}){var i;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.controlSessionId)!=null&&i.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const s=t.toString(),a=s?`/api/assistant/sandboxes?${s}`:"/api/assistant/sandboxes";return pn(a,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function eb(e){return pn(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function tb(e){return pn(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function nb(e){return pn(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function sb(e){return ne.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function rb(){return ne.request("/api/butler/control-session/events")}function Hh(){return ne.request("/api/butler/overview")}function $h(e={}){var i;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const s=t.toString(),a=s?`/api/butler/projects?${s}`:"/api/butler/projects";return ne.request(a)}function ab(e,t={}){const s=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&s.set("enabled",String(t.enabled)),t.executionMode&&s.set("executionMode",t.executionMode);const a=s.toString(),i=a?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${a}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return ne.request(i)}function Zl(e={}){var i,c;const t=new URLSearchParams;(i=e.workspaceId)!=null&&i.trim()&&t.set("workspaceId",e.workspaceId.trim()),(c=e.projectId)!=null&&c.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const s=t.toString(),a=s?`/api/butler/inbox?${s}`:"/api/butler/inbox";return ne.request(a)}function Uh(e){return ne.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function Gh(e={}){var i,c;const t=new URLSearchParams;e.status&&t.set("status",e.status),(i=e.projectId)!=null&&i.trim()&&t.set("projectId",e.projectId.trim()),(c=e.sessionId)!=null&&c.trim()&&t.set("sessionId",e.sessionId.trim());const s=t.toString(),a=s?`/api/butler/follow-up-tasks?${s}`:"/api/butler/follow-up-tasks";return ne.request(a)}function ib(e){return ne.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function ob(e){return ne.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function lb(e){return ne.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function cb(e,t){return ne.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function ho(e,t){return ne.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:t.projectId,itemType:t.itemType,title:t.title,content:t.content,priority:t.priority,status:t.status})})}function db(e){return ne.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function ub(e){return ne.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function zh(e){return ne.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function qh(){return ne.request("/api/butler/notifications/archives")}function Kh(e,t){return ne.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function Vh(e){const t=new URLSearchParams;return t.set("sessionId",e),ne.request(`/api/butler/session-target?${t.toString()}`)}function hb(e){const t=new URLSearchParams;return t.set("sessionId",e),ne.request(`/api/butler/session-action-context?${t.toString()}`)}function pb(e){return ne.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}class ei extends Error{constructor(t,s){super(s),this.code=t,this.name="HostSwitchError"}}class Xh{constructor(){Ne(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const s=this.performSwitch(t).finally(()=>{this.inFlight===s&&(this.inFlight=null)});this.inFlight=s,await s}async performSwitch(t){const s=_t.getState();if(ba(s)===t)return;const a=Dc(s,t);if(!a)throw new ei("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await _c(a.baseUrl)).reachable)throw new ei("HOST_UNREACHABLE",`目标 HOST 不可达:${a.baseUrl}`);const c=ol(a.id);if(c)try{await pr.loginForHost(a,{username:c.username,password:c.password})}catch{}const h=_t.getState(),p=new Date().toISOString();if(ll(a)){_t.updateRuntime({discoveredHosts:h.discoveredHosts.map(k=>k.id===t?{...k,lastConnectedAt:p,updatedAt:p}:k),activeDiscoveredHostId:t});return}qa.setActiveDiscoveredHost(null),await _t.update({hosts:h.hosts.map(k=>k.id===t?{...k,lastConnectedAt:p,updatedAt:p}:k),activeHostId:t})}}const Yh=new Xh;function Jh({open:e,id:t,role:s="dialog",labelledBy:a,className:i,anchorRef:c,popoverRef:h,children:p,maxWidth:k=360,gap:m=10,viewportPadding:x=16}){const[N,C]=o.useState(null);if(o.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){C(null);return}let H=0;const G=()=>{const v=c.current;if(!v)return;const _=v.getBoundingClientRect(),F=Math.max(180,Math.min(k,window.innerWidth-x*2)),Z=Math.min(Math.max(x,_.right-F),Math.max(x,window.innerWidth-x-F)),T=_.top>=Math.min(240,window.innerHeight*.42),z=Math.round(T?_.top-m:_.bottom+m);C({top:z,left:Math.round(Z),width:F,placeAbove:T})},E=()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(G)};return G(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.cancelAnimationFrame(H),window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[c,m,k,e,x]),!e||!N||typeof document>"u")return null;const R={position:"fixed",top:N.top,left:N.left,width:N.width,maxWidth:`calc(100vw - ${x*2}px)`,zIndex:9999,transform:N.placeAbove?"translateY(-100%)":void 0};return gr.createPortal(n.jsx("div",{id:t,ref:h,role:s,"aria-labelledby":a,className:i,"data-placement":N.placeAbove?"top":"bottom",style:R,children:p}),document.body)}const Fa={status:"idle",latencyMs:null};function Ql({collapsed:e=!1}){const[t,s]=o.useState(!1),[a,i]=o.useState(!1),[c,h]=o.useState(""),[p,k]=o.useState(""),[m,x]=o.useState(""),[N,C]=o.useState(""),[R,H]=o.useState(null),[G,E]=o.useState(null),[v,_]=o.useState(null),[F,Z]=o.useState(!1),[T,z]=o.useState(!1),[Y,O]=o.useState(Fa),[j,J]=o.useState(null),te=o.useRef(null),P=o.useRef(null),ue=o.useRef(null),K=o.useRef(null),Q=ri(S=>S),D=al(S=>S.session),{showToast:y}=as(),I=Ka(Q),q=ba(Q),se=zc(),Ce=Fc(q),ie=o.useMemo(()=>po(Q.hosts,q),[q,Q.hosts]),oe=o.useMemo(()=>po(cl(Q),q),[q,Q]),ve=o.useCallback(()=>{if(typeof window>"u")return;const S=te.current;if(!S)return;const B=S.getBoundingClientRect(),L=window.innerWidth,we=window.innerHeight,re=16,Se=8,Ae=Math.min(320,Math.max(240,L-re*2)),$e=Math.min(e?Math.max(re,B.right+Se):Math.max(re,B.left),Math.max(re,L-Ae-re)),Oe=a?440:240,Ft=e?B.top:B.bottom+Se,De=Math.min(Math.max(re,Ft),Math.max(re,we-Oe-re));J({position:"fixed",top:De,left:$e,width:Ae,maxWidth:L-re*2})},[e,a]);o.useEffect(()=>{if(!t){J(null),Z(!1),O(Fa);return}qa.refresh();function S(L){var we,re,Se;L.target instanceof Node&&!((we=te.current)!=null&&we.contains(L.target))&&!((re=P.current)!=null&&re.contains(L.target))&&!((Se=K.current)!=null&&Se.contains(L.target))&&(s(!1),i(!1),Z(!1),_(null))}function B(L){L.key==="Escape"&&(s(!1),i(!1),Z(!1),_(null))}return window.addEventListener("pointerdown",S),window.addEventListener("keydown",B),window.addEventListener("resize",ve),window.addEventListener("scroll",ve,!0),ve(),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",B),window.removeEventListener("resize",ve),window.removeEventListener("scroll",ve,!0)}},[t,ve]),o.useEffect(()=>{if(!F||!t||(se==null?void 0:se.kind)!=="relay"){O(Fa);return}let S=!1;const B=performance.now();return O({status:"probing",latencyMs:null}),ne.request("/api/client/runtime-config").then(()=>{S||O({status:"ready",latencyMs:performance.now()-B})}).catch(()=>{S||O({status:"error",latencyMs:null})}),()=>{S=!0}},[se==null?void 0:se.kind,F,t]);async function ke(S){if(R||G||S.id===q){s(!1);return}H(S.id);try{await Yh.switchHost(S.id),s(!1),i(!1),Z(!1),_(null)}catch(B){y({title:np(B,S.name),tone:"error"})}finally{H(null)}}async function he(S){if(!(S.id===q||R||G)){if(v!==S.id){_(S.id);return}E(S.id);try{await _t.update({hosts:Q.hosts.filter(B=>B.id!==S.id)}),Oc(S.id),pr.clearHostSession(S.id),_(null),y({title:r("shell.hostDeleteSuccess",{name:S.name})})}catch{y({title:r("shell.hostDeleteFailed",{name:S.name}),tone:"error"})}finally{E(null)}}}async function de(){if(T)return;const S=c.trim(),B=m.trim();if((B.length>0||N.length>0)&&(!B||!N)){y({title:r("shell.hostAddIncompleteCredentials"),tone:"error"});return}let we;try{we=Hc(p)}catch{y({title:r("shell.hostAddInvalidUrl"),tone:"error"});return}z(!0);try{const re=await wd(we),Se=_t.getState(),Ke=Ka(Se);if(re?Se.hosts.find(De=>{var Ze;return De.baseUrl===we||!!re.bindingId&&((Ze=De.relayTunnel)==null?void 0:Ze.bindingId)===re.bindingId}):Se.hosts.find(De=>De.baseUrl===we)){y({title:r("shell.hostAddDuplicate"),tone:"error"});return}const $e=ll(Ke)&&Ke.baseUrl===we;$e&&qa.setActiveDiscoveredHost(null);let Oe,Ft;if(re){const Ze=(await _t.update(xd(Se,re,{activate:$e,displayName:S}))).hosts.find(Ue=>ep(Ue,we,re.bindingId??null));if(!Ze)throw new Error("relay entry host missing after save");Oe=Ze.id,Ft=Ze.name}else{const De=new Date().toISOString(),Ze={id:tp(),name:S||Zh(we),baseUrl:we,kind:Qh(we),createdAt:De,updatedAt:De,lastConnectedAt:null,lastUserId:null,lastUsername:null};await _t.update({hosts:[...Se.hosts,Ze],activeHostId:$e?Ze.id:Se.activeHostId}),Oe=Ze.id,Ft=Ze.name}B&&N&&$c({hostId:Oe,username:B,password:N}),ge(),i(!1),_(null),y({title:r("shell.hostAddSuccess",{name:Ft})})}catch{y({title:r("shell.hostAddFailed"),tone:"error"})}finally{z(!1)}}function ge(){h(""),k(""),x(""),C("")}if(!I)return null;const ye=D!=null&&D.user.username?`${I.baseUrl} · ${D.user.username}`:I.baseUrl,V=(se==null?void 0:se.kind)==="relay"?r("shell.hostSwitcherDetailStatusRelay"):r("shell.hostSwitcherDetailStatusDirect"),g=se?r(qc(se.kind)):r("common.unknown");return n.jsxs("div",{ref:te,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[n.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.hostSwitcherAriaLabel"),title:ye,"aria-expanded":t,onClick:()=>{s(S=>!S),i(!1)},children:n.jsx(ap,{})}),t&&j&&typeof document<"u"?gr.createPortal(n.jsxs("div",{ref:P,className:"workbench-host-switcher-menu",style:j,role:"menu","aria-label":r("shell.hostSwitcherTitle"),children:[n.jsx("div",{className:"workbench-host-switcher-menu-header",children:n.jsx("strong",{children:r("shell.hostSwitcherTitle")})}),n.jsxs("div",{className:"workbench-host-switcher-list",children:[n.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherSavedSection")}),ie.map(S=>{const B=S.id===q,L=B?(D==null?void 0:D.user.username)??S.lastUsername??S.baseUrl:S.lastUsername??S.baseUrl;return n.jsxs("div",{className:"workbench-host-switcher-item","data-active":B,children:[n.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:R!==null||G!==null,onClick:()=>{ke(S)},children:[n.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[n.jsxs("span",{className:"workbench-host-switcher-item-title",children:[S.name,B?n.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),n.jsx("span",{className:"workbench-host-switcher-item-meta",children:L})]}),n.jsx("span",{className:"workbench-host-switcher-item-trailing",children:R===S.id?r("shell.hostSwitcherSwitching"):B?n.jsx(mo,{}):n.jsx(fo,{})})]}),B?n.jsx("button",{ref:ue,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:S.name}),"aria-expanded":F,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{Z(we=>!we),_(null)},children:r("shell.hostSwitcherDetailAction")}):n.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostDeleteAriaLabel",{name:S.name}),title:v===S.id?r("shell.hostDeleteConfirmAction"):r("shell.hostDeleteAction"),"data-confirming":v===S.id,disabled:R!==null||G!==null,onClick:()=>{he(S)},children:G===S.id?r("shell.hostDeleteBusy"):v===S.id?r("shell.hostDeleteConfirmAction"):n.jsx(op,{})})]},S.id)}),oe.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-host-switcher-section-label",children:r("shell.hostSwitcherDiscoveredSection")}),oe.map(S=>{const B=S.id===q,L=ol(S.id),we=B?(D==null?void 0:D.user.username)??(L==null?void 0:L.username)??S.baseUrl:(L==null?void 0:L.username)??S.baseUrl;return n.jsxs("div",{className:"workbench-host-switcher-item","data-active":B,"data-discovered":"true",children:[n.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:R!==null||G!==null,onClick:()=>{ke(S)},children:[n.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[n.jsxs("span",{className:"workbench-host-switcher-item-title",children:[S.name,n.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:r("shell.hostSwitcherDiscoveredBadge")}),B?n.jsx("span",{className:"workbench-host-switcher-item-badge",children:r("shell.hostSwitcherCurrentBadge")}):null]}),n.jsx("span",{className:"workbench-host-switcher-item-meta",children:we})]}),n.jsx("span",{className:"workbench-host-switcher-item-trailing",children:R===S.id?r("shell.hostSwitcherSwitching"):B?n.jsx(mo,{}):n.jsx(fo,{})})]}),B?n.jsx("button",{ref:ue,type:"button",className:"workbench-host-switcher-item-action","aria-label":r("shell.hostSwitcherDetailAriaLabel",{name:S.name}),"aria-expanded":F,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{Z(re=>!re),_(null)},children:r("shell.hostSwitcherDetailAction")}):null]},S.id)})]}):null,Q.localHostDiscovery.status==="refreshing"?n.jsx("div",{className:"workbench-host-switcher-state-row",children:r("shell.hostDiscoveryRefreshing")}):null,Q.localHostDiscovery.status==="failed"?n.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:r("shell.hostDiscoveryFailed")}):null]}),a?n.jsxs("div",{className:"workbench-host-switcher-form",children:[n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("shell.hostSwitcherNameLabel")}),n.jsx("input",{value:c,disabled:T,onChange:S=>h(S.target.value),placeholder:r("shell.hostSwitcherNamePlaceholder")})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("shell.hostSwitcherUrlLabel")}),n.jsx("input",{value:p,disabled:T,onChange:S=>k(S.target.value),placeholder:r("shell.hostSwitcherUrlPlaceholder")})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("auth.username")}),n.jsx("input",{value:m,disabled:T,onChange:S=>x(S.target.value),autoComplete:"username"})]}),n.jsxs("label",{className:"workbench-host-switcher-field",children:[n.jsx("span",{children:r("auth.password")}),n.jsx("input",{type:"password",value:N,disabled:T,onChange:S=>C(S.target.value),autoComplete:"current-password"})]}),n.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:T,onClick:()=>{i(!1),ge()},children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:T,onClick:()=>{de()},children:T?r("common.loading"):r("shell.hostSwitcherSaveAction")})]})]}):n.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{i(!0),_(null)},children:[n.jsx(ip,{}),r("shell.hostSwitcherAddAction")]}),n.jsxs(Jh,{open:F&&se!==null&&ue.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:ue,popoverRef:K,labelledBy:"workbench-host-switcher-detail-title",children:[n.jsx("div",{className:"workbench-host-switcher-detail-header",children:n.jsx("strong",{id:"workbench-host-switcher-detail-title",children:r("shell.hostSwitcherDetailTitle")})}),n.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailStatusLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:V})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailRouteLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:g})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailAddressLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(se==null?void 0:se.url)??I.baseUrl})]}),(se==null?void 0:se.kind)==="relay"?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailLatencyLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:sp(Y)})]}),n.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[n.jsx("span",{className:"workbench-host-switcher-detail-label",children:r("shell.hostSwitcherDetailTrafficLabel")}),n.jsx("span",{className:"workbench-host-switcher-detail-value",children:rp(Ce.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function po(e,t){return[...e].sort((s,a)=>{if(s.id===t)return-1;if(a.id===t)return 1;const i=s.lastConnectedAt??s.updatedAt??s.createdAt;return(a.lastConnectedAt??a.updatedAt??a.createdAt).localeCompare(i)})}function Zh(e){try{const t=new URL(e),s=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${s}`}catch{return e}}function Qh(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function ep(e,t,s){var a;return!!(e.baseUrl===t||s&&((a=e.relayTunnel)==null?void 0:a.bindingId)===s)}function tp(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function np(e,t){return e instanceof ei?e.code==="HOST_UNREACHABLE"?r("shell.hostSwitchUnreachable",{name:t}):r("shell.hostSwitchMissing"):r("shell.hostSwitchFailed")}function sp(e){return e.status==="probing"?r("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?r("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:r("shell.hostSwitcherDetailUnavailable")}function rp(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function ap(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[n.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function fo(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function mo(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function ip(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function op(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const Zr={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function lp({open:e,onClose:t,onCloned:s}){const{showToast:a}=as(),[i,c]=o.useState(!1),[h,p]=o.useState(Zr),[k,m]=o.useState(!1),[x,N]=o.useState(!1),[C,R]=o.useState(null),[H,G]=o.useState(""),[E,v]=o.useState(""),[_,F]=o.useState(null),[Z,T]=o.useState([]),[z,Y]=o.useState([]),O=i||x;o.useEffect(()=>{!e&&!i&&(p(Zr),m(!1),R(null))},[i,e]);const j=o.useCallback(async D=>{N(!0),R(null);try{const y=await dl(D);G(y.currentPath),v(y.currentPath),F(y.parentPath),T(y.roots),Y(y.items),p(I=>({...I,parentPath:y.currentPath}))}catch(y){G(""),F(null),Y([]),R(y instanceof Error?y.message:r("shell.importBrowserBrowseFailed"))}finally{N(!1)}},[]);function J(){i||(m(!1),R(null),p(Zr),t())}function te(){m(!0),j(h.parentPath||void 0)}function P(){i||(m(!1),R(null))}async function ue(D){D.preventDefault(),await j(E)}function K(){p(D=>({...D,parentPath:H})),m(!1),R(null)}async function Q(D){D.preventDefault();const y=h.repositoryUrl.trim(),I=h.parentPath.trim();if(!y){a({title:r("shell.cloneRepoRequired"),tone:"error"});return}if(!I){a({title:r("shell.clonePathRequired"),tone:"error"});return}c(!0);try{const q=await Kc({repositoryUrl:y,parentPath:I,directoryName:h.directoryName.trim()||void 0,name:h.name.trim()||void 0,auth:h.authMode==="none"?{mode:"none"}:h.authMode==="basic"?{mode:"basic",username:h.username.trim(),password:h.password}:{mode:"token",username:h.username.trim()||void 0,token:h.token}});await(s==null?void 0:s(q)),p(Zr),m(!1),a({title:r("shell.cloneSuccess"),description:q.path,tone:"success"}),t()}catch(q){a({title:q instanceof Error?q.message:r("shell.cloneFailed"),tone:"error"})}finally{c(!1)}}return n.jsxs(n.Fragment,{children:[n.jsx(Ye,{open:e,title:r("shell.cloneWorkspaceTitle"),description:r("shell.cloneWorkspaceHint"),onClose:J,children:n.jsxs("form",{className:"workbench-clone-form",onSubmit:D=>void Q(D),children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneRepositoryLabel")}),n.jsx("input",{type:"text",value:h.repositoryUrl,placeholder:r("shell.cloneRepositoryPlaceholder"),onChange:D=>p(y=>({...y,repositoryUrl:D.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneParentPathLabel")}),n.jsxs("div",{className:"workbench-modal-inline-field",children:[n.jsx("input",{type:"text",value:h.parentPath,placeholder:r("shell.cloneParentPathPlaceholder"),onChange:D=>p(y=>({...y,parentPath:D.target.value}))}),n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:te,children:r("shell.clonePickDirectory")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneDirectoryNameLabel")}),n.jsx("input",{type:"text",value:h.directoryName,placeholder:r("shell.cloneDirectoryNamePlaceholder"),onChange:D=>p(y=>({...y,directoryName:D.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importNameLabel")}),n.jsx("input",{type:"text",value:h.name,placeholder:r("shell.importNamePlaceholder"),onChange:D=>p(y=>({...y,name:D.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneAuthModeLabel")}),n.jsxs("select",{value:h.authMode,onChange:D=>p(y=>({...y,authMode:D.target.value})),children:[n.jsx("option",{value:"none",children:r("shell.cloneAuthModeNone")}),n.jsx("option",{value:"basic",children:r("shell.cloneAuthModeBasic")}),n.jsx("option",{value:"token",children:r("shell.cloneAuthModeToken")})]})]}),h.authMode==="basic"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:D=>p(y=>({...y,username:D.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.clonePasswordLabel")}),n.jsx("input",{type:"password",value:h.password,placeholder:r("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:D=>p(y=>({...y,password:D.target.value}))})]})]}):null,h.authMode==="token"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneUsernameLabel")}),n.jsx("input",{type:"text",value:h.username,placeholder:r("shell.cloneTokenUsernamePlaceholder"),onChange:D=>p(y=>({...y,username:D.target.value}))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.cloneTokenLabel")}),n.jsx("input",{type:"password",value:h.token,placeholder:r("shell.cloneTokenPlaceholder"),onChange:D=>p(y=>({...y,token:D.target.value}))})]})]}):null,n.jsx("p",{className:"workbench-import-hint",children:r("shell.cloneHint")}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:J,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:i,children:i?r("shell.cloneSubmitting"):r("shell.cloneSubmit")})]})]})}),n.jsxs(Ye,{open:e&&k,title:r("shell.cloneBrowserTitle"),description:r("shell.cloneBrowserDescription"),onClose:P,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ue,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:E,placeholder:r("shell.importPathPlaceholder"),onChange:D=>v(D.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:O||!_,onClick:()=>{_&&j(_)},children:r("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:O,children:r("shell.importBrowserOpenPath")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:Z.map(D=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:O,onClick:()=>{j(D.path)},children:D.name},D.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:H}),C?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:C}):null,x?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):z.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:z.map(D=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:O,onClick:()=>{j(D.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:D.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:D.path})]},D.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:i,onClick:P,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:O||!H,onClick:K,children:r("shell.cloneBrowserSubmit")})]})]})]})}const cp="butler:inbox-updated";function Oa(){typeof window>"u"||window.dispatchEvent(new Event(cp))}const bo={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function ec({active:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:a=0,initialDraft:i=null,compactComposer:c=!1,composerOpen:h=!0,onComposerOpenChange:p}){const{showToast:k}=as(),[m,x]=o.useState(!1),[N,C]=o.useState(!1),[R,H]=o.useState([]),[G,E]=o.useState([]),[v,_]=o.useState(null),[F,Z]=o.useState(null),[T,z]=o.useState(bo),[Y,O]=o.useState(!1),j=o.useMemo(()=>ko(R,t,F),[F,t,R]),J=o.useMemo(()=>Y?G:G.filter(y=>y.status!=="closed"),[G,Y]);o.useEffect(()=>{e&&te()},[e,s]),o.useEffect(()=>{!e||v||z(y=>{const I=xo({projects:j,currentProjectId:y.projectId,preferredProjectId:F,preferredWorkspaceId:t});return I===y.projectId?y:{...y,projectId:I}})},[e,v,F,t,j]),o.useEffect(()=>{!e||a<=0||(P(void 0,t,i,F),p==null||p(!0))},[e,a,i,p,F,t]);async function te(){x(!0);try{const[y,I,q]=await Promise.all([$h(),Zl(),s?Vh(s).catch(()=>null):Promise.resolve(null)]),se=(q==null?void 0:q.target.project.id)??null;Z(se),H(y.items),E(I.items),v||P(y.items,t,a>0?i:null,se)}catch(y){k({title:r("shell.butlerInboxLoadFailed"),description:y instanceof Error?y.message:void 0,tone:"error"})}finally{x(!1)}}function P(y=R,I=t,q=i,se=F){var ie,oe;const Ce=ko(y,I,se);_(null),z({...bo,projectId:xo({projects:Ce,preferredProjectId:se,preferredWorkspaceId:I}),title:((ie=q==null?void 0:q.title)==null?void 0:ie.trim())??"",content:((oe=q==null?void 0:q.content)==null?void 0:oe.trim())??""})}function ue(y){_(y.id),z({projectId:y.projectId,itemType:y.itemType,title:y.title,content:y.content,status:y.status}),c&&(p==null||p(!0))}async function K(y){y.preventDefault(),C(!0);try{v?(await ho(v,{projectId:T.projectId,itemType:T.itemType,title:T.title,content:T.content,status:T.status,priority:"medium"}),k({title:r("shell.butlerInboxUpdated"),tone:"success"})):(await Uh({projectId:T.projectId,itemType:T.itemType,title:T.title,content:T.content,status:T.status,priority:"medium"}),k({title:r("shell.butlerInboxCreated"),tone:"success"})),Oa(),await te(),P(),c&&(p==null||p(!1))}catch(I){k({title:r("shell.butlerInboxSaveFailed"),description:I instanceof Error?I.message:void 0,tone:"error"})}finally{C(!1)}}async function Q(y){C(!0);try{await zh(y),k({title:r("shell.butlerInboxDeleted"),tone:"success"}),Oa(),await te(),v===y&&P()}catch(I){k({title:r("shell.butlerInboxDeleteFailed"),description:I instanceof Error?I.message:void 0,tone:"error"})}finally{C(!1)}}async function D(y,I){if(y.status!==I){C(!0);try{await ho(y.id,{status:I}),k({title:r("shell.butlerInboxUpdated"),tone:"success"}),Oa(),await te(),v===y.id&&z(q=>({...q,status:I}))}catch(q){k({title:r("shell.butlerInboxSaveFailed"),description:q instanceof Error?q.message:void 0,tone:"error"})}finally{C(!1)}}}return n.jsxs("div",{className:"workspace-inbox-modal",children:[c?null:n.jsx("section",{className:"workspace-inbox-panel",children:n.jsx(go,{selectableProjects:j,formState:T,saving:N,editingItemId:v,useMobilePicker:!1,onProjectChange:y=>{z(I=>({...I,projectId:y}))},onItemTypeChange:y=>{z(I=>({...I,itemType:y}))},onStatusChange:y=>{z(I=>({...I,status:y}))},onTitleChange:y=>{z(I=>({...I,title:y}))},onContentChange:y=>{z(I=>({...I,content:y}))},onCancel:()=>P(),onSubmit:K})}),n.jsxs("section",{className:"workspace-inbox-panel",children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsxs("div",{children:[n.jsx("h3",{children:r("shell.butlerInboxListTitle")}),n.jsx("p",{children:r("shell.butlerInboxListDescription")})]}),n.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[n.jsx("input",{type:"checkbox",checked:Y,onChange:y=>O(y.target.checked)}),n.jsx("span",{children:r("shell.butlerInboxShowClosedAction")})]})]}),m?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxLoading")}):null,!m&&J.length===0?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxEmpty")}):null,!m&&J.length>0?n.jsx("div",{className:"workspace-inbox-list",children:J.map(y=>n.jsxs("article",{className:"workspace-inbox-item",children:[n.jsxs("div",{className:"workspace-inbox-item-header",children:[n.jsxs("div",{children:[n.jsx("strong",{children:y.title}),n.jsx("p",{children:y.projectName})]}),n.jsxs("div",{className:"workspace-inbox-item-badges",children:[n.jsx("span",{className:"workspace-inbox-badge",children:vo(y.status)}),n.jsx("span",{className:"workspace-inbox-badge",children:fp(y.itemType)})]})]}),n.jsx("p",{className:"workspace-inbox-item-content",children:y.content}),n.jsxs("div",{className:"workspace-inbox-item-footer",children:[n.jsx("span",{children:mp(y.updatedAt)}),n.jsxs("div",{className:"workspace-inbox-item-actions",children:[n.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":r("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(I=>{const q=y.status===I;return n.jsx("button",{type:"button",className:"secondary-button","data-active":q,disabled:N,onClick:()=>{D(y,I)},children:vo(I)},`${y.id}:${I}`)})}),n.jsx("button",{type:"button",className:"secondary-button",disabled:N,onClick:()=>ue(y),children:r("shell.butlerInboxEditAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:N,onClick:()=>{Q(y.id)},children:r("shell.butlerInboxDeleteAction")})]})]})]},y.id))}):null]}),c?n.jsx(Ye,{open:e&&h,title:v?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle"),description:r("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{p==null||p(!1),P()},children:n.jsx("div",{className:"workspace-inbox-composer-modal-body",children:n.jsx(go,{selectableProjects:j,formState:T,saving:N,editingItemId:v,useMobilePicker:!0,onProjectChange:y=>{z(I=>({...I,projectId:y}))},onItemTypeChange:y=>{z(I=>({...I,itemType:y}))},onStatusChange:y=>{z(I=>({...I,status:y}))},onTitleChange:y=>{z(I=>({...I,title:y}))},onContentChange:y=>{z(I=>({...I,content:y}))},onCancel:()=>{p==null||p(!1),P()},onSubmit:K})})}):null]})}function go(e){const t=e.selectableProjects.map(i=>({value:i.id,label:i.name})),s=[{value:"task",label:r("shell.butlerInboxTypeTask")},{value:"bug",label:r("shell.butlerInboxTypeBug")},{value:"feature",label:r("shell.butlerInboxTypeFeature")},{value:"change",label:r("shell.butlerInboxTypeChange")}],a=[{value:"pending",label:r("shell.butlerInboxStatusPending")},{value:"in_progress",label:r("shell.butlerInboxStatusInProgress")},{value:"closed",label:r("shell.butlerInboxStatusClosed")}];return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"workspace-inbox-panel-header",children:[n.jsx("h3",{children:e.editingItemId?r("shell.butlerInboxEditingTitle"):r("shell.butlerInboxCreateTitle")}),n.jsx("p",{children:r("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?n.jsx("p",{className:"workspace-inbox-status",children:r("shell.butlerInboxProjectsEmpty")}):n.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[n.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?n.jsxs(n.Fragment,{children:[n.jsx(Ha,{label:r("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),n.jsx(Ha,{label:r("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:s,disabled:e.saving,onChange:e.onItemTypeChange}),n.jsx(Ha,{label:r("shell.butlerInboxStatusLabel"),value:e.formState.status,options:a,disabled:e.saving,onChange:e.onStatusChange})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxProjectLabel")}),n.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:i=>e.onProjectChange(i.target.value),children:e.selectableProjects.map(i=>n.jsx("option",{value:i.id,children:i.name},i.id))})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxTypeLabel")}),n.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:i=>e.onItemTypeChange(i.target.value),children:[n.jsx("option",{value:"task",children:r("shell.butlerInboxTypeTask")}),n.jsx("option",{value:"bug",children:r("shell.butlerInboxTypeBug")}),n.jsx("option",{value:"feature",children:r("shell.butlerInboxTypeFeature")}),n.jsx("option",{value:"change",children:r("shell.butlerInboxTypeChange")})]})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxStatusLabel")}),n.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:i=>e.onStatusChange(i.target.value),children:[n.jsx("option",{value:"pending",children:r("shell.butlerInboxStatusPending")}),n.jsx("option",{value:"in_progress",children:r("shell.butlerInboxStatusInProgress")}),n.jsx("option",{value:"closed",children:r("shell.butlerInboxStatusClosed")})]})]})]})}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxTitleLabel")}),n.jsx("input",{value:e.formState.title,placeholder:r("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:i=>e.onTitleChange(i.target.value)})]}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.butlerInboxContentLabel")}),n.jsx("textarea",{rows:4,value:e.formState.content,placeholder:r("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:i=>e.onContentChange(i.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?r("shell.butlerInboxCancelEditAction"):r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?r("shell.butlerInboxUpdateAction"):r("shell.butlerInboxCreateAction")})]})]})]})}function Ha({label:e,value:t,options:s,disabled:a,onChange:i}){const[c,h]=o.useState(!1),p=s.find(k=>k.value===t)??s[0]??null;return o.useEffect(()=>{if(!c)return;function k(m){m.key==="Escape"&&h(!1)}return window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}},[c]),n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[n.jsx("span",{children:e}),n.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":c,disabled:a||s.length===0,onClick:()=>h(!0),children:[n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(p==null?void 0:p.label)??""}),n.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:n.jsx(hp,{expanded:c})})]})]}),n.jsx(dp,{open:c,title:e,options:s,selectedValue:t,onClose:()=>h(!1),onSelect:k=>{i(k),h(!1)}})]})}function dp({open:e,title:t,options:s,selectedValue:a,onClose:i,onSelect:c}){return e?n.jsx(Vc,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:i,children:n.jsx(Xc,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:s.map(h=>{const p=h.value===a;return n.jsx(Yc,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":p,selected:p,trailing:n.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:p?n.jsx(pp,{}):null}),onClick:()=>c(h.value),children:n.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[n.jsx("strong",{children:h.label}),h.description?n.jsx("span",{children:h.description}):null]})},h.value)})})}):null}function fb({open:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:a=0,initialDraft:i=null,onClose:c,compactComposer:h=!1}){const[p,k]=o.useState(0),[m,x]=o.useState(!h);return o.useEffect(()=>{e||x(!h)},[h,e]),n.jsx(Ye,{open:e,title:r("shell.butlerInboxModalTitle"),description:r("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!h,headerActions:h?n.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":r("shell.butlerInboxCreateAction"),title:r("shell.butlerInboxCreateAction"),onClick:()=>{k(N=>N+1),x(!0)},children:n.jsx(up,{})}):void 0,onClose:c,children:n.jsx(ec,{active:e,preferredWorkspaceId:t,preferredSessionId:s,creationRequestId:Math.max(a,p),initialDraft:i,compactComposer:h,composerOpen:m,onComposerOpenChange:x})})}function ko(e,t,s){return[...e].filter(a=>a.lifecycleStatus!=="archived").sort((a,i)=>{const c=wo(a,t,s),h=wo(i,t,s);return c!==h?h-c:a.name.localeCompare(i.name,"zh-Hans-CN")})}function wo(e,t,s){return s&&e.id===s?2:t&&e.workspaceId===t?1:0}function xo({projects:e,currentProjectId:t,preferredProjectId:s,preferredWorkspaceId:a}){var c;if(t&&e.some(h=>h.id===t))return t;if(s&&e.some(h=>h.id===s))return s;const i=a?e.find(h=>h.workspaceId===a):null;return(i==null?void 0:i.id)||((c=e[0])==null?void 0:c.id)||""}function up(){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[n.jsx("path",{d:"M12 5v14"}),n.jsx("path",{d:"M5 12h14"})]})}function hp({expanded:e}){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:n.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function pp(){return n.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:n.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function fp(e){switch(e){case"bug":return r("shell.butlerInboxTypeBug");case"feature":return r("shell.butlerInboxTypeFeature");case"change":return r("shell.butlerInboxTypeChange");case"task":default:return r("shell.butlerInboxTypeTask")}}function vo(e){switch(e){case"in_progress":return r("shell.butlerInboxStatusInProgress");case"closed":return r("shell.butlerInboxStatusClosed");case"pending":default:return r("shell.butlerInboxStatusPending")}}function mp(e){return new Date(e).toLocaleString()}function bp({open:e,onClose:t,onImported:s}){const{showToast:a}=as(),[i,c]=o.useState(!1),[h,p]=o.useState(!1),[k,m]=o.useState(!1),[x,N]=o.useState(null),[C,R]=o.useState(""),[H,G]=o.useState(""),[E,v]=o.useState(null),[_,F]=o.useState([]),[Z,T]=o.useState([]),[z,Y]=o.useState(!1),[O,j]=o.useState(""),J=i||h||k,te=o.useCallback(async I=>{c(!0),N(null);try{const q=await dl(I);R(q.currentPath),G(q.currentPath),v(q.parentPath),F(q.roots),T(q.items)}catch(q){R(""),v(null),T([]),N(q instanceof Error?q.message:r("shell.importBrowserBrowseFailed"))}finally{c(!1)}},[]);o.useEffect(()=>{if(!e){Y(!1),j(""),N(null);return}te(C||void 0)},[te,e]);function P(){J||(Y(!1),j(""),t())}async function ue(I){I.preventDefault(),await te(H)}function K(){!C||J||(j(""),Y(!0))}function Q(){h||(Y(!1),j(""))}async function D(I){I==null||I.preventDefault();const q=O.trim();if(!(!C||!q||J)){p(!0),N(null);try{const se=await Zc({parentPath:C,directoryName:q});a({title:r("shell.importBrowserCreateDirectorySuccess"),description:se.path,tone:"success"}),Y(!1),j(""),await te(se.path)}catch(se){const Ce=se instanceof Error?se.message:r("shell.importBrowserCreateDirectoryFailed");N(Ce),a({title:Ce,tone:"error"})}finally{p(!1)}}}async function y(){const I=C.trim();if(!(!I||J)){m(!0),N(null);try{const q=await Jc({path:I});a({title:r("shell.importSuccess"),description:q.path,tone:"success"}),t(),Promise.resolve().then(()=>s==null?void 0:s(q)).catch(se=>{a({title:se instanceof Error?se.message:r("shell.navigationLoadFailed"),tone:"error"})})}catch(q){a({title:q instanceof Error?q.message:r("shell.importFailed"),tone:"error"})}finally{m(!1)}}}return n.jsxs(n.Fragment,{children:[n.jsxs(Ye,{open:e,title:r("shell.importBrowserTitle"),description:r("shell.importBrowserDescription"),onClose:P,children:[n.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:ue,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCurrentPath")}),n.jsx("input",{type:"text",value:H,placeholder:r("shell.importPathPlaceholder"),onChange:I=>G(I.target.value)})]}),n.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:J||!E,onClick:()=>{E&&te(E)},children:r("shell.importBrowserOpenParent")}),n.jsx("button",{type:"submit",className:"secondary-button",disabled:J,children:r("shell.importBrowserOpenPath")}),n.jsx("button",{type:"button",className:"secondary-button",disabled:J||!C,onClick:K,children:r("shell.importBrowserCreateDirectory")})]})]}),n.jsxs("section",{className:"workbench-directory-browser-panel",children:[n.jsxs("div",{className:"workbench-directory-browser-section",children:[n.jsx("span",{className:"workbench-directory-browser-section-title",children:r("shell.importBrowserRoots")}),n.jsx("div",{className:"workbench-directory-browser-root-list",children:_.map(I=>n.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:J,onClick:()=>{te(I.path)},children:I.name},I.path))})]}),n.jsx("div",{className:"workbench-directory-browser-current-path",children:C}),x?n.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:x}):null,i?n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("common.loading")}):Z.length>0?n.jsx("div",{className:"workbench-directory-browser-list",children:Z.map(I=>n.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:J,onClick:()=>{te(I.path)},children:[n.jsx("span",{className:"workbench-directory-browser-item-name",children:I.name}),n.jsx("span",{className:"workbench-directory-browser-item-path",children:I.path})]},I.path))}):n.jsx("p",{className:"workbench-directory-browser-status status-text",children:r("shell.importBrowserEmpty")})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:J,onClick:P,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:J||!C,onClick:()=>{y()},children:k?r("shell.importSubmitting"):r("shell.importBrowserSubmit")})]})]}),n.jsx(Ye,{open:e&&z,title:r("shell.importBrowserCreateDirectoryTitle"),description:r("shell.importBrowserCreateDirectoryDescription"),onClose:Q,children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:I=>void D(I),children:[n.jsx("div",{className:"workbench-directory-browser-current-path",children:C}),n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.importBrowserCreateDirectoryLabel")}),n.jsx("input",{type:"text",value:O,placeholder:r("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:I=>j(I.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:h,onClick:Q,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:h||!O.trim(),children:h?r("shell.importBrowserCreatingDirectory"):r("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function gp({onOpenSoftwareUpdate:e}){var a;const t=ri(i=>i.platform),s=Uc(i=>i.latestState);return t!=="desktop"||!(s!=null&&s.hasUpdate)?null:n.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((a=s.manifest)==null?void 0:a.version)??r("settings.releaseUpdateReady"),onClick:e,children:n.jsx("span",{className:"workbench-nav-update-badge-label",children:r("settings.releaseUpdateBadge")})})}function tc(e){return{provider:e,model:"",memberPrompt:"",workspaceIsolationMode:"none"}}function yo(e,t){return Array.from({length:t},()=>tc(e))}function kp(e,t){var s;return(s=e==null?void 0:e.modelOptions)!=null&&s.length?e.modelOptions:da(t).modelOptions??[]}function So(e,t){return Math.max(0,e-t.length)}function wp({open:e,source:t,onClose:s,onCreated:a}){const i=o.useId(),c=(t==null?void 0:t.defaultProvider)??"codex",h=(t==null?void 0:t.kind)==="group",p=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,k=o.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:p},(V,g)=>g+1):[2,3,4],[p,t==null?void 0:t.kind]),m=(t==null?void 0:t.kind)==="group"?1:2,x=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",[N,C]=o.useState(x),[R,H]=o.useState(m),[G,E]=o.useState(()=>yo(c,m)),[v,_]=o.useState({}),[F,Z]=o.useState(!1),[T,z]=o.useState(!1),[Y,O]=o.useState(null),[j,J]=o.useState(null),[te,P]=o.useState({});o.useEffect(()=>{if(!e)return;const V=(t==null?void 0:t.defaultProvider)??"codex",g=(t==null?void 0:t.kind)==="group"?1:2;C((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),H(g),E(yo(V,g)),_({}),Z(!1),z(!1),O(null),J(null),P({})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),o.useEffect(()=>{E(V=>{var B;if(V.length===R)return V;if(V.length>R)return V.slice(0,R);const g=V.slice(),S=((B=V[0])==null?void 0:B.provider)??c;for(;g.length<R;)g.push(tc(S));return g})},[c,R]),o.useEffect(()=>{k.length!==0&&H(V=>k.includes(V)?V:k[0]??V)},[k]),o.useEffect(()=>{if(!e||!t)return;let V=!1;return Z(!0),Qc(Pi,t.workspaceId).then(g=>{V||_(g)}).finally(()=>{V||Z(!1)}),()=>{V=!0}},[e,t==null?void 0:t.workspaceId]);const ue=o.useMemo(()=>Pi.filter(V=>{const g=v[V];return g?g.canStartSession!==!1:!1}),[v]);o.useEffect(()=>{if(!ue.length)return;const V=ue.includes(c)?c:ue[0];E(g=>{let S=!1;const B=g.map(L=>ue.includes(L.provider)?L:(S=!0,{...L,provider:V,model:""}));return S?B:g})},[ue,c]);const K=o.useMemo(()=>G.map((V,g)=>{const S=v[V.provider]??null,B=kp(S,V.provider);return{index:g,draft:V,modelOptions:B}}),[G,v]);if(!e||!t)return null;const Q=t,D=j?So(G.length,j.memberFailures):0,y=new Set(j?G.map((V,g)=>g).filter(V=>!(V in te)):[]),I=Q.kind==="group"?r("shell.parallelAppendModalTitle"):r("shell.parallelCreateModalTitle"),q=Q.kind==="session"?`${Q.workspaceName} · ${Q.sessionTitle}`:Q.workspaceName,se=Q.kind==="group"?r("shell.parallelAppendSharedPromptLabel"):r("shell.parallelCreateSharedPromptLabel"),Ce=Q.kind==="group"?r("shell.parallelAppendCountLabel"):r("shell.parallelCreateCountLabel"),ie=Q.kind==="group"?r("shell.parallelAppendSubmit"):r("shell.parallelCreateSubmit"),oe=Q.kind==="group"?r("shell.parallelAppendSubmitting"):r("shell.parallelCreateSubmitting"),ve=Y??(Q.kind==="group"&&p===0?r("shell.parallelAppendNoRemainingSlots"):null)??(!F&&ue.length===0?r("shell.parallelCreateNoAvailableProviders"):null),ke={"--parallel-member-columns":String(Math.max(1,Math.min(R,4)))};function he(V){O(null),J(null),P(g=>{if(!(V in g))return g;const S={...g};return delete S[V],S})}function de(){O(null),J(null),P({})}function ge(V,g){he(V);const S=g?"temporary_worktree":"none";E(B=>B.map((L,we)=>we===V?{...L,workspaceIsolationMode:S}:L))}async function ye(){const V=N.trim();if(!h&&!V){O(r("shell.parallelCreatePromptRequired"));return}if(Q.kind==="group"&&p===0){O(r("shell.parallelAppendNoRemainingSlots"));return}if(!ue.length){O(r("shell.parallelCreateNoAvailableProviders"));return}z(!0),O(null),J(null),P({});try{const g=G.map(B=>({provider:B.provider,model:B.model.trim()||null,memberPrompt:B.memberPrompt.trim()||null,workspaceIsolationMode:B.workspaceIsolationMode})),S=Q.kind==="group"?await td(Q.groupId,{members:g}):Q.kind==="session"?await nd(Q.sessionId,{sharedPrompt:V,members:g}):await sd(Q.workspaceId,{sharedPrompt:V,members:g});if(S.memberFailures.length>0){const B=So(G.length,S.memberFailures);J(S),P(Object.fromEntries(S.memberFailures.map(L=>[L.ordinal,L]))),O(B>0?r("shell.parallelCreatePartialFailure",{successCount:B,failureCount:S.memberFailures.length}):r("shell.parallelCreateAllFailed",{failureCount:S.memberFailures.length}));return}await a(S)}catch(g){O(g instanceof Error?g.message:r("shell.parallelGroupLoadFailed"))}finally{z(!1)}}return n.jsx(kd,{open:e,title:I,description:q,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!T,onClose:s,footer:n.jsxs(ed,{align:"between",className:"parallel-create-modal-footer",children:[n.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:ve?n.jsx("span",{className:"parallel-create-modal-error",children:ve}):null}),n.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[j&&D>0?n.jsx("button",{type:"button",className:"secondary-button",disabled:T,onClick:()=>{a(j)},children:r("shell.parallelCreateContinuePartial")}):null,n.jsx("button",{type:"button",className:"secondary-button",disabled:T,onClick:s,children:r("common.cancel")}),n.jsx("button",{type:"button",className:"primary-button",disabled:T||F||ue.length===0||Q.kind==="group"&&p===0,onClick:()=>{ye()},children:T?oe:ie})]})]}),children:n.jsxs("div",{className:"parallel-create-layout",children:[n.jsx(Ei,{className:"parallel-create-shared-section",tone:"accent",children:n.jsxs("div",{className:"parallel-create-target-row",children:[n.jsx(sr,{className:"parallel-create-target-field",label:se,htmlFor:`${i}-shared-prompt`,children:n.jsx("textarea",{id:`${i}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:N,readOnly:h,"aria-readonly":h,"data-readonly":h?"true":void 0,onChange:V=>{h||(de(),C(V.target.value))}})}),n.jsx(sr,{className:"parallel-create-count-field",label:Ce,children:n.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":Ce,children:k.map(V=>n.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":R===V,onClick:()=>{de(),H(V)},children:V},V))})})]})}),n.jsx(Ei,{className:"parallel-create-members-section",heading:r("shell.parallelCreateMembersTitle"),children:n.jsx("div",{className:"parallel-create-member-list",style:ke,children:K.map(({draft:V,index:g,modelOptions:S})=>{var we;const B=ue,L=B.includes(V.provider)?V.provider:"";return n.jsxs("article",{className:"parallel-create-member-card","data-state":te[g]?"error":y.has(g)?"success":void 0,children:[n.jsxs("header",{className:"parallel-create-member-header",children:[n.jsxs("div",{className:"parallel-create-member-title-block",children:[n.jsx("strong",{children:r("shell.parallelCreateMemberTitle",{index:g+1})}),n.jsx("span",{className:"parallel-create-member-provider",children:Va(V.provider,"full")}),n.jsxs("label",{className:"parallel-create-isolation-toggle",children:[n.jsx("input",{type:"checkbox",checked:V.workspaceIsolationMode==="temporary_worktree",onChange:re=>{ge(g,re.target.checked)}}),n.jsx("span",{className:"parallel-create-isolation-copy",children:r("shell.parallelCreateIsolationLabel")})]})]}),te[g]?n.jsx("span",{className:"parallel-create-member-status error",children:r("shell.parallelCreateMemberFailed")}):y.has(g)?n.jsx("span",{className:"parallel-create-member-status success",children:r("shell.parallelCreateMemberSucceeded")}):null]}),n.jsxs("div",{className:"parallel-create-member-grid",children:[n.jsx(sr,{label:r("shell.createSessionProviderLabel"),htmlFor:`${i}-member-${g}-provider`,children:n.jsx("select",{id:`${i}-member-${g}-provider`,className:"parallel-create-select",value:L,disabled:!B.length,onChange:re=>{he(g);const Se=re.target.value;E(Ke=>Ke.map((Ae,$e)=>$e===g?{...Ae,provider:Se,model:""}:Ae))},children:B.length>0?B.map(re=>n.jsx("option",{value:re,children:Va(re,"full")},re)):n.jsx("option",{value:"",disabled:!0,children:F?r("shell.parallelCreateProvidersLoading"):r("shell.parallelCreateNoAvailableProviders")})})}),n.jsx(sr,{label:r("shell.parallelCreateModelLabel"),htmlFor:`${i}-member-${g}-model`,children:n.jsx("select",{id:`${i}-member-${g}-model`,className:"parallel-create-select",value:V.model,disabled:!B.length,onChange:re=>{he(g);const Se=re.target.value;E(Ke=>Ke.map((Ae,$e)=>$e===g?{...Ae,model:Se}:Ae))},children:S.length>0?n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"",children:((we=S.find(re=>re.usesProviderDefault===!0))==null?void 0:we.name)??r("shell.parallelPaneModelFallback")}),S.filter(re=>re.usesProviderDefault!==!0).map(re=>n.jsx("option",{value:re.id,children:re.name},re.id))]}):n.jsx("option",{value:"",children:r("shell.parallelCreateNoModelsAvailable")})})})]}),n.jsx(sr,{label:r("shell.parallelCreateMemberPromptLabel"),htmlFor:`${i}-member-${g}-prompt`,children:n.jsx("textarea",{id:`${i}-member-${g}-prompt`,className:"parallel-create-textarea member",rows:2,value:V.memberPrompt,onChange:re=>{he(g);const Se=re.target.value;E(Ke=>Ke.map((Ae,$e)=>$e===g?{...Ae,memberPrompt:Se}:Ae))}})}),te[g]?n.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[n.jsx("strong",{children:r("shell.parallelCreateMemberErrorTitle")}),n.jsx("p",{children:te[g].detail})]}):null]},`parallel-member-${g}`)})})})]})})}const jo="workbench.left.width",No="workbench.right.width",Co="workbench.left.collapsed",Io="workbench.right.collapsed",Qr="workbench.last.session.path",$a="workbench.workspace.selected.id",To="workbench.notifications.seen_at",xp=280,vp=320,Ro=240,Mo=280,Po=520,Eo=560,yp=200,Ua=20,ir=40,ea=5,Sp=3e4,jp=12,Ao=60*1e3,Np=4e3,Wo=220,Lo=18,Cp=6,Ps="data-workbench-panel-resizing",ta="data-workbench-window-resizing",Ip=180,Tp="workbench:focus-composer",Rp=new Set(["starting","running","reconnecting","stale","unknown"]),Mp=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],Pp=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],Fe={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function nc(e,t){const s=e.getPropertyValue(t).trim();if(!s)return null;const a=Number.parseFloat(s);return Number.isFinite(a)?a:null}function Ep(e){return Math.round(e*100)/100}function Ap(e,t){const s=t.getBoundingClientRect();if(s.width<=0||s.height<=0)return null;const a=window.getComputedStyle(t);return a.display==="none"||a.visibility==="hidden"?null:s.top-e.top+s.height/2}function Mn(e,t){const s=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(t)).map(c=>Ap(s,c)).filter(c=>c!==null);return i.length===0?null:i.reduce((c,h)=>c+h,0)/i.length}function Yt(e,t,s){const a=e.style.getPropertyValue(t).trim();if(s===null||!Number.isFinite(s)){a&&e.style.removeProperty(t);return}const i=`${Ep(s)}px`;a!==i&&e.style.setProperty(t,i)}function Jt(e,t,s,a){return a===null?null:(nc(e,t)??0)+(s-a)}function Bo(e){if(e)for(const t of Pp)e.style.removeProperty(t)}function Wp(e){return Rp.has(e.runningState??"idle")||e.activityState==="running"}function Lp(e,t){const s=[];for(const a of[...t].sort()){const i=e.get(a);!i||i.size===0||s.push(`${a}:${[...i].sort().join(",")}`)}return s.join("|")}function Bp(e){var i,c;const t=((i=e.lastErrorCode)==null?void 0:i.trim())??"",s=((c=e.lastErrorDetail)==null?void 0:c.trim())??"",a=[t,s].filter(h=>h.length>0).join(" · ");return a?a.length<=Wo?a:`${a.slice(0,Wo-3)}...`:null}function Dp(e,t,s){var c,h,p,k,m,x,N,C,R,H,G,E;const a=new Map(e.projects.map(v=>[v.id,v.workspaceId])),i=[];for(const v of s){const _=v.title.trim()||v.projectName;if(v.assistantState.lifecycleStage==="analyzed"&&!((c=v.assistantState.linkedSessionId)!=null&&c.trim())&&v.assistantState.lastAnalyzedAt){i.push({id:`todo-analysis-completed:${v.id}:${v.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:r("shell.globalNotificationTodoAnalyzedTitle",{title:_}),body:((h=v.assistantState.analysisSummary)==null?void 0:h.trim())||((p=v.assistantState.generatedPrompt)==null?void 0:p.trim())||v.content,routePath:rs(v.workspaceId),workspaceId:v.workspaceId,createdAt:v.assistantState.lastAnalyzedAt});continue}v.assistantState.lifecycleStage==="failed"&&i.push({id:`todo-analysis-failed:${v.id}:${v.updatedAt}`,kind:"todo_analyze_failed",title:r("shell.globalNotificationTodoAnalyzeFailedTitle",{title:_}),body:((k=v.assistantState.lastError)==null?void 0:k.trim())||v.content,routePath:rs(v.workspaceId),workspaceId:v.workspaceId,createdAt:v.updatedAt})}for(const v of t){const _=((m=v.sessionTitle)==null?void 0:m.trim())||v.projectName,F=v.updatedAt||v.lastAutomationAt||v.createdAt;if(v.status==="waiting_user"){i.push({id:`follow-up-waiting:${v.id}`,kind:"follow_up_waiting_user",title:r("shell.globalNotificationFollowUpWaitingTitle",{title:_}),body:((x=v.waitingReason)==null?void 0:x.trim())||((N=v.lastAutomationSummary)==null?void 0:N.trim())||v.objective,routePath:Tt(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F});continue}if(v.status==="completed"){i.push({id:`follow-up-completed:${v.id}`,kind:"follow_up_completed",title:r("shell.globalNotificationFollowUpCompletedTitle",{title:_}),body:((C=v.lastAutomationSummary)==null?void 0:C.trim())||v.objective,routePath:Tt(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F});continue}v.status==="failed"&&i.push({id:`follow-up-failed:${v.id}`,kind:"follow_up_failed",title:r("shell.globalNotificationFollowUpFailedTitle",{title:_}),body:((R=v.lastAutomationSummary)==null?void 0:R.trim())||((H=v.waitingReason)==null?void 0:H.trim())||v.objective,routePath:Tt(v.workspaceId,v.sessionId),workspaceId:v.workspaceId,createdAt:F})}for(const v of e.verifications){if(v.status!=="failed")continue;const _=v.projectId?a.get(v.projectId)??null:null,F=((G=v.targetRef)==null?void 0:G.trim())||v.verificationType;i.push({id:`verification-failed:${v.id}`,kind:"verification_failed",title:r("shell.globalNotificationVerificationFailedTitle",{title:F}),body:((E=v.summary)==null?void 0:E.trim())||r("shell.globalNotificationVerificationFailedFallback"),routePath:_?rs(_):null,workspaceId:_,createdAt:v.finishedAt||v.startedAt||v.createdAt})}return i.sort((v,_)=>{const F=Do(v.kind)-Do(_.kind);return F!==0?F:Wn(_.createdAt)-Wn(v.createdAt)}).slice(0,jp)}function Do(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function _p(e){switch(e){case"follow_up_waiting_user":return r("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return r("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return r("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return r("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return r("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return r("shell.globalNotificationKindVerificationFailed");default:return r("shell.globalNotificationsPanelTitle")}}function Wn(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function Fp(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function Op(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function Hp(e,t){const s=new Set,a=(e==null?void 0:e.currentBranch)??"",i=((e==null?void 0:e.local)??[]).slice().sort((p,k)=>Number(k.current)-Number(p.current)||p.name.localeCompare(k.name)).map(p=>({value:p.name,current:p.current,recommended:p.name===a})).filter(p=>!p.value||s.has(p.value)?!1:(s.add(p.value),!0)),c=((e==null?void 0:e.remote)??[]).map(p=>({value:p.name})).filter(p=>!p.value||s.has(p.value)?!1:(s.add(p.value),!0)),h=t.map(p=>({value:p.name})).filter(p=>!p.value||s.has(p.value)?!1:(s.add(p.value),!0));return{localBranches:i,remoteBranches:c,tags:h}}function $p(e){return e.getBoundingClientRect()}function Up(e,t){return t?Wn(e.createdAt)>Wn(t):!0}function Gp(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function _o(e,t){var h,p;const s=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const k of s){const m=Ee(k,e),x=(h=m==null?void 0:m.params.workspaceId)==null?void 0:h.trim();if(x)return x}const a=hr(e),i=(a==null?void 0:a.sessionId)??null;return!i||!Mc(i)?null:((p=new URLSearchParams(t).get("workspaceId"))==null?void 0:p.trim())||null}function zp(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function Ga(e){return e==="mobile"?mt():"/landing"}function hr(e){var c,h,p;const t=Ee("/workspaces/:workspaceId/sessions/:sessionId",e),s=(c=t==null?void 0:t.params.sessionId)==null?void 0:c.trim();if(s)return{sessionId:s,workspaceId:((h=t==null?void 0:t.params.workspaceId)==null?void 0:h.trim())??null};const a=Ee("/sessions/:sessionId",e),i=(p=a==null?void 0:a.params.sessionId)==null?void 0:p.trim();return i?{sessionId:i,workspaceId:null}:null}function qp(e){return!!(Ee("/sessions",e)||Ee("/workspaces/:workspaceId/sessions",e))}function Fo(e){return!!hr(e)}function Kp(e){return!!(Ee("/tools",e)||Ee("/tools/files",e)||Ee("/tools/git",e)||Ee("/tools/processes",e)||Ee("/workspaces/:workspaceId/tools",e)||Ee("/workspaces/:workspaceId/tools/files",e)||Ee("/workspaces/:workspaceId/tools/git",e)||Ee("/workspaces/:workspaceId/tools/processes",e))}function la(e){return!!(Ee("/terminals",e)||Ee("/workspaces/:workspaceId/terminals",e))}function ca(e){return!!Ee("/workspaces/:workspaceId/butler",e)}function Vp(e,t){return Ee("/workspaces/:workspaceId/debug",e)?Il(t):Ee("/workspaces/:workspaceId",e)?Qt(t):Ee("/workspaces/:workspaceId/tools/files",e)||Ee("/tools/files",e)?Rl(t):Ee("/workspaces/:workspaceId/tools/git",e)||Ee("/tools/git",e)?Ml(t):Ee("/workspaces/:workspaceId/tools/processes",e)||Ee("/tools/processes",e)?Pl(t):Ee("/workspaces/:workspaceId/tools",e)||Ee("/tools",e)?Tl(t):la(e)?ss(t):ca(e)?rs(t):mr(t)}function Xp(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const Yp=o.lazy(async()=>({default:(await ai(()=>import("./FileContextPanel-C3qex8bb.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),Jp=o.lazy(async()=>({default:(await ai(()=>import("./GitSidebar-BK6H16XU.js"),__vite__mapDeps([11,1,2,3,4,12,5,7,6,8,9,10]))).GitSidebar})),Zp=o.lazy(async()=>({default:(await ai(()=>import("./TerminalManagerPanel-CCLr1Ypk.js"),__vite__mapDeps([13,1,2,6,3,4,5,14,15,8,9,10]))).TerminalManagerPanel}));function Qp(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function Dt(e){return Os(e)}function sc(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function lr(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(Qp):[]}async function rc(e,t){const s=await hd(t,e);if(s.canStartSession===!1)throw new Error(s.limitations[0]??r("conversation.capabilityDenied"))}const ac=o.createContext(null);function ti(e){return xh(e)}function Zt(e){return e.isArchived===!0}function xa(e){return vl(e)}function Ni(e,t){return Sl(e,{getId:s=>s.sessionId,getParentId:xa,compare:(s,a)=>Si(s,a,t)})}function ic(e){return e.filter(t=>{if(Zt(t))return!1;const s=xa(t);if(!s)return!0;const a=e.find(i=>i.sessionId===s);return!a||!Zt(a)})}function ef(e){return e.flatMap(t=>{const s=sc(t);return s?[s,...jl(Dt(t))]:[]})}function tf(e,t,s){const a=new Set(Pn(Dt(e)).sort((i,c)=>Si(i.item,c.item,s)).slice(0,t).map(i=>i.item.sessionId));return{...e,children:oc(Dt(e),a)}}function oc(e,t){return e.flatMap(s=>{const a=oc(Dt(s),t);return!t.has(s.item.sessionId)&&a.length===0?[]:[{...s,children:a}]})}function na(e,t,s,a=-1){if(e<=0)return 0;const i=a>=0?Math.max(t,a+1):t;return Math.min(e,Math.max(s??0,i))}function Oo(e,t){const s=Object.keys(e),a=Object.keys(t);return s.length!==a.length?!1:s.every(i=>e[i]===t[i])}function nf(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function sf(e){return xi(e)||e.syncStatus==="error"}function rf(e){var a,i;if(!sf(e))return null;const t=((a=e.lastErrorCode)==null?void 0:a.trim())??"",s=((i=e.lastErrorDetail)==null?void 0:i.replace(/\s+/g," ").trim())??"";return t&&s&&!s.includes(t)?`${t} · ${s}`:s||t||(e.syncStatus==="error"&&!xi(e)?r("conversation.syncStatusError"):r("conversation.runtimeErrorTitle"))}function af(e,t=110){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}function va(e,t="compact"){return Va(e,t)}const of={position:"relative",zIndex:0},lf={zIndex:1};function lc(e,t,s,a){const i=[],c=(a==null?void 0:a.trim())||t.name;s&&i.push(c);const h=nf(e);return h&&i.push(h),i.join(" · ")||c}function Ho(e,t){return fh("session-state-indicator",e,t)}function cf(e,t){return Kl(e,t)}function $o(e,t){try{const s=window.localStorage.getItem(e),a=s?Number(s):Number.NaN;return Number.isFinite(a)?a:t}catch{return t}}function Uo(e,t){try{const s=window.localStorage.getItem(e);return s===null?t:s==="true"}catch{return t}}function Go(e){var t;try{const s=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return s||null}catch{return null}}function ns(e,t){try{window.localStorage.setItem(e,t)}catch{}}function df(e){try{window.localStorage.removeItem(e)}catch{}}function sa(e,t,s){return Math.max(t,Math.min(s,e))}function ra(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function uf(e){const t=window.getComputedStyle(e),s=ra(t.getPropertyValue("--desktop-macos-titlebar-height")),a=ra(t.getPropertyValue("--workbench-header-min-height")),i=ra(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),c=ra(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(s,a,40)+i+c+8}function zo(e,t){const s=t.getBoundingClientRect();return e>=s.top&&e<=s.top+uf(t)}function hf(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function pf(){typeof window>"u"||window.dispatchEvent(new CustomEvent(Tp))}function cc(e,t){const s=t==null?void 0:t.trim();if(!s)return null;for(const a of e){if(a.workspace.id===s)return a;const i=cc(a.children,s);if(i)return i}return null}function qo(e,t){const s=t==null?void 0:t.trim();if(!s)return null;for(const a of e){const i=cc(a.childWorktrees,s);if(i)return i}return null}function dc(e){return e.flatMap(t=>[t.workspace.id,...dc(t.children)])}function ff(e){return new Set(e.flatMap(t=>[t.workspace.id,...dc(t.childWorktrees)]))}function Ko(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var s;return t.collapsed===!0&&((s=t.workspace)==null?void 0:s.id)}).map(t=>t.workspace.id)}function za(e,t){const s=new Set(t);return{items:e.map(a=>({workspace:a.workspace,sessions:a.sessions,childWorktrees:a.childWorktrees,collapsed:s.has(a.workspace.id)}))}}function uc(e,t,s){return e.map(a=>{const i=ic(a.sessions);return{workspace:a.workspace,meta:a.meta,visibleSessions:i,archivedSessions:a.sessions.filter(c=>Zt(c)&&!xa(c)),visibleSessionTree:Ni(i,s).filter(c=>!t.has(c.item.sessionId)&&!hi(Dt(c),h=>t.has(h.sessionId))),children:uc(a.children,t,s)}})}function ni(e){return e.flatMap(t=>[t.workspace.id,...ni(t.children)])}function cr(e){return e.flatMap(t=>[...t.visibleSessionTree,...cr(t.children)])}function mf(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,visibleSessionTree:lr(s)};const a=pc(s.childWorktrees,t);if(a)return a}return null}function hc(e,t){for(const s of e){const a=Pn(s.visibleSessionTree).find(c=>c.item.sessionId===t);if(a)return a;const i=hc(s.children,t);if(i)return i}return null}function pc(e,t){for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,visibleSessionTree:s.visibleSessionTree};const a=pc(s.children,t);if(a)return a}return null}function bf(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const a=fc(s.childWorktrees,t);if(a)return a}return null}function Vo(e,t){if(!t)return null;for(const s of e){if(s.workspace.id===t)return s.workspace;const a=mc(s.childWorktrees,t);if(a)return a}return null}function fc(e,t){for(const s of e){if(s.workspace.id===t)return{workspace:s.workspace,archivedSessions:s.archivedSessions};const a=fc(s.children,t);if(a)return a}return null}function mc(e,t){for(const s of e){if(s.workspace.id===t)return s.workspace;const a=mc(s.children,t);if(a)return a}return null}function bc(e,t){for(const s of e){if(s.workspace.id===t)return[s.workspace.id];const a=bc(s.children,t);if(a.length>0)return[s.workspace.id,...a]}return[]}function Xo(e){return e.flatMap(t=>[t.workspace.id,...gc(t.childWorktrees)])}function gc(e){return e.flatMap(t=>[t.workspace.id,...gc(t.children)])}function gf(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const s=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&s.push(e.parentDisplayName),s.join(" / ")}function kf(e,t,s,a){if(t===s)return e;const i=e.findIndex(m=>m.workspace.id===t),c=e.findIndex(m=>m.workspace.id===s);if(i<0||c<0)return e;const h=[...e],[p]=h.splice(i,1);if(!p)return e;const k=h.findIndex(m=>m.workspace.id===s);return k<0?e:(h.splice(a==="before"?k:k+1,0,p),h.every((m,x)=>{var N;return m.workspace.id===((N=e[x])==null?void 0:N.workspace.id)})?e:h)}function wf(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let s=!1;const a=e.items.map(i=>{let c=!1;const h=i.sessions.map(k=>{const m=t.get(k.sessionId);return m===void 0||Zt(k)===m?k:(s=!0,c=!0,{...k,isArchived:m})}),p=wc(i.childWorktrees??[],t,k=>{k&&(s=!0,c=!0)});return c?{...i,sessions:h,childWorktrees:p}:i});return s?{...e,items:a}:e}function xf(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const s of t.items){for(const a of s.sessions){const i=e.get(a.sessionId);i!==void 0&&Zt(a)===i&&e.delete(a.sessionId)}xc(e,s.childWorktrees??[])}}function vf(e,t,s){let a=!1;const i=e.map(c=>{if(c.workspace.id!==t.workspaceId){const{nodes:k,changed:m}=vc(c.childWorktrees,t,s);return m?(a=!0,{...c,childWorktrees:k}):c}const h=c.sessions.findIndex(k=>k.sessionId===t.sessionId),p=h>=0?c.sessions.map((k,m)=>m===h?t:k):[t,...c.sessions];return a=!0,{...c,sessions:xr(p,s)}});return a?i:e}function yf(e,t,s){let a=!1;const i=e.map(c=>{let h=!1;const p=c.sessions.map(m=>m.sessionId!==t?m:(a=!0,h=!0,{...m,lastSeenAt:m.lastSeenAt&&m.lastSeenAt>s?m.lastSeenAt:s,activityState:m.activityState==="completed_unread"?"idle":m.activityState})),k=ya(c.childWorktrees,m=>m.sessionId!==t?m:(a=!0,h=!0,{...m,lastSeenAt:m.lastSeenAt&&m.lastSeenAt>s?m.lastSeenAt:s,activityState:m.activityState==="completed_unread"?"idle":m.activityState}));return h?{...c,sessions:p,childWorktrees:k}:c});return a?i:e}function Yo(e,t,s){let a=!1;const i=e.map(c=>{let h=!1;const p=c.sessions.map(m=>m.sessionId!==t||m.isArchived===s?m:(a=!0,h=!0,{...m,isArchived:s})),k=ya(c.childWorktrees,m=>m.sessionId!==t||m.isArchived===s?m:(a=!0,h=!0,{...m,isArchived:s}));return h?{...c,sessions:p,childWorktrees:k}:c});return a?i:e}function Jo(e,t,s){let a=!1;const i=e.map(c=>{let h=!1;const p=c.sessions.map(m=>m.sessionId!==t||m.isFavorite===!0===s?m:(a=!0,h=!0,{...m,isFavorite:s})),k=ya(c.childWorktrees,m=>m.sessionId!==t||m.isFavorite===!0===s?m:(a=!0,h=!0,{...m,isFavorite:s}));return h?{...c,sessions:p,childWorktrees:k}:c});return a?i:e}function Sf(e,t){return e.includes(t)?e.filter(s=>s!==t):[...e,t]}function jf(e){return e?e.slice(0,8):"--"}function Zo(e,t,s){return s?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(a=>a!==t):e}function kc(e,t){const s=e.filter(a=>t.has(a));return s.length===e.length?e:s}function wc(e,t,s){return e.map(a=>{let i=!1;const c=a.sessions.map(p=>{const k=t.get(p.sessionId);return k===void 0||Zt(p)===k?p:(i=!0,{...p,isArchived:k})}),h=wc(a.children,t,p=>{p&&(i=!0)});return s(i),i?{...a,sessions:c,children:h}:a})}function xc(e,t){for(const s of t){for(const a of s.sessions){const i=e.get(a.sessionId);i!==void 0&&Zt(a)===i&&e.delete(a.sessionId)}xc(e,s.children)}}function vc(e,t,s){let a=!1;const i=e.map(c=>{if(c.workspace.id===t.workspaceId){const p=c.sessions.findIndex(m=>m.sessionId===t.sessionId),k=p>=0?c.sessions.map((m,x)=>x===p?t:m):[t,...c.sessions];return a=!0,{...c,sessions:xr(k,s)}}const h=vc(c.children,t,s);return h.changed?(a=!0,{...c,children:h.nodes}):c});return{nodes:a?i:[...e],changed:a}}function Nf(e,t){return e.map(s=>({...s,sessions:xr(s.sessions,t),childWorktrees:ji(s.childWorktrees,t)}))}function ya(e,t){let s=!1;const a=e.map(i=>{let c=!1;const h=i.sessions.map(k=>{const m=t(k);return m!==k&&(c=!0,s=!0),m}),p=ya(i.children,t);return p!==i.children&&(c=!0,s=!0),c?{...i,sessions:h,children:p}:i});return s?a:[...e]}function si(e){return`workspace-management.summary.${e}`}function yc(e){return`git-sidebar.snapshot.${e}`}function Sc(e,t){const s=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!s,repoRoot:s,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function jc(e,t){const s=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!s,repoRoot:s}}}function Nc(e,t){var c,h,p,k;const s=((c=t.status)==null?void 0:c.snapshot.enabled)!==!1,a=s?((h=t.status)==null?void 0:h.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,i=s?((p=t.status)==null?void 0:p.snapshot.branch)??((k=t.branches)==null?void 0:k.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:s&&(e.git.isRepository||!!a),repoRoot:a,currentBranch:i,error:null}}}function Cc({count:e,className:t="workbench-skeleton-lines"}){return n.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(s,a)=>n.jsx("span",{className:"skeleton-line"},a))})}function Cf(){return n.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>n.jsxs("section",{className:"workbench-skeleton-card",children:[n.jsxs("div",{className:"workbench-skeleton-heading",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx("span",{className:"skeleton-line tiny"})]}),n.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(s,a)=>n.jsxs("div",{className:"workbench-skeleton-session",children:[n.jsx("span",{className:"workbench-skeleton-dot"}),n.jsx(Cc,{count:2,className:"workbench-skeleton-lines compact"})]},a))})]},t))})}function aa(){return n.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>n.jsxs("article",{className:"workbench-info-skeleton-card",children:[n.jsx("span",{className:"skeleton-line short"}),n.jsx(Cc,{count:3})]},t))})}function If({side:e,collapsed:t}){const s=e==="left"?8.5:15.5,a=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:s,y1:"4",x2:s,y2:"20"}),n.jsx("polyline",{points:a})]})}function Qo({ariaLabel:e,side:t,collapsed:s,className:a="panel-icon-button",onClick:i}){return n.jsx("button",{className:a,type:"button","aria-label":e,title:e,onClick:i,children:n.jsx(If,{side:t,collapsed:s})})}function dr({expanded:e}){return n.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Tf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),n.jsx("polyline",{points:"7 10 12 15 17 10"}),n.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Rf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),n.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),n.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),n.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function Mf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Ic(e){return n.jsx("div",{className:"workbench-notification-anchor",children:n.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":r("shell.globalNotificationsAction"),title:r("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[n.jsx(Mf,{}),e.unreadCount>0?n.jsx("span",{className:"workbench-notification-badge","aria-label":r("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function Pf(e){const[t,s]=o.useState("notifications");o.useEffect(()=>{e.open&&s("notifications")},[e.open]);const a=o.useMemo(()=>e.notifications.filter(i=>e.showArchivedNotifications||!e.archivedNotificationIds.has(i.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return n.jsxs(Ye,{open:e.open,title:r("shell.globalNotificationsPanelTitle"),description:r("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[n.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":r("shell.globalNotificationsPanelTitle"),children:[n.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>s("notifications"),children:r("shell.globalNotificationsAction")}),n.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>s("inbox"),children:r("shell.butlerInboxAction")})]}),n.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?n.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.globalNotificationsAction"),children:[n.jsx("div",{className:"workbench-notification-toolbar",children:n.jsxs("label",{className:"workbench-notification-filter",children:[n.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:i=>e.onToggleShowArchivedNotifications(i.target.checked)}),n.jsx("span",{children:r("shell.globalNotificationsShowArchived")})]})}),a.length>0?n.jsx("div",{className:"workbench-notification-list",children:a.map(i=>{const c=e.archivedNotificationIds.has(i.id);return n.jsxs("article",{className:"workbench-notification-item","data-archived":c,children:[n.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(i)},children:[n.jsx("span",{className:"workbench-notification-item-kind",children:_p(i.kind)}),n.jsx("strong",{children:i.title}),n.jsx("p",{children:i.body})]}),n.jsxs("div",{className:"workbench-notification-item-side",children:[n.jsx("time",{children:Gp(i.createdAt)}),n.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(c){e.onUnarchiveNotification(i.id);return}e.onArchiveNotification(i.id)},children:c?r("shell.globalNotificationsRemoveArchiveAction"):r("shell.globalNotificationsArchiveAction")})]})]},i.id)})}):n.jsx("p",{className:"workbench-notification-empty",children:r("shell.globalNotificationsEmpty")})]}):n.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":r("shell.butlerInboxAction"),children:n.jsx(ec,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),n.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:n.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:r("common.close")})})]})}function Ef(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Af(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"11",cy:"11",r:"7"}),n.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function Wf(){return n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Lf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("path",{d:"M7 9l3 3-3 3"}),n.jsx("path",{d:"M13 15h4"})]})}function Bf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),n.jsx("circle",{cx:"9",cy:"11",r:"1"}),n.jsx("circle",{cx:"15",cy:"11",r:"1"}),n.jsx("path",{d:"M8 15h8"}),n.jsx("path",{d:"M12 5V3"})]})}function Df(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),n.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Tc(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),n.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),n.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function _f(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"18",cy:"6",r:"3"}),n.jsx("circle",{cx:"6",cy:"6",r:"3"}),n.jsx("circle",{cx:"18",cy:"18",r:"3"}),n.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),n.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function Ff(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function Of(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),n.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),n.jsx("path",{d:"M14 16l2 2 4-4"})]})}function Hf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),n.jsx("path",{d:"M10 12h8"}),n.jsx("path",{d:"M15 8l4 4-4 4"})]})}function $f({selected:e}){return e?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),n.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Rc({active:e,className:t}){return e?n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):n.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:n.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function Uf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 7h18"}),n.jsx("path",{d:"M5 7l1 12h12l1-12"}),n.jsx("path",{d:"M9 11h6"}),n.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function Gf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M12 20h9"}),n.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function zf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 6h18"}),n.jsx("path",{d:"M8 6V4h8v2"}),n.jsx("path",{d:"M6 6l1 14h10l1-14"}),n.jsx("path",{d:"M10 11v5"}),n.jsx("path",{d:"M14 11v5"})]})}function qf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[n.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),n.jsx("path",{d:"M9 13h6"})]})}function Kf(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),n.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function Vf({open:e,mode:t,keyword:s,codeWorkspaceId:a,codeResults:i,codeLoading:c,codeError:h,workspaceOptions:p,sessionResults:k,onClose:m,onModeChange:x,onKeywordChange:N,onCodeWorkspaceChange:C,onCodeSearch:R,onOpenSession:H}){const G=s.trim().length>0&&a.trim().length>0;return n.jsx(Ye,{open:e,title:r("shell.searchModalTitle"),description:r("shell.searchModalDescription"),onClose:m,children:n.jsxs("div",{className:"workbench-search-modal",children:[n.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":r("shell.searchModeLabel"),children:[n.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>x("sessions"),children:r("shell.searchModeSessions")}),n.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>x("code"),children:r("shell.searchModeCode")})]}),t==="sessions"?n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:s,placeholder:r("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:E=>N(E.target.value)})]}),n.jsx("div",{className:"workbench-search-results",children:s.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionHint")}):k.length>0?k.map(E=>{const v=yi(E.session.title,r("common.unknown"));return n.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>H(E.session.sessionId),children:[n.jsx("span",{className:"workbench-search-result-title",title:v.fullTitle,children:v.displayTitle}),n.jsxs("span",{className:"workbench-search-result-meta",children:[E.workspace.name," · ",va(E.session.provider,"full")]})]},E.session.sessionId)}):n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchSessionEmpty")})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchWorkspaceLabel")}),n.jsx("select",{value:a,onChange:E=>C(E.target.value),children:p.map(E=>n.jsx("option",{value:E.id,children:E.name},E.id))})]}),n.jsxs("form",{className:"workbench-search-code-form",onSubmit:E=>{E.preventDefault(),R()},children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.searchKeywordLabel")}),n.jsx("input",{type:"text",value:s,placeholder:r("shell.searchCodePlaceholder"),autoFocus:!0,onChange:E=>N(E.target.value)})]}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!G||c,children:c?r("common.loading"):r("shell.searchSubmit")})]}),n.jsxs("div",{className:"workbench-search-results",children:[h?n.jsx("p",{className:"status-text","data-tone":"error",children:h}):null,!h&&s.trim().length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeHint")}):null,!h&&s.trim().length>0&&!c&&i.length===0?n.jsx("p",{className:"workbench-search-empty",children:r("shell.searchCodeEmpty")}):null,i.map(E=>n.jsxs("div",{className:"workbench-search-result-item static",children:[n.jsx("span",{className:"workbench-search-result-title",children:E.name}),n.jsx("span",{className:"workbench-search-result-meta",children:E.path})]},`${E.path}-${E.kind}`))]})]})]})})}function el({menuKey:e,session:t,workspace:s,workspaceContext:a,isActive:i,isFavorite:c,menuOpen:h,menuAnchorPoint:p,showWorkspaceName:k,depth:m=0,showActions:x=!0,hasSubagents:N=!1,subagentListExpanded:C=!1,selectionMode:R=!1,selected:H=!1,onToggleSelect:G,onToggleSubagents:E,onOpen:v,onRename:_,onOpenContextMenu:F,onToggleFavorite:Z,onArchive:T,onDelete:z,onCloseMenu:Y}){var ke,he,de;const O=Ln(),j=da(t.provider).supportsSessionDelete===!0,J=ti(t)?((ke=t.subagentLabel)==null?void 0:ke.trim())||r("shell.subagentBadge"):null,te=yi(t.title,r("common.unknown")),P=rf(t),ue=P?af(P):null,K=mh(t),Q=K?bh("session-activity-badge",t):null,D=vi(t),y=vh(t),I=Bd(t.parallelGroup),q=Wd(t.parallelGroup),se=o.useRef(null),[Ce,ie]=o.useState(null);o.useLayoutEffect(()=>{if(O.isDesktop||!h||!p||typeof window>"u"){ie(null);return}const ge=()=>{var V,g;const ye=Ph(p,{width:((V=se.current)==null?void 0:V.offsetWidth)??0,height:((g=se.current)==null?void 0:g.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:j&&z?216:168});ie({position:"fixed",top:`${Math.round(ye.top)}px`,left:`${Math.round(ye.left)}px`,width:`${Math.round(ye.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(ye.maxHeight)}px`,transformOrigin:ye.transformOrigin})};return ge(),window.addEventListener("resize",ge),window.addEventListener("scroll",ge,!0),()=>{window.removeEventListener("resize",ge),window.removeEventListener("scroll",ge,!0)}},[p,h,O.isDesktop]);async function oe(){await Ed([{id:`rename:${t.sessionId}`,label:r("shell.renameAction"),onSelect:_},{id:`favorite:${t.sessionId}`,label:c?r("shell.unfavoriteAction"):r("shell.favoriteAction"),onSelect:Z},{id:`archive:${t.sessionId}`,label:r("shell.archiveAction"),onSelect:T},...j&&z?[{id:`delete:${t.sessionId}`,label:r("shell.deleteSessionAction"),onSelect:z}]:[]])}const ve=!O.isDesktop&&h&&typeof document<"u"?gr.createPortal(n.jsxs("div",{ref:se,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":r("shell.sessionMoreAction"),onClick:ge=>ge.stopPropagation(),style:Ce??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{_(),Y()},children:[n.jsx(Gf,{}),n.jsx("span",{children:r("shell.renameAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{Z(),Y()},children:[n.jsx(Rc,{active:c}),n.jsx("span",{children:c?r("shell.unfavoriteAction"):r("shell.favoriteAction")})]}),n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{T(),Y()},children:[n.jsx(Uf,{}),n.jsx("span",{children:r("shell.archiveAction")})]}),j&&z?n.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{z(),Y()},children:[n.jsx(zf,{}),n.jsx("span",{children:r("shell.deleteSessionAction")})]}):null]}),document.body):null;return n.jsxs("article",{className:"workbench-session-card","data-active":i,"data-depth":m,"data-subagent":ti(t),"data-workspace-tone":a.tone,"data-worktree-depth":a.depth,"data-has-subagents":N,"data-selecting":R,"data-selected":H,"data-parallel-group":t.parallelGroup?"true":void 0,"data-parallel-role":((he=t.parallelGroup)==null?void 0:he.role)??void 0,"data-parallel-color-token":((de=t.parallelGroup)==null?void 0:de.colorToken)??void 0,style:{...hn(a)??{},...q??{}},onContextMenu:ge=>{if(!(R||!x||!F)){if(ge.preventDefault(),ge.stopPropagation(),O.isDesktop){oe();return}F({x:ge.clientX,y:ge.clientY})}},children:[n.jsxs("div",{className:"workbench-session-main",children:[R?n.jsx("span",{className:"workbench-session-selection-indicator","data-selected":H,"aria-hidden":"true",children:n.jsx($f,{selected:H})}):N?n.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:lf,"data-indicator-variant":cf(t,{hasSubagents:!0,isActive:i}),"aria-label":C?r("shell.subagentCollapse"):r("shell.subagentExpand"),title:C?r("shell.subagentCollapse"):r("shell.subagentExpand"),"aria-expanded":C,onClick:ge=>{ge.stopPropagation(),E==null||E()},children:[n.jsx("span",{className:Ho(t,{hasSubagents:!0,isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:n.jsx(dr,{expanded:C})})]}):n.jsx("span",{className:Ho(t,{isActive:i}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),n.jsx("button",{type:"button",className:"workbench-session-link",style:N?of:void 0,"data-active":i,"aria-pressed":R?H:void 0,onClick:R?G:v,onKeyDown:ge=>{if(R||!x||!F||ge.key!=="ContextMenu"&&!(ge.shiftKey&&ge.key==="F10"))return;if(ge.preventDefault(),ge.stopPropagation(),O.isDesktop){oe();return}const ye=ge.currentTarget.getBoundingClientRect();F({x:ye.right,y:ye.bottom})},children:n.jsxs("div",{className:"workbench-session-link-copy",children:[n.jsxs("div",{className:"session-title-row",children:[n.jsx("span",{className:"session-title",title:te.fullTitle,children:te.displayTitle}),J?n.jsx("span",{className:"session-subagent-badge",children:J}):null,I?n.jsx("span",{className:"session-parallel-badge",children:I}):null,!I&&y&&D?n.jsx("span",{className:`session-fork-badge ${D}`,children:y}):null]}),n.jsxs("div",{className:"session-meta-row",children:[n.jsx("span",{className:"session-meta",children:lc(t,s,k,a.displayName)}),K&&Q?n.jsx("span",{className:Q,children:K}):null,n.jsx("span",{className:`session-provider-badge ${t.provider}`,children:va(t.provider)})]}),ue?n.jsx("div",{className:"session-error-row",title:P??void 0,children:n.jsx("span",{className:"session-error-text",children:ue})}):null]})})]}),ve]})}function tl({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:s,favoriteSessions:a,favoriteSessionIds:i,activeWorkspaceId:c,isConversationActive:h,isTerminalActive:p,isButlerActive:k,isSearchOpen:m,navigationLoading:x,navigationError:N,activeSessionId:C,onRefreshNavigation:R,onSessionUpdated:H,onNavigateConversation:G,onNavigateTerminals:E,onNavigateButler:v,onOpenSearch:_,onOpenSettings:F,onSelectWorkspace:Z,onToggleWorkspaceCollapse:T,onStartWorkspaceReorder:z,onPreviewWorkspaceReorder:Y,onCommitWorkspaceReorder:O,allowWorkspaceReorder:j,subscribeGitSnapshot:J,requestGitRefresh:te,subscribeWorkspaceManagementSnapshot:P,requestWorkspaceManagementRefresh:ue,onToggleFavoriteSession:K,onArchiveSession:Q,onUnarchiveSession:D,workspaceManagementStateById:y,setWorkspaceManagementStateById:I,unreadNotificationCount:q,notificationPanelOpen:se,onToggleNotificationPanel:Ce,onClose:ie,onToggleCollapse:oe}){var Js;const ve=br(),ke=Ln(),he=Ol(ke),{showToast:de}=as(),ge=ri(d=>d),ye=((Js=Ka(ge))==null?void 0:Js.name)??"",V=ge.hosts.length+cl(ge).length>1&&ye.length>0,[g,S]=o.useState(!1),[B,L]=o.useState(!1),[we,re]=o.useState(!1),[Se,Ke]=o.useState([]),[Ae,$e]=o.useState(null),[Oe,Ft]=o.useState(null),[De,Ze]=o.useState(null),[Ue,os]=o.useState(null),[ze,Ot]=o.useState(null),[Rt,ls]=o.useState(null),[Mt,Bn]=o.useState(null),[vt,fn]=o.useState(!1),[Qe,cs]=o.useState(!1),[Hs,mn]=o.useState(""),[vr,Re]=o.useState(""),[ds,_e]=o.useState(""),[Ht,Dn]=o.useState({localBranches:[],remoteBranches:[],tags:[]}),[it,nt]=o.useState(!1),[_n,et]=o.useState(-1),[us,Fn]=o.useState(!1),[bn,On]=o.useState(!1),[en,Hn]=o.useState(null),[tn,hs]=o.useState(null),[Sa,$t]=o.useState(null),[ja,nn]=o.useState(null),[gn,$n]=o.useState(null),[Ut,kn]=o.useState(null),[Pt,yr]=o.useState(null),[Sr,st]=o.useState(null),[Et,We]=o.useState(Ua),[ps,wn]=o.useState({}),[Un,xn]=o.useState({}),[$s,vn]=o.useState([]),[sn,Gt]=o.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[Ve,yn]=o.useState(null),[Gn,zn]=o.useState(""),[fs,Sn]=o.useState(null),[ot,rn]=o.useState(null),[bt,lt]=o.useState([]),[ms,Us]=o.useState(!1),[rt,ct]=o.useState({}),[dt,an]=o.useState(null),jn=o.useRef(null),Nn=o.useRef(null),zt=o.useRef(null),Cn=o.useRef(new Map),yt=o.useRef(null),bs=o.useRef(null),qt=o.useRef(null),gs=o.useMemo(()=>new Set(sn.expandedWorkspaceIds),[sn.expandedWorkspaceIds]),jr=o.useMemo(()=>new Set(sn.collapsedWorkspaceIds),[sn.collapsedWorkspaceIds]),qn=dt!==null,At=j&&ke.isDesktop&&ke.ui.osFamily==="macos",tt=o.useCallback(()=>{yr(null),st(null)},[]),Nr=o.useCallback((d,f)=>{yr(d),st(f)},[]),Me=Vo(e,ze)??((Mt==null?void 0:Mt.id)===ze?Mt:null),ks=ds.trim().toLowerCase(),In=o.useMemo(()=>[{key:"localBranches",label:r("shell.createWorktreeBaseRefLocalGroup"),items:Ht.localBranches},{key:"remoteBranches",label:r("shell.createWorktreeBaseRefRemoteGroup"),items:Ht.remoteBranches},{key:"tags",label:r("shell.createWorktreeBaseRefTagGroup"),items:Ht.tags}].map(f=>({...f,items:f.items.filter(w=>ks?w.value.toLowerCase().includes(ks):!0)})).filter(f=>f.items.length>0),[ks,Ht]),gt=o.useMemo(()=>In.flatMap(d=>d.items),[In]),Kt=Me?`create-worktree-base-ref-listbox-${Me.id}`:"create-worktree-base-ref-listbox",St=bf(e,ja),jt=St?ln(St.workspace):null,xe=o.useMemo(()=>mf(e,ot),[ot,e]),at=o.useMemo(()=>xe?ef(xe.visibleSessionTree):[],[xe]),je=o.useMemo(()=>at.map(d=>d.sessionId),[at]),Tn=o.useMemo(()=>new Set(je),[je]),Kn=o.useMemo(()=>new Set(bt),[bt]),ws=je.length>0&&bt.length===je.length;o.useEffect(()=>{I(d=>{const f=Xo(e),w=new Set(f),A={};Object.entries(d).forEach(([ee,Pe])=>{w.has(ee)&&(A[ee]=Pe)}),f.forEach(ee=>{const Pe=Vo(e,ee);if(!Pe)return;const Le=ha(si(ee),Ao),Ie=ha(yc(ee),Ao),qe=A[ee];let ht=jc((qe==null?void 0:qe.detail)??Le??Sc(Pe),Pe);(Ie!=null&&Ie.status||Ie!=null&&Ie.branches)&&(ht=Nc(ht,{status:Ie.status??null,branches:Ie.branches??null})),A[ee]={detail:ht,loading:!1,error:null}});const W=Object.keys(d),fe=Object.keys(A);return W.length===fe.length&&fe.every(ee=>d[ee]===A[ee])?d:A})},[e]);const Vt=o.useCallback(async d=>{await R(),await ke.bridge.showNotification(r("shell.importSuccess"),d.path)},[R,ke.bridge]),xs=o.useCallback(async d=>{await R(),await ke.bridge.showNotification(r("shell.cloneSuccess"),d.path)},[R,ke.bridge]);function Cr(d){if(Se.includes(d)){Ke(w=>w.filter(A=>A!==d));return}Ke(w=>[...w,d]),J(d),te(d),P(d),ue(d)}async function Gs(d,f){if(rt[d])return;const w=(f==null?void 0:f.trim().toUpperCase())??null;ct(A=>({...A,[d]:!0}));try{await hl(d,{backgroundColor:w}),await R()}catch(A){de({title:A instanceof Error?A.message:r("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{ct(A=>({...A,[d]:!1}))}}async function Ir(){if(!(!Ae||Oe)){Ft(Ae.id);try{await md(Ae.id),Ke(d=>d.filter(f=>f!==Ae.id)),I(d=>{const f={...d};return delete f[Ae.id],f}),$e(null),await R(),de({title:r("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(d){de({title:d instanceof Error?d.message:r("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{Ft(null)}}}o.useEffect(()=>{if(!Pt)return;function d(f){const w=f.target;w instanceof HTMLElement&&w.closest(".workbench-session-menu")||tt()}return window.addEventListener("pointerdown",d),()=>{window.removeEventListener("pointerdown",d)}},[tt,Pt]),o.useEffect(()=>{if(!ot){bt.length>0&<([]);return}if(!xe){rn(null),lt([]);return}lt(d=>kc(d,Tn))},[xe,Tn,ot,bt.length]),o.useEffect(()=>{ot&&je.length===0&&(rn(null),lt([]))},[je.length,ot]),o.useEffect(()=>{const d=new Set(Xo(e)),f=new Set(e.flatMap(w=>ni(w.childWorktrees)));Ke(w=>w.filter(A=>d.has(A))),Gt(w=>({expandedWorkspaceIds:w.expandedWorkspaceIds.filter(A=>f.has(A)),collapsedWorkspaceIds:w.collapsedWorkspaceIds.filter(A=>f.has(A))})),$e(w=>w&&d.has(w.id)?w:null),ct(w=>Object.fromEntries(Object.entries(w).filter(([A,W])=>W&&d.has(A))))},[e]),o.useEffect(()=>{const d=a.findIndex(f=>f.session.sessionId===C);We(f=>{const w=na(a.length,Ua,f,d);return w===f?f:w})},[C,a]),o.useEffect(()=>{wn(d=>{const f={};for(const w of e){const A=lr(w),W=A.findIndex(fe=>fe.item.sessionId===C||As([fe],C??"",ee=>ee.sessionId).length>0);f[w.workspace.id]=na(A.length,ir,d[w.workspace.id],W);for(const fe of cr(w.childWorktrees)){fe.item.sessionId===C||As([fe],C??"",Ie=>Ie.sessionId).length>0;const ee=fe.item.workspaceId;if(f[ee]!==void 0)continue;const Pe=cr(w.childWorktrees).filter(Ie=>Ie.item.workspaceId===ee&&Ie.depth===0),Le=Pe.findIndex(Ie=>Ie.item.sessionId===C||As([Ie],C??"",qe=>qe.sessionId).length>0);f[ee]=na(Pe.length,ir,d[ee],Le)}}return Oo(d,f)?d:f})},[C,e]),o.useEffect(()=>{xn(d=>{const f={};for(const w of e)for(const A of[...lr(w),...cr(w.childWorktrees)])for(const W of Pn(Dt(A))){const fe=Dt(W);if(fe.length===0)continue;const ee=Pn(fe),Pe=ee.findIndex(Le=>Le.item.sessionId===C);f[W.item.sessionId]=na(ee.length,ea,d[W.item.sessionId],Pe)}return Oo(d,f)?d:f})},[C,e]),o.useEffect(()=>{if(!C)return;const d=e.flatMap(f=>[...As(lr(f),C,w=>w.sessionId),...cr(f.childWorktrees).flatMap(w=>As([w],C,A=>A.sessionId))]);d.length!==0&&vn(f=>{const w=new Set(f);let A=!1;for(const W of d)w.has(W)||(w.add(W),A=!0);return A?Array.from(w):f})},[C,e]),o.useEffect(()=>{if(!c)return;const d=[];for(const f of e){const w=bc(f.childWorktrees,c);w.length!==0&&d.push(...w)}d.length>0&&Gt(f=>{const w=new Set(f.expandedWorkspaceIds);let A=!1;for(const W of d)w.has(W)||(w.add(W),A=!0);return A?{expandedWorkspaceIds:Array.from(w),collapsedWorkspaceIds:f.collapsedWorkspaceIds}:f})},[c,e]),o.useEffect(()=>{if(!ze){Bn(null),fn(!1),cs(!1),mn(""),Re(""),_e(""),nt(!1),et(-1),Fn(!1),Dn({localBranches:[],remoteBranches:[],tags:[]}),On(!1),Hn(null);return}fn(!1),mn(""),Re(""),_e(""),nt(!1),et(-1),Fn(!1),Dn({localBranches:[],remoteBranches:[],tags:[]}),On(!1),Hn(null)},[ze]),o.useEffect(()=>{const d=Me;if(!vt||!d)return;let f=!1;const w=d.id;return On(!0),Hn(null),Promise.all([Md(w),Pd(w)]).then(([A,W])=>{f||Dn(Hp(A,W))}).catch(()=>{f||(Dn({localBranches:[],remoteBranches:[],tags:[]}),Hn(r("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{f||On(!1)}),()=>{f=!0}},[Me==null?void 0:Me.id,vt]),o.useLayoutEffect(()=>{if(!it||!jn.current){hs(null),$t(null);return}const d=()=>{const w=jn.current;if(!w)return;const A=$p(w);hs({top:A.bottom+8,left:A.left,width:A.width})};d();const f=w=>{var W,fe;const A=w.target;A instanceof Node&&((W=jn.current)!=null&&W.contains(A)||(fe=Nn.current)!=null&&fe.contains(A)||(nt(!1),et(-1)))};return window.addEventListener("resize",d),window.addEventListener("scroll",d,!0),window.addEventListener("pointerdown",f),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),window.removeEventListener("pointerdown",f)}},[gt.length,it]),o.useLayoutEffect(()=>{if(!it||!Nn.current){$t(null);return}const d=Nn.current,f=()=>{const A=Math.ceil(d.getBoundingClientRect().height);$t(W=>W===A?W:A)};if(f(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{f()});return w.observe(d),()=>{w.disconnect()}},[it,In,bn,en]);function zs(){S(!0)}function ut(){L(!0)}function Ge(d){kt(),Ot(null),ls({kind:"workspace",workspaceId:d.id,workspaceName:d.name})}function kt(){fn(!1),mn(""),Re(""),_e(""),nt(!1),et(-1),Fn(!1)}function Vn(d,f){const w=d.getBoundingClientRect();return f<=w.top+w.height/2?"before":"after"}function vs(){zt.current!==null&&(cancelAnimationFrame(zt.current),zt.current=null),an(null)}function Xn(d){const f=(d==null?void 0:d.commit)??!1,w=(d==null?void 0:d.preserveClickSuppression)??!1,A=yt.current,W=bs.current;yt.current=null,bs.current=null,W==null||W(),A!=null&&A.dragging&&(vs(),f&&O(),!w&&qt.current===A.workspaceId&&(qt.current=null))}function le(d){if(qt.current===d){qt.current=null;return}T(d)}function Tr(d,f){if(f){Cn.current.set(d,f);return}Cn.current.delete(d)}function qs(d,f){for(const[w,A]of Cn.current){const W=A.getBoundingClientRect();if(d>=W.left&&d<=W.right&&f>=W.top&&f<=W.bottom)return{workspaceId:w,element:A}}return null}function ys(d,f){var Pe;if(!At||d.button!==0)return;Xn();const w=d.currentTarget,A={pointerId:d.pointerId,workspaceId:f,startX:d.clientX,startY:d.clientY,pointerTarget:w,dragging:!1};yt.current=A,(Pe=w.setPointerCapture)==null||Pe.call(w,d.pointerId);const W=Le=>{Rn(Le)},fe=Le=>{Ss(Le.pointerId,{commit:!0,preserveClickSuppression:!0})},ee=Le=>{Ss(Le.pointerId,{commit:!1,preserveClickSuppression:!1})};bs.current=()=>{w.removeEventListener("pointermove",W),w.removeEventListener("pointerup",fe),w.removeEventListener("pointercancel",ee),window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",fe),window.removeEventListener("pointercancel",ee)},w.addEventListener("pointermove",W),w.addEventListener("pointerup",fe),w.addEventListener("pointercancel",ee),window.addEventListener("pointermove",W,{passive:!1}),window.addEventListener("pointerup",fe),window.addEventListener("pointercancel",ee)}function Rn(d){const f=yt.current;if(!f||f.pointerId!==d.pointerId)return;if(!f.dragging){if(Math.hypot(d.clientX-f.startX,d.clientY-f.startY)<Cp)return;f.dragging=!0,qt.current=f.workspaceId,z(),an(f.workspaceId)}d.preventDefault();const w=qs(d.clientX,d.clientY);!w||w.workspaceId===f.workspaceId||Y(f.workspaceId,w.workspaceId,Vn(w.element,d.clientY))}function Ss(d,f){var A,W;const w=yt.current;!w||w.pointerId!==d||((W=(A=w.pointerTarget).releasePointerCapture)==null||W.call(A,d),Xn(f))}function Yn(d){Rn(d)}function wt(d){Ss(d.pointerId,{commit:!0,preserveClickSuppression:!0})}function He(d){Ss(d.pointerId,{commit:!1,preserveClickSuppression:!1})}function Jn(d,f){d.dataTransfer.effectAllowed="move",d.dataTransfer.setData("text/plain",f),z(),zt.current!==null&&cancelAnimationFrame(zt.current),zt.current=requestAnimationFrame(()=>{zt.current=null,an(f)})}function Rr(d,f){const w=dt||d.dataTransfer.getData("text/plain");!w||w===f||(d.preventDefault(),d.dataTransfer.dropEffect="move",Y(w,f,Vn(d.currentTarget,d.clientY)))}function js(d){d.preventDefault()}function Ns(){vs(),O()}o.useEffect(()=>()=>{Xn()},[]);function Ci(d){return Un[d]??ea}function Wt(d){return $s.includes(d)}function Nt(d){return ps[d]??ir}function Mr(){We(d=>Math.min(a.length,d+Ua))}function Ks(d,f){wn(w=>({...w,[d]:Math.min(f,(w[d]??ir)+ir)}))}function Cs(d){xn(f=>({...f,[d]:(f[d]??ea)+ea}))}function Na(d){vn(f=>f.includes(d)?f.filter(w=>w!==d):[...f,d])}function Ct(d,f){return jr.has(d)?!1:f||gs.has(d)}function Pr(d,f){const w=!Ct(d,f);Gt(A=>{const W=A.expandedWorkspaceIds.filter(ee=>ee!==d),fe=A.collapsedWorkspaceIds.filter(ee=>ee!==d);return w?{expandedWorkspaceIds:[...W,d],collapsedWorkspaceIds:fe}:{expandedWorkspaceIds:W,collapsedWorkspaceIds:[...fe,d]}})}function xt(d){for(const f of e){const w=Pn(Ni(f.visibleSessions,s)).find(A=>A.item.sessionId===d)??hc(f.childWorktrees,d);if(w)return Dt(w)}return[]}function Zn(d,f){const w=ln(d);return n.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":w.tone,style:hn(w),onClick:()=>nn(d.id),children:[n.jsxs("span",{className:"workbench-archive-folder-main",children:[n.jsx(qf,{}),n.jsx("span",{children:r("shell.archiveFolderLabel")})]}),n.jsx("span",{className:"workbench-section-counter",children:f.length})]})}function Is(){return n.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[n.jsx("span",{className:"workbench-workspace-batch-label",children:r("shell.batchSelectionMode")}),n.jsxs("span",{className:"workbench-workspace-batch-counter",children:[bt.length,"/",je.length]}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Ta,children:ws?r("shell.clearSelectedSessions"):r("shell.selectAllSessions")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:bt.length===0||ms,onClick:()=>{Ts()},children:ms?r("shell.batchArchiving"):r("shell.batchArchiveAction")}),n.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Ia,children:r("common.cancel")})]})}function Er(d,f="workbench-workspace-actions"){return n.jsxs("div",{className:f,children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.switchWorkspace"),title:r("shell.switchWorkspace"),"aria-pressed":c===d,onClick:()=>{Z(d),ie==null||ie()},children:n.jsx(Hf,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.batchSelectSessions"),title:r("shell.batchSelectSessions"),onClick:()=>Ca(d),children:n.jsx(Of,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":r("shell.createSession"),title:r("shell.createSession"),onClick:()=>Ot(d),children:n.jsx(Ef,{})})]})}function Ar(d){const f=d.visibleSessionTree,A=new Set(ni(d.children)).has(c??""),W=d.workspace.id===c||A,fe=qn||!Ct(d.workspace.id,W),ee=ln(d.workspace);return n.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":ot===d.workspace.id,"data-worktree-depth":d.meta.depth,"data-workspace-tone":"worktree",style:hn(ee),children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":fe?r("shell.worktreeExpand"):r("shell.worktreeCollapse"),onClick:()=>Pr(d.workspace.id,W),children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(dr,{expanded:!fe})}),n.jsxs("span",{children:[n.jsx("strong",{children:d.meta.displayName||d.workspace.name}),n.jsx("span",{className:"session-meta",children:d.meta.branchName})]})]}),ot===d.workspace.id?Is():Er(d.workspace.id)]}),fe?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list","data-workspace-tone":ee.tone,style:hn(ee),children:[f.length===0?n.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):f.slice(0,Nt(d.workspace.id)).map(Pe=>Qn({node:Pe,workspace:d.workspace,workspaceContext:ee,menuKeyPrefix:`worktree:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:ot===d.workspace.id,favoriteEnabled:!0})),f.length>Nt(d.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Ks(d.workspace.id,f.length),children:r("shell.sessionExpandMore")}):null]}),d.children.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.children.map(Pe=>Ar(Pe))}):null,Zn(d.workspace,d.archivedSessions)]})]},d.workspace.id)}function Qn(d){var er;const{node:f,workspace:w,workspaceContext:A,menuKeyPrefix:W,showWorkspaceName:fe,selectionMode:ee,favoriteEnabled:Pe,ancestorExpanded:Le=!1,allowToggle:Ie=f.depth===0,ancestorHasNextSiblings:qe=[],hasNextSibling:ht=!1,isFirstSibling:cn=!1}=d,pe=f.item,dn=Dt(f),Lt=Le||Wt(pe.sessionId),Be=Lt&&Ie,Fr=Be?tf(f,Ci(pe.sessionId),s):f,es=Lt?Dt(Fr):[],Or=Pn(dn).length,Hr=Pn(es).length,$r=Be&&Hr<Or,Zs=f.depth>0?[...qe,ht]:[...qe],Qs=Lt&&((er=pe.parallelGroup)==null?void 0:er.role)==="anchor"&&dn.some(pt=>{var ft,tr,nr;return((tr=(ft=sc(pt))==null?void 0:ft.parallelGroup)==null?void 0:tr.groupId)===((nr=pe.parallelGroup)==null?void 0:nr.groupId)});return n.jsxs("div",{className:"workbench-session-tree-node",children:[n.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":f.depth},children:[f.depth>0?n.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[qe.map((pt,ft)=>pt?n.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":ft+1}},`${pe.sessionId}:ancestor:${ft}`):null),n.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":ht,"data-first":cn,style:{"--workbench-session-tree-level":f.depth},children:n.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,n.jsx(el,{menuKey:`${W}:${pe.sessionId}`,session:pe,workspace:w,workspaceContext:A,isActive:pe.sessionId===C,isFavorite:Pe&&i.has(pe.sessionId),menuOpen:Pt===`${W}:${pe.sessionId}`,showWorkspaceName:fe,depth:f.depth,showActions:Pe,hasSubagents:Ie&&dn.length>0,subagentListExpanded:Lt,selectionMode:ee,selected:Kn.has(pe.sessionId),onToggleSelect:()=>Wr(pe.sessionId),onToggleSubagents:()=>Na(pe.sessionId),onOpen:()=>{ve(Tt(w.id,pe.sessionId)),ie==null||ie()},onRename:()=>Vs(pe,w),menuAnchorPoint:Pt===`${W}:${pe.sessionId}`?Sr:null,onOpenContextMenu:pt=>Nr(`${W}:${pe.sessionId}`,pt),onToggleFavorite:()=>Lr(pe.sessionId),onArchive:()=>Br(pe.sessionId),onDelete:da(pe.provider).supportsSessionDelete===!0?()=>{tt(),$n({session:pe,workspace:w})}:void 0,onCloseMenu:tt})]}),dn.length>0&&Lt?n.jsxs("div",{className:"workbench-subsession-list",children:[Qs?n.jsx("div",{className:"workbench-session-tree-node",children:n.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":f.depth+1},children:[n.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[Zs.map((pt,ft)=>pt?n.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":ft+1}},`parallel-anchor-replica:${pe.sessionId}:ancestor:${ft}`):null),n.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":es.length>0,"data-first":"true",style:{"--workbench-session-tree-level":f.depth+1},children:n.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}),n.jsx(el,{menuKey:`${W}:parallel-anchor-replica:${pe.sessionId}`,session:pe,workspace:w,workspaceContext:A,isActive:!1,isFavorite:Pe&&i.has(pe.sessionId),menuOpen:Pt===`${W}:parallel-anchor-replica:${pe.sessionId}`,showWorkspaceName:fe,depth:f.depth+1,showActions:Pe,hasSubagents:!1,subagentListExpanded:!1,selectionMode:ee,selected:Kn.has(pe.sessionId),onToggleSelect:()=>Wr(pe.sessionId),onOpen:()=>{ve(Tt(w.id,pe.sessionId)),ie==null||ie()},onRename:()=>Vs(pe,w),menuAnchorPoint:Pt===`${W}:parallel-anchor-replica:${pe.sessionId}`?Sr:null,onOpenContextMenu:pt=>Nr(`${W}:parallel-anchor-replica:${pe.sessionId}`,pt),onToggleFavorite:()=>Lr(pe.sessionId),onArchive:()=>Br(pe.sessionId),onDelete:da(pe.provider).supportsSessionDelete===!0?()=>{tt(),$n({session:pe,workspace:w})}:void 0,onCloseMenu:tt})]})},`parallel-anchor-replica:${pe.sessionId}`):null,es.map((pt,ft)=>Qn({node:pt,workspace:w,workspaceContext:A,menuKeyPrefix:W,showWorkspaceName:fe,selectionMode:ee,favoriteEnabled:Pe,ancestorExpanded:!0,allowToggle:!1,ancestorHasNextSiblings:Zs,hasNextSibling:ft<es.length-1,isFirstSibling:!Qs&&ft===0})),$r?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Cs(pe.sessionId),children:r("shell.subagentExpandMore")}):null]}):null]},pe.sessionId)}function Ca(d){tt(),rn(d),lt([])}function Ia(){rn(null),lt([])}function Wr(d){lt(f=>Sf(f,d))}function Ta(){lt(d=>d.length===je.length?[]:je)}async function Ra(d,f){Ze(d),os(f);try{await rc(d,f),Ot(null),ve(El(d,f)),ie==null||ie()}catch(w){de({title:w instanceof Error?w.message:r("shell.startSessionFailed"),tone:"error"})}finally{Ze(null),os(null)}}async function Ma(d){if(d.preventDefault(),!Me||Qe)return;const f=Hs.trim(),w=vr.trim(),A=ds.trim();if(!f){de({title:r("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!Fp(f)){de({title:r("shell.createWorktreeBranchInvalid"),tone:"error"});return}cs(!0);try{const W=await bd({sourceWorkspaceId:Me.id,branchName:f,displayName:w||void 0,baseRef:A||void 0});Bn(W.workspace),Z(W.workspace.id),await R(),Ot(W.workspace.id),kt(),de({title:r("shell.createWorktreeSucceeded",{name:W.meta.displayName||W.workspace.name}),tone:"success"})}catch(W){de({title:W instanceof Error?W.message:r("shell.createWorktreeFailed"),tone:"error"})}finally{cs(!1)}}async function Lr(d){const f=i.has(d);tt();try{await K(d),de({title:f?r("shell.favoriteRemoved"):r("shell.favoriteAdded"),tone:"success"})}catch(w){de({title:w instanceof Error?w.message:r("shell.favoriteToggleFailed"),tone:"error"})}}async function Br(d){tt();try{await Q(d),de({title:r("shell.archiveAdded"),tone:"success"})}catch(f){de({title:f instanceof Error?f.message:r("shell.navigationLoadFailed"),tone:"error"})}}async function on(){if(!gn||Ut)return;const{session:d,workspace:f}=gn;kn(d.sessionId),tt();try{await fd(d.sessionId),lt(w=>w.filter(A=>A!==d.sessionId)),$n(null),C===d.sessionId&&ve(f.id?mr(f.id):mt()),await R(),de({title:r("shell.deleteSessionSuccess"),tone:"success"})}catch(w){de({title:w instanceof Error?w.message:r("shell.deleteSessionFailed"),tone:"error"})}finally{kn(null)}}async function Ts(){if(!(bt.length===0||ms)){tt(),Us(!0);try{const d=[...bt],f=await Promise.allSettled(d.map(async W=>({sessionId:W,session:await ul(W,!0)}))),w=[];let A=0;for(const W of f){if(W.status==="fulfilled"){w.push(W.value.sessionId),H(W.value.session);continue}A+=1}w.length>0&&(await R(),lt(W=>W.filter(fe=>!w.includes(fe)))),A>0?de({title:w.length>0?r("shell.batchArchivePartialFailed"):r("shell.batchArchiveFailed"),tone:"error"}):de({title:r("shell.batchArchiveSuccess"),tone:"success"})}catch(d){de({title:d instanceof Error?d.message:r("shell.batchArchiveFailed"),tone:"error"})}finally{Us(!1)}}}async function Rs(d){tt();try{await D(d),de({title:r("shell.archiveRestored"),tone:"success"})}catch(f){de({title:f instanceof Error?f.message:r("shell.navigationLoadFailed"),tone:"error"})}}function Vs(d,f){tt(),yn({session:d,workspace:f}),zn(d.title)}async function Dr(d){if(d.preventDefault(),!Ve)return;const f=Gn.trim();if(f){Sn(Ve.session.sessionId);try{const w=await pl(Ve.session.sessionId,f);H(w),yn(null),zn(""),de({title:r("shell.renameSuccess"),tone:"success"})}catch(w){de({title:w instanceof Error?w.message:r("shell.renameFailed"),tone:"error"})}finally{Sn(null)}}}const Xs=a.slice(0,Et),Ys=Xs.length<a.length;function ln(d){return t[d.id]??ma(d)}function _r(d,f,w,A,W=[]){var Lt;const fe=Se.includes(d.id),ee=y[d.id]??{detail:null,loading:!1,error:null},Pe=Oe===d.id,Le=rt[d.id]===!0,Ie=(Lt=ee.detail)!=null&&Lt.git.remotes.length?ee.detail.git.remotes.map(Be=>`${Be.name}: ${Be.url}`).join(" · "):r("shell.manageWorkspaceNoRemote"),qe=ee.detail?Nh(ee.detail.codeComposition.items,r("shell.manageWorkspaceCodeCompositionOther")):[],ht=qe.length>0?Ih(qe):void 0,cn=ln(d),pe=gf(cn,W),dn=[...W,cn.displayName];return n.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":cn.tone,"data-worktree-node":A,style:hn(cn),children:[n.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":fe,onClick:()=>Cr(d.id),children:[n.jsxs("span",{className:"workbench-manage-item-heading",children:[n.jsx(dr,{expanded:fe}),n.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[n.jsx("strong",{children:cn.displayName}),n.jsx("span",{className:"workbench-manage-item-tree-path",children:pe})]})]}),n.jsx("span",{className:"workbench-section-counter",children:f})]}),fe?n.jsxs("div",{className:"workbench-manage-item-body",children:[n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspacePathLabel")}),n.jsx("p",{className:"workbench-manage-detail-value",children:d.path})]}),A?n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceColorLabel")}),n.jsxs("div",{className:"workbench-manage-color-actions",children:[n.jsx("div",{className:"workbench-manage-color-palette","aria-label":r("shell.manageWorkspaceColorLabel"),children:Mp.map(Be=>n.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":r("shell.manageWorkspaceColorSelectSwatch",{color:Be}),"aria-pressed":d.backgroundColor===Be,disabled:Le,"data-selected":d.backgroundColor===Be,style:{backgroundColor:Be},onClick:()=>{Gs(d.id,Be)}},Be))}),n.jsx("button",{type:"button",className:"ghost-button",disabled:Le||!d.backgroundColor,onClick:()=>{Gs(d.id,null)},children:r("shell.manageWorkspaceColorClearAction")})]})]}),n.jsx("p",{className:"workbench-manage-hint",children:d.backgroundColor??r("shell.manageWorkspaceColorUnset")})]}):null,ee.loading&&ee.detail===null?n.jsx("p",{className:"workbench-manage-status status-text",children:r("shell.manageWorkspaceLoading")}):null,ee.error?n.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:ee.error}):null,ee.detail?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-manage-detail-block",children:n.jsxs("div",{className:"workbench-manage-detail-header",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitCommitCount")}),n.jsx("strong",{className:"workbench-manage-detail-accent",children:ee.detail.git.commitCount??"--"})]})}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceGitInfoLabel")}),ee.detail.git.isRepository?n.jsxs("div",{className:"workbench-manage-kv-list",children:[n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceRepoRoot")}),n.jsx("span",{children:ee.detail.git.repoRoot??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceCurrentBranch")}),n.jsx("span",{children:ee.detail.git.currentBranch??"--"})]}),n.jsxs("div",{className:"workbench-manage-kv-item",children:[n.jsx("span",{children:r("shell.manageWorkspaceRemoteLabel")}),n.jsx("span",{children:Ie})]})]}):n.jsx("p",{className:"workbench-section-empty",children:ee.detail.git.error??r("shell.manageWorkspaceNotGit")})]}),n.jsxs("div",{className:"workbench-manage-detail-block",children:[n.jsx("span",{className:"workbench-manage-detail-label",children:r("shell.manageWorkspaceCodeCompositionLabel")}),qe.length>0?n.jsxs("div",{className:"workbench-manage-type-chart",children:[n.jsxs("div",{className:"workbench-manage-type-chart-ring",style:ht,"aria-hidden":"true",children:[n.jsx("strong",{className:"workbench-manage-type-chart-total",children:ee.detail.codeComposition.scannedFileCount}),n.jsx("span",{className:"workbench-manage-type-chart-caption",children:r("shell.manageWorkspaceCodeCompositionFiles")})]}),n.jsx("div",{className:"workbench-manage-type-list",children:qe.map(Be=>n.jsxs("div",{className:"workbench-manage-type-item",children:[n.jsxs("span",{className:"workbench-manage-type-meta",children:[n.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:Be.color},"aria-hidden":"true"}),n.jsx("span",{className:"workbench-manage-type-name",children:Be.type})]}),n.jsxs("span",{children:[Be.count," · ",jh(Be)]})]},Be.key))})]}):n.jsx("p",{className:"workbench-section-empty",children:ee.detail.codeComposition.error??r("shell.manageWorkspaceNoCodeComposition")}),ee.detail.codeComposition.truncated?n.jsx("p",{className:"workbench-manage-hint",children:r("shell.manageWorkspaceCodeTruncated",{count:ee.detail.codeComposition.scannedFileCount})}):null]})]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{re(!1),ve(Il(d.id))},children:r("shell.workspaceDetailDebugOpenPageAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Oe,onClick:()=>$e(d),children:Pe?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveAction")})]})]}):null,w.length>0?n.jsx("div",{className:"workbench-manage-children",children:w.map(Be=>_r(Be.workspace,Be.visibleSessions.length+Be.archivedSessions.length,Be.children,!0,dn))}):null]},d.id)}return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":he,children:n.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":he,children:[oe?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideSessionSidebar"),title:r("shell.hideSessionSidebar"),onClick:oe,children:n.jsx(Tc,{})}):null,n.jsx(Ql,{}),n.jsx(Ic,{unreadCount:q,open:se,onToggle:Ce})]})}),n.jsxs("div",{className:"workbench-nav-body",children:[n.jsxs("div",{className:"workbench-nav-segment",children:[n.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":r("shell.centerTabsLabel"),children:[n.jsxs("div",{className:"workbench-nav-segment-pair",children:[n.jsxs("button",{type:"button",className:h?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":h,onClick:G,children:[n.jsx(Wf,{}),n.jsx("span",{children:r("shell.conversationEntry")})]}),n.jsxs("button",{type:"button",className:k?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":k,onClick:v,children:[n.jsx(Bf,{}),n.jsx("span",{children:r("shell.butlerEntry")})]})]}),n.jsxs("button",{type:"button",className:p?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":p,onClick:E,children:[n.jsx(Lf,{}),n.jsx("span",{children:r("shell.terminalsEntry")})]})]}),n.jsx(Xu,{triggerClassName:"workbench-nav-segment-button",triggerLabel:r("shell.skillsEntry"),triggerLeading:n.jsx(Df,{})}),n.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":m,"aria-haspopup":"dialog","aria-expanded":m,onClick:_,children:[n.jsx(Af,{}),n.jsx("span",{children:r("shell.searchEntry")})]})]}),N?n.jsx("div",{className:"workbench-status-row",children:n.jsx("p",{className:"status-text","data-tone":"error",children:N})}):null,a.length>0?n.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsxs("div",{className:"workbench-section-heading-main",children:[n.jsx(Rc,{active:!0,className:"workbench-favorite-heading-icon"}),n.jsx("span",{children:r("shell.favoriteSectionTitle")})]}),n.jsx("span",{className:"workbench-section-counter",children:a.length})]}),n.jsxs("div",{className:"workbench-session-list",children:[Xs.map(d=>{const f=xt(d.session.sessionId);return n.jsx("div",{children:Qn({node:{item:d.session,depth:0,children:f},workspace:d.workspace,workspaceContext:ln(d.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},d.session.sessionId)}),Ys?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:Mr,children:r("shell.favoriteExpandMore")}):null]})]}):null,x&&e.length===0?n.jsx(Cf,{}):null,!x&&!N&&e.length===0?n.jsx("div",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.emptyNavigationBody")})}):null,n.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[n.jsxs("div",{className:"workbench-section-heading",children:[n.jsx("div",{className:"workbench-section-heading-main",children:n.jsx("span",{children:r("shell.workspaceSectionTitle")})}),n.jsxs("div",{className:"workbench-section-actions",children:[n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.manageWorkspaceAction"),title:r("shell.manageWorkspaceAction"),onClick:()=>re(!0),children:n.jsx(Rf,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.importWorkspaceTitle"),title:r("shell.importWorkspaceTitle"),onClick:zs,children:n.jsx(Tf,{})}),n.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":r("shell.cloneWorkspaceTitle"),title:r("shell.cloneWorkspaceTitle"),onClick:ut,children:n.jsx(_f,{})})]})]}),e.map(d=>{const f=lr(d),w=dt===d.workspace.id,A=d.isCollapsed||qn;return n.jsxs("section",{className:"workbench-workspace-group",ref:W=>Tr(d.workspace.id,W),"data-workspace-group-id":d.workspace.id,"data-batch-active":ot===d.workspace.id,"data-dragging":w,onDragOver:W=>Rr(W,d.workspace.id),onDrop:js,children:[n.jsxs("div",{className:"workbench-workspace-header minimal",children:[n.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":A?r("shell.workspaceExpand"):r("shell.workspaceCollapse"),draggable:j&&!At,onClick:()=>le(d.workspace.id),onPointerDown:At?W=>ys(W,d.workspace.id):void 0,onPointerMove:At?Yn:void 0,onPointerUp:At?wt:void 0,onPointerCancel:At?He:void 0,onDragStart:j&&!At?W=>Jn(W,d.workspace.id):void 0,onDragEnd:j&&!At?Ns:void 0,"data-reorder-enabled":j?"true":void 0,children:[n.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:n.jsx(dr,{expanded:!A})}),n.jsx("strong",{children:d.workspace.name})]}),ot===d.workspace.id?Is():Er(d.workspace.id)]}),A?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-session-list",children:[f.length===0?n.jsx("p",{className:"workbench-session-empty",children:r("shell.emptyWorkspaceSessions")}):f.slice(0,Nt(d.workspace.id)).map(W=>Qn({node:W,workspace:d.workspace,workspaceContext:ln(d.workspace),menuKeyPrefix:`workspace:${d.workspace.id}`,showWorkspaceName:!1,selectionMode:ot===d.workspace.id,favoriteEnabled:!0})),f.length>Nt(d.workspace.id)?n.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>Ks(d.workspace.id,f.length),children:r("shell.sessionExpandMore")}):null]}),d.childWorktrees.length>0?n.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:d.childWorktrees.map(W=>Ar(W))}):null,Zn(d.workspace,d.archivedSessions)]})]},d.workspace.id)})]})]}),n.jsx("div",{className:"workbench-nav-footer minimal",children:n.jsxs("div",{className:"workbench-nav-footer-actions",children:[n.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:F,title:V?`${r("settings.title")} · ${ye}`:r("settings.title"),children:[n.jsx(Ff,{}),n.jsx("span",{className:"settings-entry-label",children:r("settings.title")}),V?n.jsx("span",{className:"workbench-nav-settings-host-badge",title:ye,children:ye}):null]}),n.jsx(gp,{onOpenSoftwareUpdate:()=>ve("/settings/software-update")})]})}),n.jsx(Ye,{open:we,title:r("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:r("shell.manageWorkspaceDescription"),headerActions:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:zs,children:r("shell.manageWorkspaceImportAction")}),n.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:ut,children:r("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{Oe||re(!1)},children:e.length>0?n.jsx("div",{className:"workbench-manage-list",children:e.map(d=>_r(d.workspace,d.visibleSessions.length+d.archivedSessions.length,d.childWorktrees,!1))}):n.jsx("p",{className:"workbench-section-empty",children:r("shell.manageWorkspaceEmpty")})}),n.jsxs(Ye,{open:gn!==null,title:r("shell.deleteSessionConfirmTitle"),description:r("shell.deleteSessionConfirmDescription"),onClose:()=>{Ut||$n(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:gn?gn.session.title:""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!Ut,onClick:()=>$n(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Ut,onClick:()=>{on()},children:Ut?r("common.loading"):r("shell.deleteSessionAction")})]})]}),n.jsxs(Ye,{open:Ae!==null,title:r("shell.manageWorkspaceRemoveConfirmTitle"),description:r("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{Oe||$e(null)},children:[n.jsx("p",{className:"workbench-section-empty",children:Ae?r("shell.manageWorkspaceRemoveConfirmTarget",{name:Ae.name}):""}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!Oe,onClick:()=>$e(null),children:r("common.cancel")}),n.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Oe,onClick:()=>{Ir()},children:Oe?r("shell.manageWorkspaceRemoving"):r("shell.manageWorkspaceRemoveConfirmAction")})]})]}),n.jsx(lp,{open:B,onClose:()=>L(!1),onCloned:xs}),n.jsx(bp,{open:g,onClose:()=>S(!1),onImported:Vt}),n.jsx(wp,{open:Rt!==null,source:Rt,onClose:()=>ls(null),onCreated:async d=>{d.members.forEach(w=>{H(w.session)}),Od(d.group.id),await R();const f=d.members.find(w=>w.session.sessionId===d.group.anchorSessionId)??d.members[0]??null;f&&ve(Tt(_d(f.session,f.sessionIsolatedWorkspace),f.session.sessionId)),ls(null),de({title:r("shell.parallelCreateSucceeded"),tone:"success"})}}),n.jsx(Ye,{open:Me!==null,title:r("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:Me?`${r("shell.createSessionTarget")} · ${Me.name}`:r("shell.createSessionModalDescription"),headerActions:n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:Qe||!!De||!Me,onClick:()=>{Me&&Ge(Me)},children:r("shell.parallelCreateAction")}),n.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:Qe||!!De,onClick:()=>fn(!0),children:r("shell.createWorktreeAction")})]}),onClose:()=>Ot(null),children:n.jsxs("section",{className:"create-session-modal-section",children:[n.jsxs("div",{className:"create-session-modal-section-header",children:[n.jsx("strong",{children:r("shell.createSessionProviderLabel")}),n.jsx("span",{children:r("shell.providerOptionHint")})]}),n.jsx(pd,{disabled:!!De||Qe,workspaceId:(Me==null?void 0:Me.id)??null,pendingProvider:De===(Me==null?void 0:Me.id)?Ue??null:null,onSelect:d=>{Me&&Ra(Me.id,d)}})]})}),n.jsx(Ye,{open:Me!==null&&vt,title:r("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:n.jsx("button",{type:"button",className:us?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":r("shell.createWorktreeHelpAction"),title:r("shell.createWorktreeHelpAction"),"aria-pressed":us,onClick:()=>Fn(d=>!d),children:n.jsx(Kf,{})}),description:Me?`${r("shell.createWorktreeSectionDescription")} ${r("shell.createSessionTarget")} · ${Me.name}`:r("shell.createWorktreeSectionDescription"),onClose:kt,children:n.jsxs("form",{className:"create-session-worktree-form",onSubmit:Ma,children:[us?n.jsxs("section",{className:"create-session-worktree-help-card","aria-label":r("shell.createWorktreeHelpTitle"),children:[n.jsx("strong",{children:r("shell.createWorktreeHelpTitle")}),n.jsxs("div",{className:"create-session-worktree-help-grid",children:[n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpBranchTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpBranchBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpDisplayNameTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpDisplayNameBody")})]}),n.jsxs("article",{children:[n.jsx("h3",{children:r("shell.createWorktreeHelpBaseRefTitle")}),n.jsx("p",{children:r("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeBranchLabel")}),n.jsx("input",{className:"settings-text-input",value:Hs,placeholder:r("shell.createWorktreeBranchPlaceholder"),onChange:d=>{const f=d.target.value;Op(f)&&mn(f)}})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeDisplayNameLabel")}),n.jsx("input",{className:"settings-text-input",value:vr,placeholder:r("shell.createWorktreeDisplayNamePlaceholder"),onChange:d=>Re(d.target.value)})]}),n.jsxs("label",{className:"create-session-worktree-field",children:[n.jsx("span",{children:r("shell.createWorktreeBaseRefLabel")}),n.jsx("div",{className:"create-session-worktree-combobox",ref:jn,onBlurCapture:d=>{var w,A;const f=d.relatedTarget;f instanceof Node&&((w=jn.current)!=null&&w.contains(f)||(A=Nn.current)!=null&&A.contains(f))||(nt(!1),et(-1))},children:n.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[n.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":it,"aria-controls":Kt,value:ds,placeholder:r("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{nt(!0),et(gt.length>0?0:-1)},onChange:d=>{_e(d.target.value),nt(!0),et(gt.length>0?0:-1)},onKeyDown:d=>{if(d.key==="ArrowDown"){if(d.preventDefault(),!it){nt(!0);return}gt.length>0&&et(f=>f>=gt.length-1?0:f+1);return}if(d.key==="ArrowUp"){if(d.preventDefault(),!it){nt(!0);return}gt.length>0&&et(f=>f<=0?gt.length-1:f-1);return}if(d.key==="Enter"&&it&&_n>=0){d.preventDefault();const f=gt[_n];f&&(_e(f.value),nt(!1),et(-1));return}d.key==="Escape"&&nt(!1)}}),n.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":r("shell.createWorktreeBaseRefToggle"),"aria-expanded":it,onClick:()=>{nt(d=>!d),et(!it&>.length>0?0:-1)},children:n.jsx(dr,{expanded:it})})]})}),n.jsx("span",{className:"create-session-worktree-field-hint",children:bn?r("shell.createWorktreeBaseRefLoading"):en||r("shell.createWorktreeBaseRefHint",{localCount:Ht.localBranches.length,remoteCount:Ht.remoteBranches.length,tagCount:Ht.tags.length})})]}),it&&tn&&typeof document<"u"?gr.createPortal(n.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[n.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${tn.top}px`,"--create-worktree-combobox-left":`${tn.left}px`,"--create-worktree-combobox-width":`${tn.width}px`,"--create-worktree-combobox-height":`${Sa??0}px`}}),n.jsx("div",{ref:Nn,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${tn.top}px`,"--create-worktree-combobox-left":`${tn.left}px`,"--create-worktree-combobox-width":`${tn.width}px`},children:bn?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefLoading")}):en?n.jsx("p",{className:"create-session-worktree-combobox-empty",children:en}):In.length>0?n.jsx("div",{id:Kt,className:"create-session-worktree-combobox-list",role:"listbox",children:In.map(d=>n.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":d.label,children:[n.jsx("header",{className:"create-session-worktree-combobox-group-title",children:d.label}),n.jsx("div",{className:"create-session-worktree-combobox-group-options",children:d.items.map(f=>{const w=gt.findIndex(fe=>fe.value===f.value),A=ds===f.value,W=_n===w;return n.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":A,"data-highlighted":W,onMouseDown:fe=>fe.preventDefault(),onMouseEnter:()=>et(w),onClick:()=>{_e(f.value),nt(!1),et(-1)},children:[n.jsx("span",{className:"create-session-worktree-combobox-option-label",children:f.value}),n.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[f.current?n.jsx("span",{className:"create-session-worktree-combobox-badge",children:r("shell.createWorktreeBaseRefCurrentBadge")}):null,f.recommended?n.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:r("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${d.key}:${f.value}`)})})]},d.key))}):n.jsx("p",{className:"create-session-worktree-combobox-empty",children:r("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:Qe,onClick:kt,children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:Qe,children:Qe?r("shell.createWorktreeSubmitting"):r("shell.createWorktreeSubmit")})]})]})}),n.jsx(Ye,{open:St!==null,title:r("shell.archiveModalTitle"),description:St?`${St.workspace.name} · ${r("shell.archiveModalDescription")}`:r("shell.archiveModalDescription"),onClose:()=>nn(null),children:St&&St.archivedSessions.length>0?n.jsx("div",{className:"workbench-archive-list","data-workspace-tone":(jt==null?void 0:jt.tone)??"root",style:hn(jt),children:St.archivedSessions.map(d=>{const f=yi(d.title,r("common.unknown"));return n.jsxs("article",{className:"workbench-archive-item","data-workspace-tone":(jt==null?void 0:jt.tone)??"root",style:hn(jt),children:[n.jsxs("div",{className:"workbench-archive-item-main",children:[n.jsx("strong",{title:f.fullTitle,children:f.displayTitle}),n.jsxs("p",{children:[lc(d,St.workspace,!1)," ·"," ",va(d.provider)]})]}),n.jsx("button",{type:"button",className:"secondary-button",onClick:()=>Rs(d.sessionId),children:r("shell.unarchiveAction")})]},d.sessionId)})}):n.jsx("p",{className:"workbench-section-empty",children:r("shell.archiveEmpty")})}),n.jsx(Ye,{open:Ve!==null,title:r("shell.renameModalTitle"),description:r("shell.renameModalDescription"),onClose:()=>{fs||(yn(null),zn(""))},children:n.jsxs("form",{className:"workbench-rename-form",onSubmit:Dr,children:[n.jsxs("label",{className:"workbench-modal-field",children:[n.jsx("span",{children:r("shell.renameInputLabel")}),n.jsx("input",{type:"text",value:Gn,placeholder:r("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:d=>zn(d.target.value)})]}),n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!fs,onClick:()=>{yn(null),zn("")},children:r("common.cancel")}),n.jsx("button",{type:"submit",className:"primary-button",disabled:!Gn.trim()||fs===(Ve==null?void 0:Ve.session.sessionId),children:fs===(Ve==null?void 0:Ve.session.sessionId)?r("shell.renamingSession"):r("common.save")})]})]})})]})}function nl({panelReady:e,activeTab:t,fileRevealRequest:s,onTabChange:a,onToggleCollapse:i,currentSessionId:c,activeWorkspaceId:h,navigationGroups:p,workspaceContext:k,worktreeMeta:m,worktreeMergeState:x,onRefreshWorktreeMergePreview:N,onApplyWorktreeMerge:C,onCleanupWorktree:R}){var ue;const H=h??((ue=p[0])==null?void 0:ue.workspace.id)??null,G=Ln(),E=Ol(G),{showToast:v}=as(),_=o.useRef(null),F=o.useRef(null),Z=G.isDesktop&&G.bridge.supported,T=Z&&!!h,z=Z&&!!H,Y=Z&&!!H,O=typeof globalThis<"u"&&"PointerEvent"in globalThis,j=o.useCallback(async(K,Q,D)=>{if(K==="files"){const I=await Uu(G,{workspaceId:Q,sessionId:D,focusOwner:"file-context-panel"});I.ok||v({title:I.detail??r("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(K==="git"){const I=await Gu(G,{workspaceId:Q,focusOwner:"git-sidebar"});I.ok||v({title:I.detail??r("git.openExternalFailed"),tone:"error"});return}const y=await zu(G,{workspaceId:Q,focusOwner:"terminal-manager-panel"});y.ok||v({title:y.detail??r("terminalManager.openExternalFailed"),tone:"error"})},[G,v]),J=o.useCallback((K,Q)=>{if(K.button!==0||!Z)return;const D=Q==="files"?h:Q==="git"||Q==="terminals"?H:null;if(!D)return;const y=Q==="files"?c:null;_.current={tab:Q,startX:K.clientX,startY:K.clientY,workspaceId:D,sessionId:y,detached:!1,preview:null};const I=ie=>{var he;const oe=_.current;if(!oe)return;const ve=Math.abs(ie.clientX-oe.startX),ke=Math.abs(ie.clientY-oe.startY);!oe.detached&&Math.max(ve,ke)<Lo||(oe.detached||(oe.detached=!0,F.current=oe.tab,oe.preview=Zi({title:oe.tab==="files"?r("shell.filesEntry"):oe.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:ie.clientX,y:ie.clientY})),(he=oe.preview)==null||he.updatePosition(ie.clientX,ie.clientY))},q=ie=>{var ve;const oe=(ve=_.current)==null?void 0:ve.preview;ie&&(oe==null||oe.cancel()),window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",se),window.removeEventListener("blur",Ce),_.current=null},se=async()=>{var oe;const ie=_.current;q(!1),ie!=null&&ie.detached&&(await((oe=ie.preview)==null?void 0:oe.complete()),await j(ie.tab,ie.workspaceId,ie.sessionId))},Ce=()=>{q(!0)};window.addEventListener("mousemove",I),window.addEventListener("mouseup",se),window.addEventListener("blur",Ce)},[h,Z,c,H,j]),te=o.useCallback((K,Q)=>{if(K.button!==0||!Z)return;const D=Q==="files"?h:Q==="git"||Q==="terminals"?H:null;if(!D)return;const y=K.currentTarget,I=K.pointerId;y.setPointerCapture(I);const q=Q==="files"?c:null;_.current={tab:Q,startX:K.clientX,startY:K.clientY,workspaceId:D,sessionId:q,detached:!1,preview:null};const se=ke=>{var ye;if(ke.pointerId!==I)return;const he=_.current;if(!he)return;const de=Math.abs(ke.clientX-he.startX),ge=Math.abs(ke.clientY-he.startY);!he.detached&&Math.max(de,ge)<Lo||(he.detached||(he.detached=!0,F.current=he.tab,he.preview=Zi({title:he.tab==="files"?r("shell.filesEntry"):he.tab==="git"?r("shell.gitEntry"):r("shell.terminalManagerEntry"),x:ke.clientX,y:ke.clientY})),(ye=he.preview)==null||ye.updatePosition(ke.clientX,ke.clientY))},Ce=ke=>{var de;const he=(de=_.current)==null?void 0:de.preview;ke&&(he==null||he.cancel()),y.removeEventListener("pointermove",se),y.removeEventListener("pointerup",ie),y.removeEventListener("pointercancel",oe),y.removeEventListener("lostpointercapture",oe),window.removeEventListener("blur",ve),_.current=null,y.hasPointerCapture(I)&&y.releasePointerCapture(I)},ie=async ke=>{var de;if(ke.pointerId!==I)return;const he=_.current;Ce(!1),he!=null&&he.detached&&(await((de=he.preview)==null?void 0:de.complete()),await j(he.tab,he.workspaceId,he.sessionId))},oe=ke=>{ke.pointerId===I&&Ce(!0)},ve=()=>{Ce(!0)};y.addEventListener("pointermove",se),y.addEventListener("pointerup",ie),y.addEventListener("pointercancel",oe),y.addEventListener("lostpointercapture",oe),window.addEventListener("blur",ve)},[h,Z,c,H,j]),P=o.useCallback(K=>{if(F.current===K){F.current=null;return}a(K)},[a]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(k==null?void 0:k.tone)??"root",style:hn(k),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":E,children:[i?n.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":r("shell.hideInfoSidebar"),title:r("shell.hideInfoSidebar"),onClick:i,children:n.jsx(Tc,{})}):null,n.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":r("shell.infoTabsLabel"),"data-tauri-drag-region":E,children:[n.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:T?"拖拽标签到独立窗口":void 0,onPointerDown:K=>te(K,"files"),onMouseDown:O?void 0:K=>J(K,"files"),onClick:()=>P("files"),children:r("shell.filesEntry")}),n.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:z?"拖拽标签到独立窗口":void 0,onPointerDown:K=>te(K,"git"),onMouseDown:O?void 0:K=>J(K,"git"),onClick:()=>P("git"),children:r("shell.gitEntry")}),n.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:Y?"拖拽标签到独立窗口":void 0,onPointerDown:K=>te(K,"terminals"),onMouseDown:O?void 0:K=>J(K,"terminals"),onClick:()=>P("terminals"),children:r("shell.terminalManagerEntry")})]})]}),n.jsxs("div",{className:"workbench-auxiliary-body",children:[e?null:n.jsx(aa,{}),e&&t==="git"&&m?n.jsx(Xf,{meta:m,state:x,onRefresh:()=>N(m.workspaceId,!0),onApply:()=>C(m.workspaceId),onCleanup:()=>R(m)}):null,e&&t==="files"?h?n.jsx(o.Suspense,{fallback:n.jsx(aa,{}),children:n.jsx(Yp,{sessionId:c,workspaceId:h,externalRevealRequest:s})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.filesPanelEmpty")})}):null,e&&t==="git"?H?n.jsx(o.Suspense,{fallback:n.jsx(aa,{}),children:n.jsx(Jp,{workspaceId:H})}):n.jsx("section",{className:"workbench-empty-state minimal",children:n.jsx("p",{children:r("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?n.jsx(o.Suspense,{fallback:n.jsx(aa,{}),children:n.jsx(Zp,{currentWorkspaceId:h,navigationGroups:p})}):null]})]})}function Xf({meta:e,state:t,onRefresh:s,onApply:a,onCleanup:i}){const[c,h]=o.useState(!1),p=(t==null?void 0:t.preview)??null,k=(t==null?void 0:t.loading)??!1,m=(t==null?void 0:t.applying)??!1,x=(t==null?void 0:t.cleaning)??!1,N=p!==null,C=(p==null?void 0:p.alreadyMerged)===!0,R=new Set((p==null?void 0:p.blockers.map(P=>P.code))??[]),H=R.size>0||!!(t!=null&&t.error),G=C&&!H,E=(p==null?void 0:p.canMerge)===!0&&!k&&!m&&!x&&!G,v=G&&!k&&!m&&!x&&!R.has("SOURCE_DIRTY")&&!R.has("HAS_ACTIVE_CHILDREN"),_=k||m||x?"loading":H?"blocked":G?"merged":p!=null&&p.canMerge?"ready":N?"blocked":"idle",F=(p==null?void 0:p.targetWorkspace.name)??r("common.unknown"),Z=(p==null?void 0:p.sourceBranchName)??e.branchName,T=(p==null?void 0:p.targetBranchName)??e.baseRef??r("common.unknown"),z=Jf({t:r,hasPreview:N,showMergedState:G,isMerged:C,canMerge:(p==null?void 0:p.canMerge)===!0,ahead:(p==null?void 0:p.ahead)??0,blockerCodeSet:R}),Y=k?r("shell.worktreeMergePreviewLoading"):m?r("shell.worktreeMergeApplying"):x?r("shell.worktreeCleanupRunning"):G?r("shell.worktreeMergeAlreadyMerged"):p!=null&&p.canMerge?r("shell.worktreeMergeReady"):N?r("shell.worktreeMergeBlocked"):r("shell.worktreeMergePreviewIdle"),O=[r("shell.worktreeMergeCurrentBranch",{branch:Z}),r("shell.worktreeMergeParentBranch",{branch:T}),r("shell.worktreeMergeTargetWorkspace",{name:F}),p?r("shell.worktreeMergeAheadBehind",{ahead:p.ahead,behind:p.behind}):r("shell.worktreeMergeAheadBehindPending"),p!=null&&p.mergeBaseCommit?r("shell.worktreeMergeBaseCommit",{commit:jf(p.mergeBaseCommit)}):null].filter(P=>!!P),j=`worktree-merge-panel-details-${e.workspaceId}`,J=c?r("shell.worktreeMergeCollapseDetails"):r("shell.worktreeMergeExpandDetails"),te=Yf({t:r,loading:k,applying:m,cleaning:x,hasPreview:N,canMerge:(p==null?void 0:p.canMerge)===!0,showMergedState:G,blockerCodeSet:R});return o.useEffect(()=>{h(!1)},[e.workspaceId]),n.jsxs("section",{className:"worktree-merge-panel","data-state":_,children:[n.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":J,"aria-expanded":c,"aria-controls":j,onClick:()=>{h(P=>!P)},children:[n.jsx("span",{className:"worktree-merge-panel-summary-label",children:r("shell.worktreeMergePanelLabel")}),n.jsx("span",{className:"worktree-merge-panel-summary-main",children:n.jsx("span",{className:"worktree-merge-panel-summary-tags",children:te.map(P=>n.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":_,children:P},P))})}),n.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:J})]}),c?n.jsxs("div",{id:j,className:"worktree-merge-panel-details",children:[n.jsx("div",{className:"worktree-merge-panel-detail-head",children:n.jsx("span",{className:"worktree-merge-panel-status","data-state":_,children:Y})}),n.jsx("div",{className:"worktree-merge-panel-meta",children:O.map(P=>n.jsx("span",{children:P},P))}),N?n.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":r("shell.worktreeMergeChecklistTitle"),children:z.map(P=>n.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":P.state,children:[n.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:P.state==="done"?"✓":P.state==="blocked"?"!":"·"}),n.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[n.jsx("strong",{children:P.label}),P.detail?n.jsx("span",{children:P.detail}):null]})]},P.key))}):null,t!=null&&t.error?n.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,p!=null&&p.conflictPaths.length?n.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[n.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:r("shell.worktreeMergeConflictLabel")}),n.jsx("div",{className:"worktree-merge-panel-conflict-list",children:p.conflictPaths.map(P=>n.jsx("code",{children:P},P))})]}):null,n.jsxs("div",{className:"worktree-merge-panel-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:k||m||x,onClick:s,children:N?r("shell.worktreeMergePreviewRefresh"):r("shell.worktreeMergePreviewAction")}),n.jsx("button",{type:"button",className:"primary-button",disabled:!E,onClick:a,children:m?r("shell.worktreeMergeApplying"):r("shell.worktreeMergeApplyAction")}),n.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!v,onClick:i,children:x?r("shell.worktreeCleanupRunning"):r("shell.worktreeCleanupAction")})]})]}):null]})}function Yf(e){const{t,loading:s,applying:a,cleaning:i,hasPreview:c,canMerge:h,showMergedState:p,blockerCodeSet:k}=e;if(s)return[t("shell.worktreeMergeCompactChecking")];if(a)return[t("shell.worktreeMergeCompactMerging")];if(i)return[t("shell.worktreeMergeCompactCleaning")];const m=[];return k.has("SOURCE_NOT_ACTIVE")&&m.push(t("shell.worktreeMergeCompactInactive")),k.has("SOURCE_DIRTY")&&m.push(t("shell.worktreeMergeCompactDirty")),k.has("TARGET_DIRTY")&&m.push(t("shell.worktreeMergeCompactTargetDirty")),k.has("HAS_CONFLICTS")&&m.push(t("shell.worktreeMergeCompactConflict")),k.has("HAS_ACTIVE_CHILDREN")&&m.push(t("shell.worktreeMergeCompactChildren")),m.length>0?m:h?[t("shell.worktreeMergeCompactReady")]:p?[t("shell.worktreeMergeCompactMerged")]:c?k.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function Jf(e){const{t,hasPreview:s,showMergedState:a,isMerged:i,canMerge:c,ahead:h,blockerCodeSet:p}=e,k=p.has("SOURCE_NOT_ACTIVE"),m=p.has("SOURCE_DIRTY"),x=p.has("TARGET_DIRTY"),N=p.has("HAS_ACTIVE_CHILDREN"),C=p.has("HAS_CONFLICTS"),R=s&&!i&&(p.has("NO_COMMITS_TO_MERGE")||h<=0),H=a?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:c?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:s?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:s&&k?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:s?k?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:s&&m?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:s?m?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:s&&x?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:s?x?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:s&&N?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:s?N?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:R?t(i?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:R?i?"done":"blocked":s?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:C?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:C?"blocked":s?"done":"pending"},H]}function mb({shellMode:e="desktop"}){var Fr,es,Or,Hr,$r,Zs,Qs,er,pt,ft,tr,nr,Ii,Ti,Ri;const t=ga(),s=br(),a=Ln(),{showToast:i}=as(),c=Ur(l=>l.sessionDisplaySortMode),h=Ur(l=>l.notificationPreferences.notifyOnPermissionRequest),p=Ur(l=>l.notificationPreferences.notifyOnSessionCompleted),k=Ur(l=>l.notificationPreferences.notifyOnSessionFailed),m=o.useRef(Ah(Xl)),x=o.useRef(0),N=o.useRef((((es=(Fr=m.current)==null?void 0:Fr.items)==null?void 0:es.length)??0)>0),C=o.useRef(new Map),R=o.useRef(!1),H=o.useRef(null),G=o.useRef(0),E=o.useRef(null),v=o.useRef(null),_=o.useRef(new Set),F=o.useRef(new Set),Z=o.useRef(new Set),T=o.useRef(new Set),z=o.useRef(null),Y=o.useRef(null),O=o.useRef(null),j=o.useRef(null),J=o.useRef(null),te=o.useRef(null),P=o.useRef(null),ue=o.useRef(null),K=o.useRef(0),Q=o.useRef(0),D=o.useRef(i),y=o.useRef(a.bridge),I=o.useRef(null),q=o.useRef(0),se=o.useRef(0),Ce=o.useRef(null),ie=o.useRef(null),oe=o.useRef(null),ve=o.useRef(!1),ke=o.useRef(!1),he=o.useRef(!1),de=o.useRef(new Map),ge=o.useRef(!1),ye=o.useRef(new Map),V=o.useRef(""),g=o.useRef([]),S=o.useRef(c),B=o.useRef(null),[L,we]=o.useState(()=>lo(m.current,c)),re=o.useRef(L),[Se,Ke]=o.useState(()=>{var l,u;return(((u=(l=m.current)==null?void 0:l.items)==null?void 0:u.length)??0)===0}),[Ae,$e]=o.useState(null),[Oe,Ft]=o.useState(()=>sa($o(jo,xp),Ro,Po)),[De,Ze]=o.useState(()=>sa($o(No,vp),Mo,Eo)),[Ue,os]=o.useState(()=>Uo(Co,!1)),[ze,Ot]=o.useState(()=>Uo(Io,!1)),[Rt,ls]=o.useState(null),[Mt,Bn]=o.useState(()=>Ko(m.current)),[vt,fn]=o.useState(()=>Go($a)),[Qe,cs]=o.useState(!1),[Hs,mn]=o.useState("files"),[vr,Re]=o.useState(!1),[ds,_e]=o.useState(!1),[Ht,Dn]=o.useState(null),[it,nt]=o.useState({}),[_n,et]=o.useState(!1),[us,Fn]=o.useState("sessions"),[bn,On]=o.useState(""),[en,Hn]=o.useState(""),[tn,hs]=o.useState(!1),[Sa,$t]=o.useState(null),[ja,nn]=o.useState([]),[gn,$n]=o.useState(null),[Ut,kn]=o.useState({}),Pt=Fl(a),yr=o.useCallback(l=>{if(Pt)return;const u=I.current;u&&(!Ja(a,l.button,l.target)||!zo(l.clientY,u)||Au({platform:a,button:l.button,target:l.target,clientX:l.clientX,clientY:l.clientY}))},[a,Pt]),Sr=o.useCallback(l=>{if(Pt)return;const u=I.current;u&&(!Ja(a,l.button,l.target)||!zo(l.clientY,u)||a.bridge.setWindowState("toggle-zoom"))},[a,Pt]),[st,Et]=o.useState({}),[We,ps]=o.useState(null),[wn,Un]=o.useState(!1),[xn,$s]=o.useState([]),[vn,sn]=o.useState(()=>new Set),[Gt,Ve]=o.useState(!1),[yn,Gn]=o.useState(!1),[zn,fs]=o.useState(0),[Sn,ot]=o.useState(()=>Go(To)),rn=e==="desktop"&&a.isDesktop&&a.ui.osFamily==="macos"&&a.ui.prefersOverlayTitlebar,{theme:bt}=Gc();o.useEffect(()=>{D.current=i},[i]),o.useEffect(()=>{if(typeof document>"u")return;const{documentElement:l,body:u}=document,b=document.getElementById("root");if(!rn){l.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy");return}const M=l.style.background,$=(u==null?void 0:u.style.background)??"",U=(b==null?void 0:b.style.background)??"";return l.setAttribute("data-workbench-macos-vibrancy","true"),u==null||u.setAttribute("data-workbench-macos-vibrancy","true"),l.style.background="transparent",u==null||u.style.setProperty("background","transparent"),b==null||b.style.setProperty("background","transparent"),()=>{l.removeAttribute("data-workbench-macos-vibrancy"),u==null||u.removeAttribute("data-workbench-macos-vibrancy"),l.style.background=M,u&&(u.style.background=$),b instanceof HTMLElement&&(b.style.background=U)}},[rn]),o.useEffect(()=>()=>{oe.current!==null&&window.clearTimeout(oe.current)},[]),o.useEffect(()=>{var $;if(typeof document>"u")return;const{documentElement:l,body:u}=document;if(!Rt){l.removeAttribute(Ps),u==null||u.removeAttribute(Ps);return}const b=l.style.cursor,M=(u==null?void 0:u.style.cursor)??"";return l.setAttribute(Ps,Rt),u==null||u.setAttribute(Ps,Rt),l.style.cursor="col-resize",u==null||u.style.setProperty("cursor","col-resize"),($=window.getSelection())==null||$.removeAllRanges(),()=>{l.removeAttribute(Ps),u==null||u.removeAttribute(Ps),l.style.cursor=b,u&&(u.style.cursor=M)}},[Rt]),o.useEffect(()=>{S.current=c,we(l=>Nf(l,c))},[c]),o.useEffect(()=>{re.current=L},[L]),o.useEffect(()=>{y.current=a.bridge},[a.bridge]),o.useEffect(()=>{q.current=Oe},[Oe]),o.useEffect(()=>{se.current=De},[De]),o.useEffect(()=>()=>{Ce.current!==null&&window.cancelAnimationFrame(Ce.current)},[]);const lt=o.useCallback(async()=>{const l=K.current+1;K.current=l;try{const u=await Oh();if(l!==K.current)return;if(!u.initialized){$s([]),sn(new Set);return}const[b,M,$,U]=await Promise.all([Hh(),Gh(),Zl(),qh()]);if(l!==K.current)return;$s(Dp(b.overview,M.items,$.items)),sn(new Set(U.items.map(ae=>ae.notificationId)))}catch{if(l!==K.current)return;$s([]),sn(new Set)}},[]),ms=o.useCallback(l=>{const u=l.map(b=>b.createdAt).sort((b,M)=>Wn(M)-Wn(b))[0]??null;u&&ot(b=>b&&Wn(b)>=Wn(u)?b:u)},[]);o.useEffect(()=>{Sn&&ns(To,Sn)},[Sn]),o.useEffect(()=>{lt();const l=window.setInterval(()=>{lt()},Sp);return()=>{window.clearInterval(l)}},[lt]),o.useEffect(()=>{Je("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),o.useEffect(()=>{var l,u;Je("workbench.cached_snapshot_loaded",{cached:!!m.current,workspaceCount:((l=m.current)==null?void 0:l.items.length)??0,sessionCount:((u=m.current)==null?void 0:u.items.reduce((b,M)=>b+M.sessions.length,0))??0})},[]);function Us(l){var M;if(!l||!Array.isArray(l.items))return;xf(C.current,l);const u=wf(l,C.current);Je("workbench.apply_snapshot",{workspaceCount:u.items.length,sessionCount:u.items.reduce(($,U)=>$+U.sessions.length,0),currentSessionId:((M=hr(t.pathname))==null?void 0:M.sessionId)??null});const b=lo(u,S.current);m.current=u,Jr(u),re.current=b,we(b),Bn(Ko(u)),$e(null)}const rt=o.useCallback(async()=>{const l=x.current+1;x.current=l,Ke(u=>u||!N.current),Je("workbench.refresh_navigation.start",{requestId:l,hasNavigationData:N.current});try{const u=await rd();if(l!==x.current){Je("workbench.refresh_navigation.stale",{requestId:l});return}Us(u)}catch(u){if(l!==x.current)return;$e(u instanceof Error?u.message:r("shell.navigationLoadFailed")),D.current({title:u instanceof Error?u.message:r("shell.navigationLoadFailed"),tone:"error"})}finally{Je("workbench.refresh_navigation.end",{requestId:l,success:l===x.current}),l===x.current&&Ke(!1)}},[]),ct=o.useCallback(l=>{we(u=>{const b=vf(u,l,S.current);return re.current=b,b})},[]),dt=o.useCallback(()=>{var l;(l=v.current)==null||l.requestRefresh()},[]),an=o.useCallback((l,u)=>{s(Tt(l,u))},[s]),jn=o.useCallback((l,u,b)=>{var M;z.current={workspaceId:l,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(M=v.current)==null||M.subscribeFileTree(l,u,b)},[]),Nn=o.useCallback((l,u,b)=>{var M;Y.current={workspaceId:l,paths:u,knownRevisionByPath:b==null?void 0:b.knownRevisionByPath},(M=v.current)==null||M.requestFileTreeRefresh(l,u,b)},[]),zt=o.useCallback(l=>(_.current.add(l),()=>{_.current.delete(l)}),[]),Cn=o.useCallback((l,u)=>{var b;O.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeGit(l,u)},[]),yt=o.useCallback((l,u)=>{var b;j.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.requestGitRefresh(l,u)},[]),bs=o.useCallback(l=>(F.current.add(l),()=>{F.current.delete(l)}),[]),qt=o.useCallback((l,u)=>{var b;J.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeWorkspaceManagement(l,u)},[]),gs=o.useCallback((l,u)=>{var b;te.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},kn(M=>{var $;return{...M,[l]:{detail:(($=M[l])==null?void 0:$.detail)??null,loading:!0,error:null}}}),(b=v.current)==null||b.requestWorkspaceManagementRefresh(l,u)},[]),jr=o.useCallback(l=>(Z.current.add(l),()=>{Z.current.delete(l)}),[]),qn=o.useCallback(async(l,u=!1)=>{const b=l.trim();if(!b)return;let M=!0;if(Et($=>{const U=$[b];return!u&&(U!=null&&U.loading)?(M=!1,$):{...$,[b]:{preview:(U==null?void 0:U.preview)??null,loading:!0,applying:(U==null?void 0:U.applying)??!1,cleaning:(U==null?void 0:U.cleaning)??!1,error:null}}}),!!M)try{const $=await ad(b);Et(U=>{var ae,be;return{...U,[b]:{preview:$,loading:!1,applying:((ae=U[b])==null?void 0:ae.applying)??!1,cleaning:((be=U[b])==null?void 0:be.cleaning)??!1,error:null}}})}catch($){Et(U=>{var ae,be,me;return{...U,[b]:{preview:((ae=U[b])==null?void 0:ae.preview)??null,loading:!1,applying:((be=U[b])==null?void 0:be.applying)??!1,cleaning:((me=U[b])==null?void 0:me.cleaning)??!1,error:$ instanceof Error?$.message:r("shell.worktreeMergePreviewFailed")}}})}},[]),At=o.useCallback(async l=>{const u=l.trim();if(u){Et(b=>{var M,$;return{...b,[u]:{preview:((M=b[u])==null?void 0:M.preview)??null,loading:!1,applying:!0,cleaning:(($=b[u])==null?void 0:$.cleaning)??!1,error:null}}});try{const b=await id(u);Et(M=>{var $;return{...M,[u]:{preview:b.preview,loading:!1,applying:!1,cleaning:(($=M[u])==null?void 0:$.cleaning)??!1,error:null}}}),dt(),rt(),qn(u,!0),yt(b.preview.targetWorkspace.id),D.current({title:b.applied?r("shell.worktreeMergeApplySuccess"):r("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(b){Et(M=>{var $,U;return{...M,[u]:{preview:(($=M[u])==null?void 0:$.preview)??null,loading:!1,applying:!1,cleaning:((U=M[u])==null?void 0:U.cleaning)??!1,error:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed")}}}),D.current({title:b instanceof Error?b.message:r("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[qn,rt,yt,dt]),tt=o.useCallback(async l=>{var M,$;const u=l.workspaceId,b=wn&&(($=(M=st[u])==null?void 0:M.preview)==null?void 0:$.alreadyMerged)===!0;Et(U=>{var ae;return{...U,[u]:{preview:((ae=U[u])==null?void 0:ae.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const U=await od(u,{deleteBranch:b});if(Et(ae=>{var be;return{...ae,[u]:{preview:((be=ae[u])==null?void 0:be.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),Un(!1),ps(ae=>(ae==null?void 0:ae.workspaceId)===u?null:ae),dt(),await rt(),s(Qt(l.parentWorkspaceId),{replace:!0}),U.branchDeleted){D.current({title:r("shell.worktreeCleanupDeleteBranchSuccess",{branch:U.deletedBranchName||l.branchName}),tone:"success"});return}if(U.branchDeleteRequested){D.current({title:r("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:l.branchName}),description:U.branchDeleteError||void 0,tone:"warning"});return}D.current({title:r("shell.worktreeCleanupSuccess"),tone:"success"})}catch(U){Et(ae=>{var be;return{...ae,[u]:{preview:((be=ae[u])==null?void 0:be.preview)??null,loading:!1,applying:!1,cleaning:!1,error:U instanceof Error?U.message:r("shell.worktreeCleanupFailed")}}}),D.current({title:U instanceof Error?U.message:r("shell.worktreeCleanupFailed"),tone:"error"})}},[wn,s,rt,dt,st]),Nr=o.useCallback(l=>{Un(!1),ps(l)},[]),Me=o.useCallback((l,u)=>{var b;P.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.subscribeTerminalManager(l,u)},[]),ks=o.useCallback((l,u)=>{var b;ue.current={workspaceId:l,knownRevision:u==null?void 0:u.knownRevision},(b=v.current)==null||b.requestTerminalManagerRefresh(l,u)},[]),In=o.useCallback(l=>(T.current.add(l),()=>{T.current.delete(l)}),[]),gt=o.useCallback((l,u)=>{we(b=>yf(b,l,u??new Date().toISOString()))},[]),Kt=o.useCallback(async(l,u)=>{C.current.set(l,u),we(b=>Yo(b,l,u));try{const b=await ul(l,u),M=Zt(b);M===u?C.current.set(l,M):C.current.delete(l),ct(b),dt(),rt()}catch(b){throw C.current.delete(l),we(M=>Yo(M,l,!u)),b}},[rt,dt,ct]),St=o.useCallback((l,u)=>{Je("workbench.set_session_workspace",{sessionId:l,workspaceId:u}),nt(b=>{if(!u){if(!(l in b))return b;const M={...b};return delete M[l],M}return b[l]===u?b:{...b,[l]:u}})},[]);o.useEffect(()=>{N.current=L.length>0},[L]),o.useEffect(()=>{Je("workbench.navigation_state",{navigationLoading:Se,workspaceCount:L.length,sessionCount:L.reduce((l,u)=>l+u.sessions.length,0)})},[L,Se]),o.useEffect(()=>{E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{var X;E.current=null,!(R.current||N.current)&&(Je("workbench.refresh_navigation.ws_fallback_triggered"),(X=v.current)==null||X.requestRefresh())},1200);const l=new Iu({onConnectionChange:X=>{X==="connected"&&ld(),X==="reconnect_failed"&&!N.current&&($e(r("shell.navigationLoadFailed")),D.current({id:"workbench-navigation-connection",title:r("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:X=>{R.current=!0,Je("workbench.ws_snapshot_received",{workspaceCount:X.items.length,sessionCount:X.items.reduce((Te,Bt)=>Te+Bt.sessions.length,0)}),E.current!==null&&(window.clearTimeout(E.current),E.current=null),Us(X),Ke(!1)},onFileTreeSnapshot:X=>{_.current.forEach(Te=>Te(X))},onGitSnapshot:X=>{ur(yc(X.workspaceId),{revision:X.revision??null,status:X.status,history:X.history,historyTotalCount:X.historyTotalCount,historyNextCursor:X.historyNextCursor,branches:X.branches}),kn(Te=>{var un;const Bt=((un=L.find(Pc=>Pc.workspace.id===X.workspaceId))==null?void 0:un.workspace)??null;if(!Bt)return Te;const Xt=Te[X.workspaceId],Xe=Nc(jc((Xt==null?void 0:Xt.detail)??Sc(Bt),Bt),X);return ur(si(X.workspaceId),Xe),{...Te,[X.workspaceId]:{detail:Xe,loading:!1,error:null}}}),F.current.forEach(Te=>Te(X))},onWorkspaceManagementSnapshot:X=>{ur(si(X.workspaceId),X),kn(Te=>({...Te,[X.workspaceId]:{detail:X,loading:!1,error:null}})),Z.current.forEach(Te=>Te(X))},onTerminalManagerSnapshot:X=>{T.current.forEach(Te=>Te(X))},onUnauthorized:()=>{pr.clear(),s("/login",{replace:!0})}});l.primeWorkbenchSnapshot(m.current),v.current=l;const u=z.current,b=Y.current,M=O.current,$=j.current,U=J.current,ae=te.current,be=P.current,me=ue.current;return u&&l.subscribeFileTree(u.workspaceId,u.paths,{knownRevisionByPath:u.knownRevisionByPath}),M&&l.subscribeGit(M.workspaceId,{knownRevision:M.knownRevision}),U&&l.subscribeWorkspaceManagement(U.workspaceId,{knownRevision:U.knownRevision}),be&&l.subscribeTerminalManager(be.workspaceId,{knownRevision:be.knownRevision}),b&&l.requestFileTreeRefresh(b.workspaceId,b.paths,{knownRevisionByPath:b.knownRevisionByPath}),$&&l.requestGitRefresh($.workspaceId,{knownRevision:$.knownRevision}),ae&&l.requestWorkspaceManagementRefresh(ae.workspaceId,{knownRevision:ae.knownRevision}),me&&l.requestTerminalManagerRefresh(me.workspaceId,{knownRevision:me.knownRevision}),l.start(),()=>{E.current!==null&&(window.clearTimeout(E.current),E.current=null),v.current===l&&(v.current=null),l.close()}},[s]),o.useEffect(()=>{ns(jo,String(Oe))},[Oe]),o.useEffect(()=>{ns(No,String(De))},[De]),o.useEffect(()=>{ns(Co,String(Ue))},[Ue]),o.useEffect(()=>{ns(Io,String(ze))},[ze]),o.useEffect(()=>{if(!vt){df($a);return}ns($a,vt)},[vt]),o.useEffect(()=>{if(Qe||ze)return;const l=window.setTimeout(()=>{cs(!0)},yp);return()=>{window.clearTimeout(l)}},[Qe,ze]);const jt=hr(t.pathname),xe=(jt==null?void 0:jt.sessionId)??null,at=xe?Mc(xe):!1,je=o.useMemo(()=>Ud(L),[L]),Tn=o.useMemo(()=>ff(L),[L]),Kn=o.useMemo(()=>new Set(Mt),[Mt]),ws=o.useMemo(()=>je.filter(l=>l.session.isFavorite===!0).map(l=>l.session.sessionId),[je]),Vt=o.useMemo(()=>new Set(ws),[ws]),xs=o.useCallback(l=>{const u=za(l,Mt);m.current=u,Jr(u),re.current=l,we(l)},[Mt]),Cr=o.useCallback(l=>{const u=!Kn.has(l),b=Zo(Mt,l,u),M=za(L,b);m.current=M,Jr(M),Bn(b),hl(l,{collapsed:u}).catch($=>{const U=Zo(b,l,!u),ae=za(L,U);m.current=ae,Jr(ae),Bn(U),D.current({title:$ instanceof Error?$.message:r("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[Kn,Mt,L]),Gs=o.useCallback(()=>{B.current={originalGroups:re.current}},[]),Ir=o.useCallback((l,u,b)=>{const M=re.current,$=kf(M,l,u,b);$!==M&&xs($)},[xs]),zs=o.useCallback(()=>{const l=B.current;B.current=null;const u=re.current;l&&(l.originalGroups.length===u.length&&l.originalGroups.every((b,M)=>{var $;return b.workspace.id===(($=u[M])==null?void 0:$.workspace.id)})||cd({workspaceIds:u.map(b=>b.workspace.id)}).catch(b=>{xs(l.originalGroups),D.current({title:b instanceof Error?b.message:r("shell.workspaceReorderFailed"),tone:"error"})}))},[xs]);o.useEffect(()=>{const l=new Map;if(je.forEach(({session:u})=>{l.set(u.sessionId,{activityState:u.activityState,completedAt:u.completedAt??null,runningState:u.runningState??null})}),!he.current){he.current=!0,de.current=l;return}je.forEach(({session:u})=>{var ae;if(u.sessionId===xe)return;const b=de.current.get(u.sessionId);if(!b)return;const M=b.activityState!=="completed_unread"&&u.activityState==="completed_unread",$=((ae=u.title)==null?void 0:ae.trim())||r("common.unknown");if(p&&M){const be=r("conversation.backgroundCompletionToastDescription",{title:$});D.current({id:`workbench-session-completed-${u.sessionId}-${u.completedAt??"unknown"}`,title:r("conversation.backgroundCompletionToastTitle"),description:be,tone:"success",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>an(u.workspaceId,u.sessionId)}}),y.current.showNotification(r("conversation.backgroundCompletionToastTitle"),be)}const U=b.runningState!=="failed"&&(u.runningState??null)==="failed";if(k&&U){const be=Bp(u)??r("conversation.runtimeFailed"),me=r("conversation.backgroundFailureToastDescription",{title:$,detail:be});D.current({id:`workbench-session-failed-${u.sessionId}-${u.updatedAt}`,title:r("conversation.backgroundFailureToastTitle"),description:me,tone:"error",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>an(u.workspaceId,u.sessionId)}}),y.current.showNotification(r("conversation.backgroundFailureToastTitle"),me)}}),de.current=l},[xe,je,p,k,an]),o.useEffect(()=>{g.current=je.map(l=>l.session).filter(l=>l.sessionId!==xe&&Wp(l)).map(l=>{var u;return{sessionId:l.sessionId,workspaceId:l.workspaceId,title:((u=l.title)==null?void 0:u.trim())||r("common.unknown")}})},[xe,je]),o.useEffect(()=>{let l=!1,u=null;const b=()=>{u=window.setTimeout(()=>{M().finally(()=>{l||b()})},Np)},M=async()=>{var me;const $=g.current;if($.length===0){ge.current||(ge.current=!0),V.current="";return}const U=new Set($.map(X=>X.sessionId)),ae=await Promise.all($.map(async X=>{try{const Te=await ud(X.sessionId);return{session:X,items:Te.items}}catch{return{session:X,items:null}}}));if(l)return;for(const X of ae){if(!X.items)continue;const Te=X.items.filter(Xe=>Xe.status==="pending"),Bt=new Set(Te.map(Xe=>Xe.id)),Xt=ye.current.get(X.session.sessionId)??new Set;ge.current&&Te.forEach(Xe=>{if(Xt.has(Xe.id)||!h)return;const un=r("conversation.backgroundPermissionToastDescription",{title:X.session.title,requestTitle:Xe.title});D.current({id:`workbench-permission-request-${Xe.id}`,title:r("conversation.permissionRequestToastTitle"),description:un,tone:"warning",durationMs:8e3,action:{label:r("shell.contextOpenSession"),onClick:()=>an(X.session.workspaceId,X.session.sessionId)}}),y.current.showNotification(r("conversation.permissionRequestToastTitle"),un)}),ye.current.set(X.session.sessionId,Bt)}for(const[X,Te]of ye.current.entries())!U.has(X)&&Te.size===0&&ye.current.delete(X);const be=Lp(ye.current,U);ge.current&&be!==V.current&&((me=v.current)==null||me.requestRefresh()),V.current=be,ge.current=!0};return M().finally(()=>{l||b()}),()=>{l=!0,u!==null&&window.clearTimeout(u)}},[h,an]),o.useEffect(()=>{Se&&L.length===0||(Bn(l=>kc(l,Tn)),fn(l=>l&&Tn.has(l)?l:null))},[Tn,Se]);const ut=je.find(l=>l.session.sessionId===xe)??null,Ge=(ut==null?void 0:ut.workspace.id)??(xe?it[xe]??null:null),kt=_o(t.pathname,t.search),Vn=kt&&Tn.has(kt)?kt:null,vs=vt&&Tn.has(vt)?vt:null,Xn=Ge??Vn??vs??null,le=Xn??((Or=L[0])==null?void 0:Or.workspace.id)??null,Tr=o.useCallback(l=>{if(l){const u=je.find(b=>b.workspace.id===l)??null;if(u)return u}return je[0]??null},[je]),qs=o.useCallback(l=>{const u=typeof window>"u"?null:window.localStorage.getItem(Qr);if(!u)return null;const b=u.split("?")[0]??u,M=hr(b);if(!M)return window.localStorage.removeItem(Qr),null;const $=M.sessionId,U=je.find(be=>be.session.sessionId===$)??null,ae=M.workspaceId??(U==null?void 0:U.workspace.id)??null;return U&&(!l||ae===l)?Tt(U.workspace.id,U.session.sessionId):(window.localStorage.removeItem(Qr),null)},[je]),ys=o.useMemo(()=>xn.filter(l=>!vn.has(l.id)),[vn,xn]),Rn=o.useMemo(()=>ys.filter(l=>Up(l,Sn)).length,[ys,Sn]);o.useEffect(()=>{Gt&&ms(ys)},[ys,ms,Gt]);const Ss=o.useCallback(l=>{Ve(!1),l.routePath&&s(l.routePath)},[s]),Yn=o.useCallback(async(l,u)=>{const b=Q.current+1;Q.current=b;try{const M=await Kh(l,u);if(b!==Q.current)return;sn($=>{const U=new Set($);return M.item?U.add(M.item.notificationId):U.delete(l),U})}catch(M){if(b!==Q.current)return;D.current({title:r("shell.globalNotificationsArchiveFailed"),description:M instanceof Error?M.message:void 0,tone:"error"})}},[]);o.useEffect(()=>{Ge&&fn(l=>l===Ge?l:Ge)},[Ge]),o.useEffect(()=>{var U;if(Se)return;const l=((U=L[0])==null?void 0:U.workspace.id)??null,u=Vn??l??vs,b=xe&&!at?Tr(u):null,M=xe&&!at?qs(u):null,$=b?Tt(b.workspace.id,b.session.sessionId):null;if(kt&&!Vn){s(M??$??(l?Vp(t.pathname,l):Ga(e)),{replace:!0});return}if(xe&&!at&&!Ge){s(M??$??(l?mr(l):Ga(e)),{replace:!0});return}},[xe,Tr,at,t.pathname,s,L,Se,qs,kt,Ge,e,vs,Vn]),o.useEffect(()=>{Je("workbench.current_workspace_resolved",{currentSessionId:xe,sessionWorkspaceId:Ge,routeWorkspaceId:kt,currentWorkspaceId:le,source:Ge?ut?"navigation":"sessionWorkspaceMap":kt?"route":vt?"workspaceSelection":"navigationFallback"})},[ut,xe,le,kt,vt,Ge]);const wt=la(t.pathname)?"terminals":ca(t.pathname)?"butler":"conversation",He=e==="mobile",Jn=Ga(e),Rr=o.useMemo(()=>L.map(l=>{const u=ic(l.sessions);return{workspace:l.workspace,visibleSessions:u,archivedSessions:l.sessions.filter(b=>Zt(b)&&!xa(b)),visibleSessionTree:Ni(u,c).filter(b=>!Vt.has(b.item.sessionId)&&!hi(Dt(b),M=>Vt.has(M.sessionId))),childWorktrees:uc(l.childWorktrees,Vt,c),isCollapsed:Kn.has(l.workspace.id)}}),[Kn,Vt,L,c]),js=o.useMemo(()=>Lh(L),[L]),Ns=o.useMemo(()=>qo(L,le),[le,L]),Wt=(ut?Fd(ut.session,ut.session.sessionIsolatedWorkspace):le)??le,Nt=o.useMemo(()=>qo(L,Wt),[Wt,L]),Mr=o.useMemo(()=>le?(Ns==null?void 0:Ns.workspace)??L.map(l=>l.workspace).find(l=>l.id===le)??null:null,[le,Ns,L]),Ks=o.useMemo(()=>Wt?(Nt==null?void 0:Nt.workspace)??L.map(l=>l.workspace).find(l=>l.id===Wt)??null:null,[Wt,Nt,L]),Cs=(Nt==null?void 0:Nt.meta)??null,Na=(le?js[le]??null:null)??(Mr?ma(Mr):null),Ct=(Wt?js[Wt]??null:null)??(Ks?ma(Ks):Na),Pr=Cs?st[Cs.workspaceId]??null:null,xt=wt==="conversation"&&Dd((ut==null?void 0:ut.session)??null);o.useEffect(()=>{Je("workbench.info_panel_state",{infoPanelReady:Qe,rightCollapsed:ze||xt,currentWorkspaceId:le,sessionWorkspaceId:Ge,currentSessionId:xe})},[xe,le,Qe,xt,ze,Ge]);const Zn=o.useMemo(()=>je.filter(l=>Vt.has(l.session.sessionId)&&!Zt(l.session)&&!ti(l.session)),[Vt,je]),Is=t.pathname.startsWith("/settings")?"settings":ca(t.pathname)?"terminals":la(t.pathname)?"butler":Kp(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":qp(t.pathname)||Fo(t.pathname)?"sessions":"workspaces",Er=He&&(Is==="sessions"&&Fo(t.pathname)||ca(t.pathname)),Ar=ka({isNativeMobile:a.isNativeMobile,viewportClass:a.viewportClass}),Qn=kr({viewportClass:a.viewportClass,activeEntry:Is,hasNavigationPanel:He,hasAuxiliaryPanel:He,preferCompactLayout:Ar}),Ca=He&&Bl(Qn),Ia=He&&Dl(Qn),Wr=o.useMemo(()=>L.map(l=>l.workspace),[L]),Ta=o.useMemo(()=>{const l=bn.trim().toLowerCase();return l?je.filter(u=>{const b=(u.session.title||"").toLowerCase(),M=u.workspace.name.toLowerCase(),$=va(u.session.provider,"full").toLowerCase();return b.includes(l)||M.includes(l)||$.includes(l)}):[]},[je,bn]);o.useEffect(()=>{var u;const l=le??((u=L[0])==null?void 0:u.workspace.id)??"";l&&Hn(b=>b&&L.some($=>$.workspace.id===b)?b:l)},[le,L]),o.useEffect(()=>{xe&&!at&&Ge&&ns(Qr,`${t.pathname}${t.search}`)},[xe,at,t.pathname,t.search,Ge]),o.useEffect(()=>{if(xe&&at){H.current=`${t.pathname}${t.search}`;return}xe&&!at&&(H.current=null)},[xe,at,t.pathname,t.search]),o.useEffect(()=>{He||(Re(!1),_e(!1))},[He]),o.useEffect(()=>{!He||Se||!zp(t.pathname)||Xn||(Re(!1),_e(!1),s(Jn,{replace:!0}))},[Xn,He,t.pathname,s,Se,Jn]);function Ra(){if(He){Re(!0);return}os(!1)}function Ma(){if(!xt){if(on(),He){_e(!0);return}Ot(!1)}}function Lr(){if(He){Re(l=>!l);return}os(l=>!l)}function Br(){if(!xt){if(on(),He){_e(l=>!l);return}Ot(l=>!l)}}function on(){cs(!0)}function Ts(l){if(fn(l),on(),la(t.pathname)){const u=ss(l);t.pathname!==u&&s(u);return}xe&&Ge!==l&&s(Jn)}const Rs=o.useCallback(async l=>{var M;const u=((M=je.find($=>$.session.sessionId===l))==null?void 0:M.session)??null,b=(u==null?void 0:u.isFavorite)!==!0;we($=>Jo($,l,b));try{const $=await dd(l,b);ct($),dt()}catch($){throw we(U=>Jo(U,l,!b)),$}},[je,dt,ct]),Vs=o.useCallback((l,u)=>{rc(l,u).then(()=>{s(El(l,u))}).catch(b=>{i({title:b instanceof Error?b.message:r("shell.startSessionFailed"),tone:"error"})})},[s,i]),Dr=o.useCallback(l=>{var M;const u=((M=l.workspaceId)==null?void 0:M.trim())||le,b=Xp(l.filePath);return!u||!b?!1:(on(),mn("files"),He?(Re(!1),_e(!0)):Ot(!1),$n({requestId:G.current+1,workspaceId:u,filePath:b,openViewer:l.openViewer===!0}),G.current+=1,!0)},[le,He]),Xs=o.useCallback(async(l,u)=>{const b=await pl(l,u.trim());return ct(b),b},[ct]);function Ys(l){et(!0)}function ln(){et(!1),Fn("sessions"),On(""),$t(null),nn([]),hs(!1)}async function _r(){const l=bn.trim();if(!l||!en.trim()){nn([]),$t(null);return}hs(!0),$t(null);try{const u=await Rd(en,l);nn(u.items)}catch(u){nn([]),$t(u instanceof Error?u.message:r("shell.searchCodeFailed"))}finally{hs(!1)}}function Js(l,u){const b=I.current;b&&(b.style.setProperty("--workbench-left-width",`${l}px`),b.style.setProperty("--workbench-left-current-width",Ue?"0px":`${l}px`),b.style.setProperty("--workbench-right-width",`${u}px`),b.style.setProperty("--workbench-right-current-width",ze?"0px":`${u}px`))}function d(l={}){return{leftWidth:l.leftWidth??(Ue?0:q.current),rightWidth:l.rightWidth??(Le&&!ze?se.current:0),leftCollapsed:l.leftCollapsed??Ue,rightCollapsed:l.rightCollapsed??(!Le||ze),prefersDarkAppearance:l.prefersDarkAppearance??bt!=="light",isResizing:l.isResizing??Rt!==null}}function f(l,u){var be;u.preventDefault(),u.stopPropagation(),(be=window.getSelection())==null||be.removeAllRanges();const b=u.clientX,M=l==="left"?Oe:De;ls(l);const $=()=>{const me=ie.current;if(ie.current=null,me!==null){if(l==="left"){q.current=me,Ft(X=>X===me?X:me),Js(me,se.current);return}se.current=me,Ze(X=>X===me?X:me),Js(q.current,me)}};function U(me){var Xt;me.preventDefault(),(Xt=window.getSelection())==null||Xt.removeAllRanges();const X=me.clientX-b,Te=l==="left"?sa(M+X,Ro,Po):sa(M-X,Mo,Eo),Bt=l==="left"?q.current:se.current;Te===Bt&&ie.current===null||(ie.current=Te,Ce.current===null&&(Ce.current=window.requestAnimationFrame(()=>{Ce.current=null,$()})))}function ae(){document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",ae),Ce.current!==null&&(window.cancelAnimationFrame(Ce.current),Ce.current=null),$(),ls(X=>X===l?null:X);const me=d({isResizing:!1});dn.current=me,a.bridge.syncNativeSidebarLayout(me)}document.addEventListener("mousemove",U,{passive:!1}),document.addEventListener("mouseup",ae)}function w(){if(W())return;if(je.length===0){s(Jn);return}const l=Tt(je[0].workspace.id,je[0].session.sessionId);s(l)}function A(){if(!W(le)){if(le){s(mr(le));return}s(Jn)}}function W(l){if(xe&&Ge)return l&&Ge&&Ge!==l?!1:(s(`${t.pathname}${t.search}`),!0);if(H.current){if(l){const[b,M=""]=H.current.split("?"),$=_o(b??H.current,M?`?${M}`:"");if($&&$!==l)return!1}return s(H.current),!0}const u=qs(l);return u?(s(u),!0):!1}o.useEffect(()=>{if(typeof window>"u")return;function l(u){if(!(u.metaKey||u.ctrlKey)){u.key==="Escape"&&(Re(!1),_e(!1));return}if(hf(u.target))return;const M=u.key.toLowerCase();if(!u.shiftKey&&M==="b"){u.preventDefault(),Lr();return}if(u.shiftKey&&M==="i"){u.preventDefault(),Br();return}if(!u.shiftKey&&M===","){u.preventDefault(),s("/settings");return}if(!u.shiftKey&&M==="1"){u.preventDefault(),w();return}if(!u.shiftKey&&M==="2"){u.preventDefault(),s(le?ss(le):mt());return}if(!u.shiftKey&&M==="k"){u.preventDefault(),pf();return}u.shiftKey&&M==="r"&&(u.preventDefault(),rt())}return window.addEventListener("keydown",l),()=>{window.removeEventListener("keydown",l)}},[s,rt,He,w]);const fe=o.useMemo(()=>({shellMode:e,navigationGroups:L,navigationLoading:Se,navigationError:Ae,currentWorkspaceId:le,currentSessionId:xe,favoriteSessionIds:ws,favoriteSessions:Zn,globalNotifications:xn,archivedNotificationIds:Array.from(vn),showArchivedNotifications:yn,unreadNotificationCount:Rn,refreshNavigation:rt,requestNavigationRefresh:dt,openNotificationPanel:()=>{Ve(!0)},closeNotificationPanel:()=>{Ve(!1)},setShowArchivedNotifications:Gn,archiveNotification:l=>{Yn(l,!0)},unarchiveNotification:l=>{Yn(l,!1)},setAuxiliaryPanel:Dn,subscribeFileTree:jn,requestFileTreeRefresh:Nn,addFileTreeSnapshotListener:zt,subscribeGitSnapshot:Cn,requestGitRefresh:yt,addGitSnapshotListener:bs,subscribeWorkspaceManagementSnapshot:qt,requestWorkspaceManagementRefresh:gs,addWorkspaceManagementSnapshotListener:jr,workspaceManagementStateById:Ut,subscribeTerminalManagerSnapshot:Me,requestTerminalManagerRefresh:ks,addTerminalManagerSnapshotListener:In,selectWorkspace:Ts,toggleFavoriteSession:Rs,archiveSession:l=>Kt(l,!0),unarchiveSession:l=>Kt(l,!1),renameSession:Xs,startDraftSession:Vs,markNavigationSessionSeen:gt,upsertNavigationSession:ct,setSessionWorkspace:St,revealWorkspaceFile:Dr}),[zt,bs,jr,In,Kt,xe,le,xn,ws,Zn,Ts,vn,gt,Ae,L,Se,Rn,Nn,yt,gs,rt,dt,Gn,Dn,ks,Xs,yn,Ut,e,Vs,St,jn,Cn,qt,Me,Yn,Rs,ct,Dr]),ee={"--workbench-left-width":`${Oe}px`,"--workbench-left-current-width":Ue?"0px":`${Oe}px`,"--workbench-right-width":`${De}px`,"--workbench-right-current-width":ze||xt?"0px":`${De}px`},Pe=wt==="butler"?Ht:n.jsx(nl,{panelReady:Qe,activeTab:Hs,fileRevealRequest:gn,onTabChange:l=>{on(),mn(l)},currentSessionId:at?null:xe,activeWorkspaceId:Wt,navigationGroups:L,workspaceContext:Ct,worktreeMeta:Cs,worktreeMergeState:Pr,onRefreshWorktreeMergePreview:qn,onApplyWorktreeMerge:At,onCleanupWorktree:tt}),Le=Pe!==null,Ie=ze||xt,qe=a.isDesktop&&a.ui.osFamily==="macos"&&a.ui.prefersOverlayTitlebar;o.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:l,body:u}=document,b=()=>{oe.current!==null&&(window.clearTimeout(oe.current),oe.current=null);const $=ve.current;ve.current=!1,l.removeAttribute(ta),u==null||u.removeAttribute(ta),$&&ke.current&&(ke.current=!1,fs(U=>U+1))};if(!qe){b();return}const M=()=>{ve.current=!0,l.setAttribute(ta,"true"),u==null||u.setAttribute(ta,"true"),oe.current!==null&&window.clearTimeout(oe.current),oe.current=window.setTimeout(()=>{b()},Ip)};return window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M),b()}},[qe]);const ht=o.useMemo(()=>({leftWidth:Ue?0:Oe,rightWidth:Le&&!Ie?De:0,leftCollapsed:Ue,rightCollapsed:!Le||Ie,prefersDarkAppearance:bt!=="light",isResizing:Rt!==null}),[Rt,Ie,Ue,Oe,De,Le,bt]),cn=o.useDeferredValue(ht),pe=Rt===null?cn:ht,dn=o.useRef(ht);o.useEffect(()=>{dn.current=ht},[ht]),o.useEffect(()=>{if(typeof window>"u")return;let l=null;const u=()=>{l=null,a.bridge.syncNativeSidebarLayout(pe)},b=()=>{l!==null&&window.cancelAnimationFrame(l),l=window.requestAnimationFrame(u)};return rn?(b(),()=>{l!==null&&window.cancelAnimationFrame(l)}):(a.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{l!==null&&window.cancelAnimationFrame(l)})},[pe,a.bridge,rn]),o.useLayoutEffect(()=>{const l=I.current;if(!l||!qe||typeof window>"u"){Bo(l);return}let u=null,b=null;const M=new Set([l]),$=()=>{ke.current=!1;const ae=window.getComputedStyle(l),be=nc(ae,"--desktop-macos-traffic-light-center-y");if(be===null){Bo(l);return}const me={navToolbar:Mn(l,Fe.navToolbar.selector),infoTabs:Mn(l,Fe.infoTabs.selector),auxiliaryToolbarButton:Mn(l,Fe.auxiliaryToolbarButton.selector),conversationHeaderMain:Mn(l,Fe.conversationHeaderMain.selector),conversationHeaderActions:Mn(l,Fe.conversationHeaderActions.selector),terminalTabbarMain:Mn(l,Fe.terminalTabbarMain.selector),collapsedLeftControls:Mn(l,Fe.collapsedLeftControls.selector),collapsedRightControls:Mn(l,Fe.collapsedRightControls.selector)},X=[me.infoTabs,me.conversationHeaderMain,me.conversationHeaderActions,me.terminalTabbarMain].filter(Xe=>Xe!==null),Te=[me.collapsedLeftControls,me.collapsedRightControls].filter(Xe=>Xe!==null),Bt=Te.length>0?Jt(ae,"--workbench-collapsed-controls-live-shift-y",be,Te.reduce((Xe,un)=>Xe+un,0)/Te.length):null,Xt=X.length>0?Jt(ae,"--workbench-titlebar-live-content-shift-y",be,X.reduce((Xe,un)=>Xe+un,0)/X.length):null;Yt(l,"--workbench-titlebar-live-content-shift-y",Xt),Yt(l,"--workbench-collapsed-controls-live-shift-y",Bt),Yt(l,Fe.navToolbar.variableName,Jt(ae,Fe.navToolbar.variableName,be,me.navToolbar)),Yt(l,Fe.infoTabs.variableName,Jt(ae,Fe.infoTabs.variableName,be,me.infoTabs)),Yt(l,Fe.auxiliaryToolbarButton.variableName,Jt(ae,Fe.auxiliaryToolbarButton.variableName,be,me.auxiliaryToolbarButton)),Yt(l,Fe.conversationHeaderMain.variableName,Jt(ae,Fe.conversationHeaderMain.variableName,be,me.conversationHeaderMain)),Yt(l,Fe.conversationHeaderActions.variableName,Jt(ae,Fe.conversationHeaderActions.variableName,be,me.conversationHeaderActions)),Yt(l,Fe.terminalTabbarMain.variableName,Jt(ae,Fe.terminalTabbarMain.variableName,be,me.terminalTabbarMain)),Yt(l,Fe.collapsedLeftControls.variableName,Jt(ae,Fe.collapsedLeftControls.variableName,be,me.collapsedLeftControls)),Yt(l,Fe.collapsedRightControls.variableName,Jt(ae,Fe.collapsedRightControls.variableName,be,me.collapsedRightControls))},U=()=>{if(ve.current){ke.current=!0;return}u!==null&&window.cancelAnimationFrame(u),u=window.requestAnimationFrame(()=>{u=null,$()})};if(U(),typeof ResizeObserver<"u"){b=new ResizeObserver(()=>{U()});for(const ae of Object.values(Fe))for(const be of l.querySelectorAll(ae.selector))M.add(be);for(const ae of M)b.observe(ae)}return window.addEventListener("resize",U),()=>{u!==null&&window.cancelAnimationFrame(u),window.removeEventListener("resize",U),b==null||b.disconnect()}},[wt,Qe,Ue,t.pathname,t.search,ze,Le,qe,zn]);const Lt=He?n.jsx(tl,{workspaceGroups:Rr,workspaceVisualContextMap:js,sessionDisplaySortMode:c,favoriteSessions:Zn,favoriteSessionIds:Vt,activeWorkspaceId:le,isConversationActive:wt==="conversation",isTerminalActive:wt==="terminals",isButlerActive:wt==="butler",isSearchOpen:_n,navigationLoading:Se,navigationError:Ae,activeSessionId:xe,onRefreshNavigation:rt,onSessionUpdated:ct,onNavigateConversation:w,onNavigateTerminals:()=>{Re(!1),s(le?ss(le):mt())},onNavigateButler:()=>{Re(!1),s(le?rs(le):mt())},onOpenSearch:()=>{Re(!1),Ys()},onOpenSettings:()=>{Re(!1),s("/settings")},onSelectWorkspace:Ts,onToggleWorkspaceCollapse:Cr,onStartWorkspaceReorder:Gs,onPreviewWorkspaceReorder:Ir,onCommitWorkspaceReorder:zs,allowWorkspaceReorder:!1,subscribeGitSnapshot:Cn,requestGitRefresh:yt,subscribeWorkspaceManagementSnapshot:qt,requestWorkspaceManagementRefresh:gs,onToggleFavoriteSession:Rs,onArchiveSession:l=>Kt(l,!0),onUnarchiveSession:l=>Kt(l,!1),workspaceManagementStateById:Ut,setWorkspaceManagementStateById:kn,unreadNotificationCount:Rn,notificationPanelOpen:Gt,onToggleNotificationPanel:()=>{Ve(l=>!l)},onClose:()=>Re(!1)}):null,Be=He&&Le?Pe:null;return n.jsxs(ac.Provider,{value:fe,children:[He?n.jsx(n.Fragment,{children:n.jsx(gu,{activeEntry:Is,presentation:Er?"conversation-focus":"default",navigationPanel:Lt,auxiliaryPanel:Be,onOpenNavigation:()=>{_e(!1),Re(!0)},onOpenSearch:()=>{Re(!1),_e(!1),Ys()},onOpenAuxiliary:()=>{Le&&(on(),Re(!1),_e(!0))},onNavigateWorkspaces:()=>{Re(!1),_e(!1),s(mt())},onNavigateTerminals:()=>{Re(!1),_e(!1),s(le?ss(le):mt())},onNavigateButler:()=>{Re(!1),_e(!1),s(le?rs(le):mt())},onNavigateSessions:()=>{Re(!1),_e(!1),A()},onNavigateToolFiles:()=>{Re(!1),_e(!1),s(le?Rl(le):mt())},onNavigateToolGit:()=>{Re(!1),_e(!1),s(le?Ml(le):mt())},onNavigateToolProcesses:()=>{Re(!1),_e(!1),s(le?Pl(le):mt())},onNavigateSettings:()=>{Re(!1),_e(!1),s("/settings")},children:n.jsx(Mi,{})})}):n.jsx("div",{className:"workbench-shell",ref:I,style:ee,onMouseDownCapture:yr,onDoubleClickCapture:Sr,"data-nav-loading":Se,"data-left-collapsed":Ue,"data-right-collapsed":Ie,"data-info-ready":Qe,"data-parallel-conversation-active":xt?"true":void 0,"data-runtime-platform":a.platform,"data-os-family":a.ui.osFamily,"data-overlay-titlebar":a.ui.prefersOverlayTitlebar,children:n.jsxs("div",{className:"workbench-body-shell",children:[n.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":Ue,children:n.jsx(tl,{workspaceGroups:Rr,workspaceVisualContextMap:js,sessionDisplaySortMode:c,favoriteSessions:Zn,favoriteSessionIds:Vt,activeWorkspaceId:le,isConversationActive:wt==="conversation",isTerminalActive:wt==="terminals",isButlerActive:wt==="butler",isSearchOpen:_n,navigationLoading:Se,navigationError:Ae,activeSessionId:xe,onRefreshNavigation:rt,onSessionUpdated:ct,onNavigateConversation:w,onNavigateTerminals:()=>s(le?ss(le):mt()),onNavigateButler:()=>s(le?rs(le):mt()),onOpenSearch:()=>Ys(),onOpenSettings:()=>s("/settings"),onSelectWorkspace:Ts,onToggleWorkspaceCollapse:Cr,onStartWorkspaceReorder:Gs,onPreviewWorkspaceReorder:Ir,onCommitWorkspaceReorder:zs,allowWorkspaceReorder:!0,subscribeGitSnapshot:Cn,requestGitRefresh:yt,subscribeWorkspaceManagementSnapshot:qt,requestWorkspaceManagementRefresh:gs,onToggleFavoriteSession:Rs,onArchiveSession:l=>Kt(l,!0),onUnarchiveSession:l=>Kt(l,!1),workspaceManagementStateById:Ut,setWorkspaceManagementStateById:kn,unreadNotificationCount:Rn,notificationPanelOpen:Gt,onToggleNotificationPanel:()=>{Ve(l=>!l)},onToggleCollapse:()=>os(!0)})}),n.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":Ue,role:"separator","aria-label":r("shell.leftResizerLabel"),onMouseDown:Ue?void 0:l=>f("left",l)}),n.jsxs("div",{className:"workbench-main-shell",children:[n.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!Ue&&!ze,children:[n.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":Ue,children:[n.jsx(Qo,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:Ra}),n.jsx(Ql,{collapsed:!0}),n.jsx(Ic,{unreadCount:Rn,open:Gt,onToggle:()=>{Ve(l=>!l)},collapsed:!0})]}),Le&&!xt?n.jsx("div",{className:"workbench-collapsed-controls right","data-visible":ze,children:n.jsx(Qo,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:r("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Ma})}):null]}),n.jsx(Mi,{})]}),Le?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Ie,"data-auto-hidden":xt?"true":void 0,role:"separator","aria-label":r("shell.rightResizerLabel"),onMouseDown:Ie?void 0:l=>f("right",l)}),n.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(Ct==null?void 0:Ct.tone)??"root","data-worktree-depth":(Ct==null?void 0:Ct.depth)??0,"data-collapsed":Ie,"data-auto-hidden":xt?"true":void 0,"data-custom-panel":wt==="butler","aria-hidden":Ie,style:hn(Ct),children:xt?null:wt==="butler"?n.jsx("div",{className:"workbench-auxiliary-custom-panel",children:Ht}):n.jsx(nl,{panelReady:Qe,activeTab:Hs,fileRevealRequest:gn,onTabChange:l=>{on(),mn(l)},onToggleCollapse:()=>Ot(!0),currentSessionId:at?null:xe,activeWorkspaceId:Wt,navigationGroups:L,workspaceContext:Ct,worktreeMeta:Cs,worktreeMergeState:Pr,onRefreshWorktreeMergePreview:qn,onApplyWorktreeMerge:At,onCleanupWorktree:Nr})})]}):null]})}),n.jsx(Pf,{open:Gt,notifications:xn,archivedNotificationIds:vn,showArchivedNotifications:yn,onClose:()=>Ve(!1),onToggleShowArchivedNotifications:Gn,onArchiveNotification:l=>{Yn(l,!0)},onUnarchiveNotification:l=>{Yn(l,!1)},onSelectNotification:Ss,preferredWorkspaceId:le,preferredSessionId:at?null:xe}),n.jsx(Vf,{open:_n,mode:us,keyword:bn,codeWorkspaceId:en,codeResults:ja,codeLoading:tn,codeError:Sa,workspaceOptions:Wr,sessionResults:Ta,onClose:ln,onModeChange:l=>{Fn(l),$t(null),nn([])},onKeywordChange:l=>{On(l),us==="code"&&!l.trim()&&(nn([]),$t(null))},onCodeWorkspaceChange:l=>Hn(l),onCodeSearch:()=>{_r()},onOpenSession:l=>{ln();const u=je.find(b=>b.session.sessionId===l)??null;s(u?Tt(u.workspace.id,l):mt())}}),n.jsxs(Ye,{open:We!==null,title:r("shell.worktreeCleanupModalTitle"),description:r("shell.worktreeCleanupModalDescription"),onClose:()=>{var l;We&&((l=st[We.workspaceId])!=null&&l.cleaning)||(Un(!1),ps(null))},children:[n.jsx("p",{className:"workbench-section-empty",children:We?r("shell.worktreeCleanupConfirm",{name:We.displayName||We.branchName}):""}),We?n.jsxs("div",{className:"worktree-cleanup-modal-options",children:[n.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[n.jsx("input",{type:"checkbox",checked:wn,disabled:!!((Hr=st[We.workspaceId])!=null&&Hr.cleaning)||((Zs=($r=st[We.workspaceId])==null?void 0:$r.preview)==null?void 0:Zs.alreadyMerged)!==!0,onChange:l=>Un(l.target.checked)}),n.jsx("span",{children:r("shell.worktreeCleanupDeleteBranchLabel",{branch:We.branchName})})]}),((er=(Qs=st[We.workspaceId])==null?void 0:Qs.preview)==null?void 0:er.alreadyMerged)!==!0?n.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:r("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,n.jsxs("div",{className:"workbench-modal-actions",children:[n.jsx("button",{type:"button",className:"secondary-button",disabled:!!(We&&((pt=st[We.workspaceId])!=null&&pt.cleaning)),onClick:()=>{Un(!1),ps(null)},children:r("common.cancel")}),n.jsx("button",{type:"button",className:wn&&We&&((tr=(ft=st[We.workspaceId])==null?void 0:ft.preview)==null?void 0:tr.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!We||!!(We&&((nr=st[We.workspaceId])!=null&&nr.cleaning)),onClick:()=>{We&&tt(We)},children:We&&((Ii=st[We.workspaceId])!=null&&Ii.cleaning)?r("shell.worktreeCleanupRunning"):wn&&We&&((Ri=(Ti=st[We.workspaceId])==null?void 0:Ti.preview)==null?void 0:Ri.alreadyMerged)===!0?r("shell.worktreeCleanupDeleteBranchAction"):r("shell.worktreeCleanupAction")})]})]}),He?n.jsxs(n.Fragment,{children:[Ca?null:n.jsx(sl,{isOpen:vr,side:"left",onClose:()=>Re(!1),children:Lt}),Ia?null:n.jsx(sl,{isOpen:ds,side:"right",onClose:()=>_e(!1),children:Be})]}):null]})}function sl({isOpen:e,side:t,onClose:s,children:a,className:i,overlayClassName:c}){if(!e)return null;const h=n.jsxs(n.Fragment,{children:[n.jsx("div",{className:["mobile-nav-overlay","open",c].filter(Boolean).join(" "),onClick:s,role:"button",tabIndex:0,"aria-label":r("common.back"),onKeyDown:p=>{p.key==="Escape"&&s()}}),n.jsx("div",{className:["mobile-nav-drawer",t,"open",i].filter(Boolean).join(" "),children:a})]});return typeof document>"u"?h:gr.createPortal(h,document.body)}function bb(){return o.useContext(ac)??{navigationGroups:[],navigationLoading:!1,navigationError:null,shellMode:"desktop",currentWorkspaceId:null,currentSessionId:null,favoriteSessionIds:[],favoriteSessions:[],globalNotifications:[],archivedNotificationIds:[],showArchivedNotifications:!1,unreadNotificationCount:0,refreshNavigation:async()=>{},requestNavigationRefresh:()=>{},openNotificationPanel:()=>{},closeNotificationPanel:()=>{},setShowArchivedNotifications:()=>{},archiveNotification:()=>{},unarchiveNotification:()=>{},setAuxiliaryPanel:()=>{},subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{},subscribeWorkspaceManagementSnapshot:()=>{},requestWorkspaceManagementRefresh:()=>{},addWorkspaceManagementSnapshotListener:()=>()=>{},workspaceManagementStateById:{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{},selectWorkspace:()=>{},toggleFavoriteSession:async()=>{},archiveSession:async()=>{},unarchiveSession:async()=>{},renameSession:async()=>{throw new Error("workbench shell unavailable")},startDraftSession:()=>{},setSessionWorkspace:()=>{},upsertNavigationSession:()=>{},markNavigationSessionSeen:()=>{},revealWorkspaceFile:()=>!1}}function Mc(e){return e.startsWith("draft-")}export{ma as $,yi as A,cp as B,mh as C,bh as D,Bd as E,Mm as F,Wd as G,xi as H,Ph as I,fh as J,Lh as K,Gd as L,Am as M,Pn as N,Os as O,As as P,hb as Q,lb as R,cb as S,pb as T,ib as U,Je as V,Iu as W,om as X,Ud as Y,Em as Z,_d as _,mb as a,ym as a$,wp as a0,Tm as a1,Im as a2,Pm as a3,Fd as a4,hn as a5,_i as a6,Rm as a7,Uu as a8,Gu as a9,ub as aA,sb as aB,Ym as aC,Jm as aD,Zm as aE,eb as aF,tb as aG,nb as aH,Jh as aI,Gm as aJ,Vm as aK,Xm as aL,ab as aM,Ah as aN,Yh as aO,ei as aP,pm as aQ,bm as aR,mm as aS,cm as aT,Rd as aU,dm as aV,um as aW,Ed as aX,im as aY,fm as aZ,wm as a_,zu as aa,Bm as ab,vi as ac,vh as ad,yh as ae,_m as af,Ol as ag,Wm as ah,Dd as ai,mt as aj,Od as ak,hi as al,Cu as am,Lm as an,Fm as ao,Om as ap,qm as aq,Km as ar,zm as as,Um as at,Hm as au,rb as av,$m as aw,Qm as ax,ob as ay,db as az,Tt as b,Md as b0,Cm as b1,xm as b2,gm as b3,vm as b4,km as b5,Nm as b6,jm as b7,Sm as b8,hm as b9,lm as ba,Il as bb,bp as c,lp as d,fb as e,xh as f,Oh as g,Hh as h,Dm as i,Zl as j,mr as k,Gh as l,lo as m,ss as n,Tl as o,rs as p,Pl as q,ha as r,Qt as s,Nh as t,bb as u,Ih as v,ur as w,Rl as x,Ml as y,jh as z};
|